Originally posted by oshunluvr
View Post
Ubuntu-specific subvolume layout in 11.04 and later
In Ubuntu 11.04 and later, the installer sets up btrfs with a specific layout:
The default subvolume to mount is always the top of the btrfs tree (subvolid=5).
Subvolumes are created below the top of the btrfs tree as needed, e.g. for / and /home, it creates subvolumes named @ and @home. This means that specific options are needed in order to mount the subvolumes, instead of the default btrfs tree top:
- [*=left]The @ subvolume is mounted to / using the kernel boot option rootflags=subvol=@
[*=left]The @home subvolume (if it is used), is mounted via the mount option subvol=@home in fstab.
How to work with snaphots in Ubuntu's layout
In order to work with snapshots of / or /home in the Ubuntu layout it is very convenient to mount the btrfs filesystem at a separate location, and work from the top of the btrfs tree, rather than from the mounted subvolumes.
sudo mount /dev/sdX# /mntCreate snapshots
To create a snapshot use
sudo btrfs subvolume snapshot /mnt/@ /mnt/@_snapshotthis will create a snapshot of the @ subvolume named @_snapshot located also in the top of the btrfs tree.
Rollback to a snapshot
To roll back to a snapshot, you simply need to change its name to the name that ubuntu mounts, using
sudo mv /mnt/@ /mnt/@_badroot
sudo mv /mnt/@_snapshot /mnt/@and reboot.
Delete a snapshot
To delete a snapshot use
sudo btrfs subvolume delete /mnt/@_badrootbtrfs snapshots are subvolumes in themselves, and self-contained, deleting the old @ subvolume like this is fine, provided we have a replacement.
The btrfs-tools command ''set-default'' will break Ubuntu's layout
Since Ubuntu is set up to always keep the top of the btrfs tree as the default mounting subvolume it will break when using the btrfs-tools command set-default, since this command is specifically designed to change the default mounting subvolume.
The mount options for / and /home described above relies on the fact that the corresponding subvolumes @ and @home can be located below the default mounting subvolume, and if set-defaultis used, this is no longer the case.
If you have accidentally used set-default and want to revert, you can do the following
sudo mount /dev/sdX# /mnt
sudo btrfs subvolume set-default 5 /mnt
since the id 5 is a permanent alias for the top of the btrfs tree.
Using the idea above, a Debian installation is modified using techniques in this link.
Comment