Root fs backup on reboot / dual boot SD card

    • Offizieller Beitrag

    I remove my SD cards from my HC2s and clone them offline. Works fine.
    But I figure that it should be possible to configure OMV to use two root filesystems while booting.


    On the card there might be three partitions:


    boot - this is the normal boot partition.
    rootfs - this is the normal root fs with OMV.
    rootfs2 - this is a new minimal root fs.


    OMV first boot to rootfs2.
    A script in rootfs2 creates a new offline snapshot off rootfs. Stored in rootfs2? Or somewhere else?
    A script in rootfs2 reboots to OMV in rootfs.


    Then in rootfs the updated snapshot may be copied to some other location, possibly on the network. Also old snapshots may be deleted so that perhaps only the latest five are kept. After/before updating or changing the configuration all that would be needed to perform a system backup is to reboot. It might even be possible to add an option to revert rootfs to the previous snapshot, and reboot. A little like timeshift.


    Could this work? Can something like this be implemented in OMV, perhaps as an option if the boot media is big enough? With 32 GB SD cards or thumbdrives it should be fine.


    Or perhaps as a DIY hack of the boot process? Can you reboot from one root fs to another rootfs? Or do you have to update the boot partition and then reboot?


    Is this something that someone already is doing? If so, please comment.

  • You will also need to backup (and restore) the boot track as taking snapshots of partitions doesn't do that.

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

  • Could this work?


    Since you're talking about the ARM images and not Raspberry Pi: Armbian (the basis here) switched from anachronistic device/partition names to UUIDs a while ago. Simply check /boot/armbianEnv.txt and there the rootdev=UUID= definition and output of blkid.


    Since the rootfs on the ARM images lives on btrfs creating snapshots should be rather easy and space efficient so IMO there's no need to store those 'snapshots' anywhere else as long as you use the filesystem's snapshot functionality.


    BTW: you could benefit from btrfs also when creating offline images of SD cards by using compression and the reflink feature to create images that only consume the space needed for differences compared to latest created image. Just like incremental backups...

    • Offizieller Beitrag

    Storing the snapshot on the rootfs using a COW snapshot sounds nice. The only problem being that I so far have managed to stay very ignorant about the details of using the btrfs COW snapshot features. I just know they exist. Oh, well... I'll just have to google and find a btrfs 101 snapshot tutorial.


    The snapshots will still have to be copied elsewhere to keep safe from card failures. But as long as the card is OK the btrfs snapshots should be available for a total revert to previous config.


    Also I think I can figure out how to change what rootfs to boot to.


    The remaining problem is that it would be nice if it was possible to reboot directly from rootfs1 to rootfs without having to change anything in the boot partition. Otherwise the boot partition has to be updated twice during every boot sequence. Once to reboot from rootfs2 to rootfs and once to boot to rootfs2 after shutdown.


    For rootfs I might use Armbian? Perhaps a cut down version? Or is there a really small minimal ARM distro that could be used only to run a few commands to create the btrfs snapshot on rootfs and then reboot, possibly after modifying the boot partition?


    And as @gderf says, if I want to write a fresh SD card, I'll need a copy of the MBR and the partition table as well.

  • if I want to write a fresh SD card, I'll need a copy of the MBR and the partition table as well

    Don't forget u-boot. I would closely study the nand-sata-install script since this tool contains all steps needed to transfer an installation from here to there.


    Which rootfs to choose? Most probably I would clone the OMV rootfs (since btrfs with zlib compression and wasting less space than a 'thin' Armbian ext4 rootfs).


    It should be possible to change boot behavior by dealing with u-boot (modifying the boot script which by default is set to read out armbianEnv.txt and do the appropriate things). But I would assume you'll loose a lot of time dealing with u-boot low-level stuff :)

    • Offizieller Beitrag

    The only problem being that I so far have managed to stay very ignorant about the details of using the btrfs COW snapshot features.

    Have a look at snapper. I use it on my HC-2. Snapshots are created automatically before and after any update.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!