I'm attempting to setup an Ubuntu server with the following disks:

/dev/sda is a 2TB disk, which will host much of the OS. It is currently partitioned as follows:

  • /dev/sda1: EFI Boot partition (488.3GB), mounted as /boot/efi
  • /dev/sda2: LVM partition, added to mymachine_vg LVM volume group.

Volume group mymachine_vg contains just a single partition (/dev/sda2), with two logical volumes:

  • mymachine_swap: a 122.1GB swap partition (/dev/dm-0).
  • mymachine_root: a 1.4TB BTRFS partition (/dev/dm-1), mounted as /.

I also have two 8TB drives, /dev/sdb and /dev/sdc that I want to operate as a RAID1 array under BTRFS. I formatted these drives as follows (all commands listed as run as root, unless stated otherwise):

mkfs.btrfs -m raid1 -d raid1 /dev/sdb /dev/sdc

I've installed a base Ubuntu system, and only the /dev/sda disk's partitions, etc. are currently mounted.

If I run btrfs filesystem show, I get the following output:

$ btrfs filesystem show
Label: none  uuid: 357d0492-9802-48f4-9656-4011c32d9e62
        Total devices 1 FS bytes used 1.80GiB
        devid    1 size 1.22TiB used 4.04GiB path /dev/dm-1

Label: none  uuid: 0ed53e28-cdee-40e3-9316-69446f34e6af
        Total devices 2 FS bytes used 640.00KiB
        devid    1 size 7.28TiB used 2.03GiB path /dev/sdb
        devid    2 size 7.28TiB used 2.01GiB path /dev/sdc

 Btrfs v3.12

Ideally, what I'd like to achieve is to use the RAID1 array for the /opt & /srv directories; presumably as BTRFS subvolumes. All the other directories would belong to the root logical volume /dev/dm-1 device.

Is this possible? If so, what do I need to do in terms of BTRFS configuration, subvolumes, device adding, etc.?

It seems I can only create subvolumes in subdirectories of a mounted device. I'm also unsure of the consequences of adding the RAID1 array to the /dev/dm-1 device.

Thanks for any assistance you can provide. If you need further information, just ask!

(As further background, I'm replacing a 32-bit Ubuntu 14.03 server which cannot be upgraded to a more recent Ubuntu release because some of the software requires 64-bit operation. This system has to be setup, initially, as a 64-bit Ubuntu 14.03 server so that I can transfer data from the old server, then perform the necessary upgrades. As a result, I'm restricted to the Ubuntu 14.03 version of the btrfs-tools package. I'm taking the opportunity to switch over to BTRFS as an experimental aside.)

1 Answer 1


OK, I think I've figured this out, although it's a bit long-winded...

If anyone can simplify the following, please let me know!

All commands are entered as root, except where indicated otherwise.

Firstly, it's necessary to mount the RAID1 volume.

Note: When mounting this volume, either of the disks belonging to the array can be specified. That said, it's probably best to use the UUID of the array in /etc/fstab (we'll use the device here for simplicity).

# mkdir /mnt/raid1
# mount -t btrfs /dev/sdb /mnt/raid1

Next, we need to create the subvolumes for the directories & mount points that we're going to specify later, in this case for /opt and /srv:

# btrfs subvolume create /mnt/raid1/opt
# btrfs subvolume create /mnt/raid1/srv
# btrfs subvolume list /mnt/raid1 -a -p
ID 258 gen 12 parent 5 top level 5 path opt
ID 259 gen 13 parent 5 top level 5 path srv

Make a note of the ID numbers of each subvolume, as we'll need them later...

The next step is to unmount the RAID1 array:

# umount /mnt/raid1

Finally, it's necessary to edit /etc/fstab to mount the subvolumes we just created. (We do not need to mount the RAID1 root subvolume.) When doing this, use the UUID values (from btrfs filesystem show or blkid, which should show the same value for the RAID1 array) and the subvolume ID's (from the above btrfs subvolume list command):

# Original /etc/fstab contents, with the following appended:

# Mount opt subvolume of BTRFS RAID1 array as /opt
UUID=0ed53e28-cdee-40e3-9316-69446f34e6af       /opt    btrfs   defaults,subvolid=258   0       2
# Mount srv subvolume of BTRFS RAID1 array as /srv
UUID=0ed53e28-cdee-40e3-9316-69446f34e6af       /srv    btrfs   defaults,subvolid=259   0       2

Note that both mount points use the same UUID (that of the RAID1 array in BTRFS), with the subvolid mount option identifying the subvolume being mounted.

Just to be sure, check that the file contents work OK:

# mount -a

If no errors are reported, you're good.

One thing I definitely didn't want to do was to add the RAID1 array devices to the root logical volume. Doh!

I'll mark this as the accepted answer for now, but if you have a better suggestion, I'll certainly consider it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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