I just installed Ubuntu 18.04 server on a VPS using the Ubuntu installer (from a mounted ISO image). I selected BTRFS as my filesystem type during the manual partitioning phase of installation.

Now that the installation has completed, I do not see @ or @home like I normally would on the non-server install. I don't care about a @home subvolume here, but I do not want the top level volume mounted at /.


vda    252:0    0   25G  0 disk
|-vda1 252:1    0    1M  0 part
|-vda2 252:2    0   20G  0 part /
`-vda3 252:3    0    5G  0 part [SWAP]

The produces no results:

btrfs su li /

I tried this next:

btrfs filesystem show | awk '/ path /{print $NF}'


# findmnt
/         /dev/vda2  btrfs      rw,relatime,space_cache,subvolid=5,subvol=/

How can I create BTRFS subvolumes during installation of 18.04 server?

I would like to create @ (for /) and @varlog (for /var/log) and maybe others.

I would like to use Snapper for hourly snapshots. Is there a recommended way to set up Ubuntu server with BTRFS and Snapper?

  • Why would you need it during installation? You can create subvolumes now as you wish.
    – Pilot6
    Jan 22, 2020 at 10:14
  • The installer puts the root file system in the top level BTRFS volume. That's bad practice IMO. It's not the way I want to set up my server's file system. The root fs should be in a subvolume. That can't be fixed now. I have to reinstall and do it the right way. Ubuntu doesn't seem to understand BTRFS, or I don't understand Ubuntu's way of working with BTRFS...
    – MountainX
    Jan 22, 2020 at 17:20
  • It is not a "bad practice" and it can be easily fixed now. You can create a subvolume now and place / there with no problems. Only grub and fstab should be updated. You can snap your top subvol to @. It' the easiest way.
    – Pilot6
    Jan 22, 2020 at 17:24
  • @Pilot6 - thank you. I look forward to knowing how to do it.
    – MountainX
    Jan 22, 2020 at 17:28
  • Thank you. The VPS does use grub. This should work. I will try now and accept your answer when I finish. Doesn't look hard. Thank you.
    – MountainX
    Jan 22, 2020 at 19:19

2 Answers 2


You can move your / to a subvolume this way:

  1. Create a shapshot of your filesystem.

     btrfs sub snap / /@
  2. Mount the new subvolume to /mnt.

     mount -o subvol=@ /dev/vda2 /mnt
  3. Chroot to the subvolume and update grub.

     cd /mnt
     mount -o bind /dev  dev
     mount -o bind /sys  sys
     mount -o bind /proc proc
     chroot /mnt
  4. Update /mnt/etc/fstab adding there subvol=@ as an option.

  5. Reboot. You will boot to the subvolume. Make sure that it is the case by

     mount | grep vda2

It should show something like

   /dev/vda2 on / type btrfs (rw,relatime,space_cache,subvolid=257,subvol=/@) 
  1. Now you can mount the top subvolume somewhere and delete its contents except /@.
  • Thanks for the detailed steps. It worked without any issues on a Vultr VPS.
    – MountainX
    Jan 22, 2020 at 19:37
  • 1
    BTRFS is great. It should receive a lot more appreciation than it does. I use it everywhere. I have not used Ubuntu in a long time, but coming back to Ubuntu I had to make sure I had BTRFS set up the way I like it. Can't be without it. :-)
    – MountainX
    Jan 22, 2020 at 19:47
  • Looks like you need to remove mount -o bind /boot boot step again. When mounted, it created inappropriate symlnks and after I removed the original root fs, the VPS booted into grub rescue.
    – MountainX
    Jan 22, 2020 at 19:50
  • That's what I was afraid of. grub placed data to the original /boot instead of the /@/boot
    – Pilot6
    Jan 22, 2020 at 19:51
  • 1
    in step 4. it shoud read: /mnt/etc/fstab because you already mounted the subvolume @ to /mnt. Inside /mnt there cannot be the folder @. @ is in / Dec 8, 2021 at 20:25

Here is a solution which works on Ubuntu Server 20.04. It creates @ subvolume before the first boot and removes all files from / volume.

  1. Do the installation of Ubuntu 20.04 with BTRFS root partition, but don't reboot after the system installation.

  2. Switch to terminal (Alt+F2).

  3. Switch to root user and umount all devices other than the BTRFS partition:

    sudo -i
    umount /target/boot/efi
    umount -l /target/run
    umount /target/cdrom

    If you have other mount points (i.e. /home) umount them too.

  4. Create @ subvolume and move all files into it:

    cd /target
    btrfs subvolume create @
    ls | grep -v @ | xargs mv -t @
  5. umount your BTRFS partition and mount it again pointing this time to the @ subvolume. It is also a good time to define some extra mounting options (in my example there are some recommended options for SSD devices). I assume BTRFS volume is under /dev/sda2 (adjust accrdingly)

    cd /
    umount /target
    mount -o subvol=@,ssd,noatime,space_cache,commit=120,compress=zstd:2 /dev/sda2 /target 
  6. Now it's time to complete the system by mounting all necessary devices and then switch to it with chroot (I assume your boot partition is /dev/sda1)

    mount /dev/sda1 /target/boot/efi
    mount --bind /proc /target/proc
    mount --bind /dev /target/dev
    mount --bind /sys /target/sys
    chroot /target

    If you've created some other partitions (i.e. /home) mount them here too

  7. Open fstab in editor:

    vi /etc/fstab

    and update the line with BTRFS partition, i.e.:

    UUID=xxx / btrfs default,subvol=@,ssd,noatime,space_cache,commit=120,compress=zstd:2  0 0
  8. Finally, setup the bootloader (I assume /dev/sda)

    update-initramfs -u -k all
    grub-install --recheck /dev/sda
  9. Get back to your installer (Alt+F1) and reboot. Ubuntu should boot to your @ subvolume.

  • Thank you. Those steps look good. I will try them on my next install. If they work better than the other answer, I'll accept your answer instead.
    – MountainX
    May 15, 2020 at 4:25
  • Shouldn't Step 5 re-mount the subvolume at /target instead of /mnt? (i.e. mount -o subvol=@,ssd,noatime,space_cache,commit=120,compress=zstd:2 /dev/sda2 /target)
    – Tobias J
    Dec 21, 2020 at 22:03

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.