Forum

Full Version: Sync root filesystem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a root filesystem on a USB hard drive (btrfs) and I wish to keep it synched with the root fs on my SD card so to have a fully functional and always up to date fallback root. I'm new to btrfs, but for what I understaood it is somehow similar to a normal ext3/4 filesystem with an intrinsic ability to chroot: this way you can have snapshots by copy.
If my understanding is not too far from reality, I believe I can keep the two filesystems in sync by using rsync from the USB drive current root to the SD card current root without bothering moving over the snapshots (to save space and write access to the SD card).

The idea is to cron schedule something like the following:

Code:
mount /dev/mmcblk0p1 /mnt/sd-root-fs
rsync -aAHXv --delete /* /mnt/sd-root-fs/@root --exclude={"/boot/*","/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*",/lost+found}
umount /mnt/sd-root-fs

Will that work? Am I completely misunderstanding btrfs?
Why not create a BTRFS mirror with the SD card and your USB stick?

In regard to your last question. You are not using BTRFS in any way in that approach.
(4th Aug, 2014 08:08 PM)CurlyMo Wrote: [ -> ]Why not create a BTRFS mirror with the SD card and your USB stick?

Can you expand on this? If btrfs mirror implies copying over the snapshots I don't think it is desiderable: a lot more write operations toward the SD, much more space used and a very little benefit considering the SD is going to be used only "on the go". If something breaks and I need to revert to a previous snapshot I'll do it on the HD and force a re-sync to ensure I have a stable OS on the HD and on the SD.
If that doesn't imply moving the snapshots then I will definitely be interested.

UPDATE: I've read a bit about mirroring and it looks as a soft raid... While I do understand it's cleanness and advantages it doesn't seem to fit my needs: too many read/writes to the SD card for my tastes Smile

(4th Aug, 2014 08:08 PM)CurlyMo Wrote: [ -> ]In regard to your last question. You are not using BTRFS in any way in that approach.

I agree, I'm not using any benefit from btrfs that I know, but I don't know btrfs so I don't know what can I do with it. With my lack of knowledge I went for the route I already know with a slight change to what I understood about btrfs layout, but I might be totally wrong.... And I wish to avoid corrupting my OS :-D

For what I have understood I cannot create a snapshot on one drive and copy it over the other as that wouldn't work: snapshots are incremental and based on filesystem state. A raid configuration is not optimal as it will use the two storages at the same time, while I want to preserve the SD... what options do I have?

UPDATE: I believe I could avoid the cumbersome mount /mnt/sd-rootfs/@/root and at least use btrfs feature to automatically mount the root partition in it's default state, then issue the rsync command and unmount it: this should at least remove the complexity of manually handling the correct data tree.
For security and stability reasons I can even create a snapshot before each rsync operation to be able to revert my changes: I understand snapshots are really cheap.
Do you believe this would work?
Reference URL's