http://dustymabe.com/2013/01/06/os-upgrade-and-rollback-using-btrfs/
http://www.funtoo.org/BTRFS_Fun

# btrfs subvolume list -a /
ID 257 gen 3081 top level 5 path <FS_TREE>/@
ID 258 gen 3081 top level 5 path <FS_TREE>/@home

# mkdir -p /var/tmp/btrfs_mount

# mount -t btrfs -o subvolid=0 /dev/sda5 /var/tmp/btrfs_mount/

# cd /var/tmp/btrfs_mount/

# ls
@  @home

# btrfs subvolume snapshot / /var/tmp/btrfs_mount/@_20160811
Create a snapshot of '/' in '/var/tmp/btrfs_mount/@_20160811'

# btrfs subvolume snapshot /home /var/tmp/btrfs_mount/@home_20160811
Create a snapshot of '/home' in '/var/tmp/btrfs_mount/@home_20160811'

# btrfs subvolume list -a /
ID 257 gen 3126 top level 5 path <FS_TREE>/@
ID 258 gen 3126 top level 5 path <FS_TREE>/@home
ID 279 gen 3125 top level 5 path <FS_TREE>/@_20160811
ID 280 gen 3125 top level 5 path <FS_TREE>/@home_20160811

# btrfs subvolume set-default 279 /

edit paths in the following files:

/var/tmp/btrfs_mount/<SNAPSHOT_NAME>/etc/fstab
/var/tmp/btrfs_mount/<SNAPSHOT_NAME>/boot/grub/grub.cfg
/boot/efi/EFI/ubuntu/grub.cfg

# umount /var/tmp/btrfs_mount

# reboot

after a successful boot, run # update-grub to update all the paths in /boot/grub/grub.cfg

now, let's delete the original subvolumes @ and @home:

# mkdir -p /var/tmp/btrfs_mount

# mount -t btrfs -o subvolid=0 /dev/sda5 /var/tmp/btrfs_mount/

# cd /var/tmp/btrfs_mount/

# ls
@  @home  @_20160811  @home_20160811

# btrfs subvolume delete /var/tmp/btrfs_mount/@home

# btrfs subvolume delete /var/tmp/btrfs_mount/@

# umount /var/tmp/btrfs_mount/
Advertisements