You are not logged in.

#1 2015-10-19 11:00:50

Ateya
Member
From: Perth, WA
Registered: 2015-10-19
Posts: 4

Help with btrfs snapshots

Hi all,

I'm having some trouble getting my btrfs snapshots to work. I've set up a VM to test the snapshots and I have been using the program snapper to create and manage my snapshots. At the moment I've got 1 snapshot of my root which is the one I want to rollback to. If I run "snapper rollback 1", it creates a new read only snapshot of the current filesystem and then creates a new read write copy of the snapshot that I want to rollback to and sets this as the default subvolume of the btrfs filesystem. All of this is working fine.

The issue I am having is once this new read write snapshot is created, I cannot seem to boot to it. By that I mean the system seems to ignore any changes to I make to fstab and keep booting to the original root subvolume. I have also tried to replace the "ROOT" subvolume (the original) with the new read write snapshot. However if I try to "mv" it, it just moves the contents of the snapshot to a folder and leaves the subvolume in it's place except for the fact that it is now empty. I'm not sure how to move subvolumes around.

Any help that anyone can give me to make me understand how to rollback to snapshots would be greatly appreciated. The whole process seems overly complicated. I'll put various outputs of commands below to give people more of an idea of how the VM is set up.

output of lsblk (ignore sda1, it's a BIOS boot partition for GRUB):

[root@Arch_testVM ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0    4G  0 disk
├─sda1   8:1    0   32M  0 part
└─sda2   8:2    0    4G  0 part /mnt
sr0     11:0    1 1024M  0 rom

output of "mount |grep "/sda" (I have subvolid=0 mounted to /mnt so I can see the whole filesystem):

[root@Arch_testVM ~]# mount |grep "/sda"
/dev/sda2 on / type btrfs (rw,relatime,space_cache,subvolid=257,subvol=/ROOT)
/dev/sda2 on /mnt type btrfs (rw,relatime,space_cache,subvolid=5,subvol=/)

output of "btrfs subvol list /mnt"

[root@Arch_testVM ~]# btrfs subvol list /mnt
ID 257 gen 255 top level 5 path ROOT
ID 260 gen 112 top level 257 path ROOT/var/lib/machines
ID 262 gen 253 top level 257 path ROOT/.snapshots
ID 277 gen 252 top level 262 path ROOT/.snapshots/1/snapshot
ID 278 gen 251 top level 262 path ROOT/.snapshots/2/snapshot
ID 279 gen 252 top level 262 path ROOT/.snapshots/3/snapshot

contents of my fstab

[root@Arch_testVM ~]# cat /etc/fstab
#<file system>    <dir>    <type>    <options>                    <dump>    <pass>
/dev/sda2    /    btrfs    rw,relatime,space_cache                0    1
/dev/sda2    /mnt    btrfs    rw,relatime,space_cache,subvolid=5,subvol=/    0    2

If there's any other outputs anyone else would like, just let me know.

Edit: I have tried booting to the Arch disk and renaming "ROOT" to "ROOT_old" and put the rw snapshot in it's place, renaming it to "ROOT". The system now boot's to the snapshot. Surely there must be an easier way to do all of this... I think the issue is that when the initcpio mounts the root filesystem, it uses the subvolume name "ROOT" to do it. Does anyone know how I can change it so that it boots into whatever subvolume is set to the default subvolume for the filesystem?

Last edited by Ateya (2015-10-19 17:06:15)

Offline

Board footer

Powered by FluxBB