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 /
.
lsblk:
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}'
/dev/vda2
and:
# findmnt
TARGET SOURCE FSTYPE OPTIONS
/ /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?
You can move your
/
to a subvolume this way:Create a shapshot of your filesystem.
Mount the new subvolume to
/mnt
.Chroot to the subvolume and update grub.
Update
/mnt/etc/fstab
adding theresubvol=@
as an option.Reboot. You will boot to the subvolume. Make sure that it is the case by
It should show something like
/@
.Here is a solution which works on Ubuntu Server 20.04. It creates
@
subvolume before the first boot and removes all files from/
volume.Do the installation of Ubuntu 20.04 with BTRFS root partition, but don't reboot after the system installation.
Switch to terminal (Alt+F2).
Switch to root user and umount all devices other than the BTRFS partition:
If you have other mount points (i.e.
/home
) umount them too.Create
@
subvolume and move all files into it: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)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
)If you've created some other partitions (i.e.
/home
) mount them here tooOpen
fstab
in editor:and update the line with BTRFS partition, i.e.:
Finally, setup the bootloader (I assume
/dev/sda
)Get back to your installer (Alt+F1) and reboot. Ubuntu should boot to your
@
subvolume.