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:


An easier to understand default subvolume layout would be:

│ └─root
│   ├─dev
│   ├─home
│   ├─var
│   ├─usr
│   └─...

How can I change the distro-default btrfs installation to use this subvolume layout without booting from a livecd?


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:

mkdir /subvolumes
btrfs subvolume snapshot / /subvolumes/root
mkdir /snapshots

/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 the subvol=/subvolumes/root option.

Now we need to mount our new root filesystem somewhere in order to fix grub to point to the new subvolume:

mkdir /media/temporary
mount -o subvol=/subvolumes/root /dev/sdXX /media/temporary
cd /media/temporary
mount -o bind /dev  dev
mount -o bind /sys  sys
mount -o bind /proc proc
mount -o bind /boot boot # only necessary if you have a separate boot partition
chroot .

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:

mkdir /media/btrfs/root

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.

cd /media/btrfs/root
rm -rf {dev,home,var,...}
  • 1
    Also, note that instead of mounting, chrooting and updating grub, you can simply set the default subvolume to be rootfs with btrfs subvolume set-default ID /. ID can be found using `btrfs subvolume list / – goncalopp Nov 2 '13 at 23:52
  • I added subvol=/rootfs (note the /) to fstab as that seems to be the 'proper' way as described in the (btrfs wiki)[btrfs.wiki.kernel.org/index.php/Mount_options]. – go2null Sep 2 '17 at 2:47
  • @go2null The problem of using subvol=/rootfs is that any program that is not aware of your layout (distro installers, for example) will mount the default subvolume instead. If the program expects the filesystem to look like a linux filesystem, if will fail, or worse - fill your default subvolume with things you don't want there – goncalopp Sep 21 '17 at 23:26
  • 1
    hmm, would have thought that progs that mess around with filesystems would at least check fstab or bootloader config. – go2null Oct 26 '17 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.