Creating btrfs subvolume like @ or @home

Sigh, seems I posted a bit too soon, with a bit of help of the almighty Zosma on IRC, we found out how this is supposed to work.

Subvolumes @ and @home are children of the btrfs root, so / is not actually the root of the file system. The UUID of the btrfs root is supplied in /etc/fstab twice, providing the mounts for / and /home. Mounting the actual root of the file system shows the subvolumes created by the installer:

root@box:~# mkdir /mnt/btrfs
root@box:~# mount UUID=f8963df3-1320-4bc0-a125-62be185b029e /mnt/btrfs
root@box:~# ls /mnt/btrfs
@  @home

So that's where they went! Creating a new subvolume in the exact way the ubuntu installer did is now easy:

root@box:~# btrfs subvolume create /mnt/btrfs/@data
Create subvolume '/mnt/btrfs/@data'

Now, as we've created a subvolume in the btrfs root instead of in the root filesystem for the install, /data/ won't show up by itself. Luckily, it's trivial to copy the trick used by the installer by examining /etc/fstab and add another mount for /data:

UUID=f8963df3-1320-4bc0-a125-62be185b029e /data  btrfs  defaults,subvol=@data 0 2

Last step is to create the mount point: mkdir /data. After a reboot, we'll have a /data directory mounted from a separate btrfs subvolume.

… Profit!


Installation works great as long as I remember to put /boot on a separate partition

You do not need to have a separate /boot. GRUB2 can read and boot Linux from a btrfs.

What I would like to do is create a separate subvolume for bulk data with different settings than things like @ and @home.

If you're talking about mounting subvolumes with different mount options, be aware that currently (Nov 2013) they are not supported: according to the Btrfs FAQ, "Can I mount subvolumes with different mount options?", currently only the btrfs-specific options are not supported or not implemented. However, the developers have plans to implement it in the future.

btrfs subvolume create data will do that for me, but I'm curious why it keeps naming it @/data (or similar things when I try /data or @data)

By default, Ubuntu's installer Ubiquity creates subvolumes @ and @home in the filesystem, and your Ubuntu root is actually in the subvolume @.

Is there a special way to create the subvolumes like @ and @home so my data subvolume will show up as @data? (and: what is the exact difference between the naming schemes?)

@ and @home are arbitrary names chosen by the installer, that have no meaning outside /etc/fstab. In fact, I typically rename them to more specific names, so that I can have many Ubiquity-installed distros on the same btrfs, as long as I remember to update their fstab's.

More subvolume explanation at Funtoo.org - BTRFS.