Score:3

Ubuntu 22.04 server installer does not create btrfs subvolumes?

by flag

I installed Ubuntu 22.04 LTS server today and selected BTRFS as for the / partition. Here is the scheme I selected in the custom installation:

/boot     2G ext4
/boot/efi 1G fat32
SWAP      4G
/         469.9G btrfs

From searching around, I saw that ubuntu used to create two separate subvolumes under @ and @home, but I don't see them when I check:

# lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0         7:0    0    62M  1 loop /snap/core20/1587
loop1         7:1    0  79.9M  1 loop /snap/lxd/22923
loop2         7:2    0    47M  1 loop /snap/snapd/16292
nvme0n1     259:0    0 476.9G  0 disk 
├─nvme0n1p1 259:1    0     1G  0 part /boot/efi
├─nvme0n1p2 259:2    0     2G  0 part /boot
├─nvme0n1p3 259:3    0     4G  0 part [SWAP]
└─nvme0n1p4 259:4    0 469.9G  0 part /
# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/disk/by-uuid/8b2ff495-b8b2-4959-a5a4-1f4aa7e85ffe none swap sw 0 0
# / was on /dev/nvme0n1p4 during curtin installation
/dev/disk/by-uuid/4466d07c-a9a8-452b-a970-667f55eff17a / btrfs defaults 0 1
# /boot was on /dev/nvme0n1p2 during curtin installation
/dev/disk/by-uuid/d15e9776-60c0-4e5f-b782-087126cfde2f /boot ext4 defaults 0 1
# /boot/efi was on /dev/nvme0n1p1 during curtin installation
/dev/disk/by-uuid/E1C9-D08B /boot/efi vfat defaults 0 1
/swap.img       none    swap    sw      0       0
# mount | grep nvme0n1p4
/dev/nvme0n1p4 on / type btrfs (rw,relatime,ssd,space_cache=v2,subvolid=5,subvol=/)

Did I miss something during installation?

I don't think this is a duplicate considering Ubuntu switched to the subquity installer recently, and the installation flow seemed to have changed from when the previous questions on this topic were answered.

Score:2
cn flag

It is a standard setup for a btrfs file system with @ and @home subvolumes.

@ is mounted to / and @home is mounted to /home.

It looks like subuiquity doesn't do it. You can fix it. Boot from a LiveUSB and run from there:

sudo mount /dev/nvme0n1p4 /mnt

Run sudo nano /mnt/etc/fstab, remove this line

 /dev/disk/by-uuid/4466d07c-a9a8-452b-a970-667f55eff17a / btrfs defaults 0 1

and add these lines:

/dev/disk/by-uuid/4466d07c-a9a8-452b-a970-667f55eff17a / btrfs subvol=@ 0 0
/dev/disk/by-uuid/4466d07c-a9a8-452b-a970-667f55eff17a /home btrfs subvol=@home 0 0

Then run:

sudo btrfs sub create /mnt/@
sudo btrfs sub create /mnt/@home
sudo mv /mnt/home/* /mnt/@home
cd /mnt
sudo mv !(@|swapfile) /mnt/@
sync
sudo umount /mnt
sudo mount -o subvol=@ /dev/nvme0n1p4 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys  /mnt/sys
sudo mount /dev/nvme0n1p2 /mnt/boot
sudo mount /dev/nvme0n1p1 /mnt/boot/efi
sudo chroot /mnt
sudo update-grub
exit
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys
sudo umount /mnt/boot
sudo umount /mnt

Reboot, and if I didn't make a mistake, all should work.

tcapwasraw avatar
by flag
Hi, I don't have either the @ or @home subvolumes. Please see the update for the contents of `/etc/fstab` and `mount | grep nvme0n1p4`.
Pilot6 avatar
cn flag
You can leave it as is, or create the subvolumes and fix `/etc/fstab` if you like. I can give directions.
tcapwasraw avatar
by flag
Yes, could you give instructions on how to do that?
Pilot6 avatar
cn flag
Hold on, I will update the answer. If you have important data, do a backup.
tcapwasraw avatar
by flag
I got "cannot move /mnt/@ to a subdirectory of itself /mnt/@/@" for the second mv command
Pilot6 avatar
cn flag
Oops. I will fix it.
Pilot6 avatar
cn flag
Check if `update-grub` doesn't give errors. You can continue from the place you stopped.
tcapwasraw avatar
by flag
The mount command returns: "mount: /media: can't find in /etc/fstab"
Pilot6 avatar
cn flag
A typo, no device. Sry.
tcapwasraw avatar
by flag
Looks like about half the installation folders are in /mnt and half under /mnt/@, should I just complete the mv manually?
Pilot6 avatar
cn flag
What do you mean by "installation folders"? If it is under `/home`, they will be moved. Some won't disappear from `/mnt` like `/sys`. Now it looks OK. If you continue, all should work well.
tcapwasraw avatar
by flag
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/139766/discussion-between-tcapwasraw-and-pilot6).
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.