When doing a installation to a root btrfs filesystem, many Linux distributions install to the default subvolume. If left unmodified, this layout will force any new snapshots or subvolumes to be created inside the root filesystem, which is quite confusing, as the snapshots contain themselves:
/
│─dev
│─home
│─var
│─usr
│─...
└─snapshots
└─snap1
An easier to understand default subvolume layout would be:
/
├─subvolumes
│ └─root
│ ├─dev
│ ├─home
│ ├─var
│ ├─usr
│ └─...
└─snapshots
└─snap1
How can I change the distro-default btrfs installation to use this subvolume layout without booting from a livecd?
Best Answer
While not strictly necessary, you might want to do these steps in single user ("recovery") mode to avoid accidental data loss.
We'll create the layout we want in the default subvolume:
/subvolumes/root
will be our new root filesystem, so don't make any changes to the filesystem one after this step.Edit
/subvolumes/root/etc/fstab
to make the system use the new root subvolume as root filesystem. For that, you'll need to modify it to include thesubvol=/subvolumes/root
option.Now we need to mount our new root filesystem somewhere in order to fix grub to point to the new subvolume:
That's it. Reboot, and your root filesystem should be the new subvolume. If this succeeded, there shouldn't be any
/snapshots
directory.If you want, you may make a permanent mount point for the default subvolume:
then you can
mount -o subvolid=0 /dev/sdXX /media/btrfs/root
to mount the default subvolume.You can now safely delete the contents of the old root filesystem in the default subvolume.