Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Being intrigued by btrfs I decided to toy around with it in a VM. Installation works great as long as I remember to put /boot on a separate partition and it all seems to work fine.

What I would like to do is create a separate subvolume for bulk data with different settings than things like @ and @home. 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). 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?)


Additional information:

  • ubuntu 12.04.2, running as a KVM guest on mint15 host;
  • kernel 3.8.0-27-generic from ubuntu-x-swat (raring backport);
  • btrfs using two devices, /dev/sda and /dev/sdb
  • /dev/sda and /dev/sdb are partitions on a disk not used by the host OS
share|improve this question

2 Answers 2

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.

share|improve this answer
    
Thanks for a thorough addition here; lots of useful information :) –  akaIDIOT Nov 3 '13 at 15:30
up vote 2 down vote accepted

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!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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