Btrfs subvol created but does not need mounting?

I’m setting up a new server and wanted to use btrfs for the filesystem.

After anaconda completed I have this fstab:

UUID=5abde8a9-aba0-4f70-a877-3fcedd20905e /                       btrfs   subvol=root,compress=zstd:1 0 0
UUID=a2073a14-3aa8-4da7-bb78-399cf64324aa /boot                   xfs     defaults        0 0
UUID=C63A-112D          /boot/efi               vfat    umask=0077,shortname=winnt 0 2
UUID=5abde8a9-aba0-4f70-a877-3fcedd20905e /home                   btrfs   subvol=home,compress=zstd:1 0 0
UUID=5abde8a9-aba0-4f70-a877-3fcedd20905e /var                    btrfs   subvol=var,compress=zstd:1 0 0

Now I want to add a new subvolume for use by samba.
It seems that this is the command to use:

btrfs subvolume create /shared

And I see the new subvol:

$ btrfs subvolume list /
ID 256 gen 1104 top level 5 path var
ID 257 gen 1104 top level 5 path root
ID 258 gen 1104 top level 5 path home
ID 259 gen 1104 top level 256 path var/lib/portables
ID 261 gen 1100 top level 257 path shared

I add this line to fstab:

UUID=5abde8a9-aba0-4f70-a877-3fcedd20905e /shared                 btrfs   subvol=shared,compress=zstd:1 0 0

But I cannot mount subvol=shared as I’d expected to need to do:

$ mount /shared
mount: /shared: fsconfig system call failed: No such file or directory.
       dmesg(1) may have more information after failed mount system call.

Reading the btrfs docs at btrfs-subvolume(8) — BTRFS documentation is not making the situation clear.

Here is the state of the subvols:

$ btrfs subvolume list /
ID 256 gen 1113 top level 5 path var
ID 257 gen 1112 top level 5 path root
ID 258 gen 1104 top level 5 path home
ID 259 gen 1104 top level 256 path var/lib/portables
ID 261 gen 1100 top level 257 path shared

Why does root, var and home need to be mounted by shared does not?
What is the significance of the level? Its 5 for the ones that need mounting.

The top level number is 257, so you should try replacing “subvol=shared” with “subvol=root/shared”.

That makes sense.

However I would like to have a new top level subvol like var not a sub subvol. Do you know how make such a top level subvol?

When you created this subvolume, your subvol root was mounted at /. So when you created the new subvolume /shared, it was created inside the subvolume at / (i.e., root), with the name shared. While I get what you are trying to do, please note that all the subvolumes listed in your btrfs subvolume list command are not “top-level” subvolumes, even though it may look like that. The designation of top-level subvolume in BTRFS is used for the initial subvolume with ID 5, see the subvolume documentation.

To create another subvolume under the one with ID 5, you need to mount the ID 5 subvolume somewhere, and then create it at that mountpoint:

$ sudo mount -o subvolid=5 UUID=5abde8a9-aba0-4f70-a877-3fcedd20905e  /mnt
$ sudo btrfs subvolume create /mnt/shared
$ sudo btrfs subvolume list /mnt/

Mounting subvolume ID 5 is the default of a BTRFS volume. I just wanted to make it explicit in the mount call above, in case you or the installer had changed the default subvolume.