The installer will add subvolumes to fstab for any subvolumes used in the installation; either created by the installer or by the user or subvolumes reused by the user (e.g. reusing the home subvolume for an otherwise clean installation with a new root subvolume).
var/lib/machines
was created by systemd, not the installer, and it is a so-called “nested” subvolume as are all the other subvolumes you created. Nesting happens anytime the subvolume is not located in top level ID 5.
https://btrfs.wiki.kernel.org/index.php/SysadminGuide#Layout
Depends on what you’re trying to achieve. Nested subvolumes don’t need to be added to fstab. But they also aren’t included when making snapshots of their parent (snapshots end at subvolume boundaries). And rollback is complicated because if you rollback to a snapshot, it won’t automatically contain all of these subvolumes you’ve created. Generally speaking, it’s advised to create subvolumes in the top level of the file system (ID 5) and use fstab to mount them into their proper location. If you created this layout in the installer’s Custom or Advanced Custom UI, it would use this so called “flat” layout. This is really an organizational preference, Btrfs itself doesn’t care and establishes no rules.
Btrfs doesn’t care what they’re named because behind the scenes it’s interacting with subvolumes based on the ID anyway. So you can name them whatever you want, just like a directory. Either referencing them by ID or name, it’s unambiguous
subvolid=257 is the same as subvol=root
subvolid=372 is the same as subvol=root/root
It might be more obvious using btrfs sub list -t /
Because /
means subvolid=257 subvol=root and the home subvolume isn’t nested inside root like all the other subvolumes. The -o option only shows subvolumes that are below the path you specify.
Depends on what you’re trying to achieve. I personally only create subvolumes in the top-level of the file system, i.e. at mkfs time, a hidden subvolume without a name with ID 5 is created and referred to as either “top level of the file system” or also “fs tree”. If you mount this btrfs normally, it mounts this subvolume. That’s why you will see what appears to be two directories named home and root in it, but those are subvolumes. You can ls -li
to see their inode numbers are 256, which is reserved for subvolumes.
Some utilities like snapper make use of the default subvolume via btrfs subvolume set-default
command which can change what subvolume is mounted when -o subvol/subvolid
options are not used. In this case the way to mount the top level of the subvolume is either:
mount -o subvolid=5 /dev/ /mnt
mount -o subvol=/ /dev/ /mnt
There is also an ID 0 aliased to ID 5. So you can use subvolid=0 if that’s easier to remember (that’s the point of the alias, because remembering ID 5 is a bit esoteric.)