LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Installing a system with btrfs, managing root snapshots (https://www.linuxquestions.org/questions/linux-newbie-8/installing-a-system-with-btrfs-managing-root-snapshots-4175482391/)

LightSeeker 10-27-2013 03:18 PM

Installing a system with btrfs, managing root snapshots
 
Hi,

In the near future I would like to install a system (probably Manjaro) but I would like to be able to rollback from an upgrade-gone-bad (which happened to my current system, whee upgrading resulted in some glitches) or any of the other reasons that a person would have to require making snapshots and be able to restore the system to its previous state.

Now the problem for me isn't partitioning or installing, but the way that I should proceed in managin snapshots. I have looked at the btrf wiki, but everything is still not very clear to me, hence the reason I am posting this thread.

As I said, I want to be able to rollback my root system (/). I will probably have a separate home partition. As far as I understand, I should modify my fstab file in order to set the default subvolume. The example given on the btrfs wiki (Sysadmin Guide) is:

LABEL=btr_pool / btrfs defaults 0 0
LABEL=btr_pool /home btrfs defaults,subvol=home 0 0
LABEL=btr_pool /media/btrfs btrfs defaults,noauto,subvolid=0 0 0


If I understand correctly, the last Label creates a subvolume in the root filesystem? Does this mean, that the system will automatically mount the subvolume that is set to 0 at boot? At least that's what I can infer form the document on the Oracle website (http://docs.oracle.com/cd/E37670_01/...se3_btrfs.html), which says: "By default, the operating system mounts the parent btrfs volume, which has an ID of 0, unless you use set-default to change the default subvolume."



Okay, let's say I make a snapshot of the system before upgrading. The btrfs site suggests:

# mount /media/btrfs
# cd /media/btrfs
# btrfs subvolume snapshot root root_snapshot_2011_01_11
# cd ~
# umount /media/btrfs


As I can understand, mounting the /media/btrfs subvolume wihtout any further options automatically mounts the root filesystem? Also the "btrfs subvolume snapshot" command automatically recognizes "root" as / ?

Now suppose an upgrade went bad. How to rollback? The btrfs wiki suggests a solution, but instead of using the root filesystem as the example, it goes with the /home partition:

# mount /media/btrfs
# umount /home
# mount -o defaults,subvol=home_snapshot_A /dev/sda /home
# btrfs subvolume delete /media/btrfs/home # optional; this is so the
# mv /media/btrfs/home_snapshot_A /media/btrfs/home # /etc/fstab need not change.
# umount /media/btrfs


Now since I am still concerned with rolling back the root partition, I guess that I do not need to perform steps 2 (umounting home) and 3 (overriding the default subvolume mount) and just use the mv command to rename the root_snapshot to the name root?

Is that how this process is supposed to be done?

I tried to do it this way (minus the fstab entries) in one of my Vbox installations, but I foud out, that using the mv command just sent my PC into a 20 min high-cpu activity that ate up all most of my designated virtual hard drive space.

p.s.: one more question. Since Btrfs uses copy-on-write, does this mean, that snapshots initially do not consume a significant amount of space, but that this increases with changes made to the system?


All times are GMT -5. The time now is 01:48 AM.