Does not work when root system is not using @ subvol

Asked by Danny on 2021-01-31

Hi,
I manually partitioned my HD before installing Ubuntu, consequently I ended up with a BTRFS volume where root is at root not at @ subvolume. Consequently apt_btrfs_snapshot.py is failing to recognize my volume as BTRFS as root is not at @. Will your script work if I just remove the check for root on @?

Cheers,
Danny Poulson.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu apt-btrfs-snapshot Edit question
Assignee:
No assignee Edit question
Last query:
2021-01-31
Last reply:
2021-04-14
Vlado (vskoric) said : #2

I just created snapshot of / called @, edited fstab to mount it and rebooted

btrfs subvolume snapshot / /@

# btrfs subvolume list /
ID 265 gen 559 top level 5 path @

/dev/disk/by-uuid/796d6ce3-2138-45e1-aca9-3335164e2804 / btrfs defaults,subvolid=265,subvol=@ 0 0

and it appears to be working as expected

# apt-btrfs-snapshot supported
Supported
# apt-btrfs-snapshot list
Available snapshots:
@apt-snapshot-2021-04-14_11:01:37

Vlado (vskoric) said : #3

If you are using swapfile on btrfs / you will not be able to create snapshot, just disable swapfile on BTRFS or move it somewhere

Vlado (vskoric) said : #4

My suggestion is not complete as I just tricked apt-btrfs-snapshot by putting subvol=@ in etc fstab but on boot kernel mounted default root

 you need to mount @ by using kernel boot option rootflags=subvol=@ by editing /etc/default/grub and running grub-update

steps:
1) edit fstab for example
/dev/sda / btrfs,default,subvol=@
2) edit /etc/default/grub (add rootflags=subvol=@ to GRUB_CMDLINE_LINUX_DEFAULT (example below) and run update-grub
GRUB_CMDLINE_LINUX_DEFAULT="maybe-ubiquity rootflags=subvol=@"
3) create snapshot of / called @
btrfs subvolume snapshot / /@

reboot

After reboot you should not see /@ on listing / directory ls -l /
# btrfs subvolume list /
ID 282 gen 2415 top level 5 path @

then just mount top level fs root somewhere so you can manually manipulate (move/rename) snapshots
btrfs subvolume set-default should not be used

https://wiki.ubuntu.com/Kernel/KernelBootParameters
https://help.ubuntu.com/community/btrfs#Ubuntu-specific_subvolume_layout_in_11.04_and_later
https://www.howtoforge.com/rollback-to-a-working-state-with-btrfs-plus-apt-btrfs-snapshot-on-ubuntu-12.10

I did not yet use apt-btrfs-snapshot set-default command, not sure what it does, maybe just mv chosen snapshot to @

Can you help with this problem?

Provide an answer of your own, or ask Danny for more information if necessary.

To post a message you must log in.