Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow btrfs subvolumes without mountpoint #1331

Open
achilleas-k opened this issue Mar 17, 2025 · 0 comments
Open

Allow btrfs subvolumes without mountpoint #1331

achilleas-k opened this issue Mar 17, 2025 · 0 comments

Comments

@achilleas-k
Copy link
Member

achilleas-k commented Mar 17, 2025

Btrfs subvolumes don't need to be mounted. They are always accessible at the location where they are created. This is quite common for nested subvolumes (beyond the top-level ones). For example, consider the following subvolume layout, as it may appear on the btrfs volume itself:

/
|- +subvolumes
   |- root
   |- var
   |  |- log
   |- home

In this case, the following mountpoints would be specified in /etc/fstab (or the mount units) for our images:

UUID=<btrfs volume uuid>    /                     btrfs     ...,subvol=/+subvolumes/root     0 0
UUID=<btrfs volume uuid>    /var                  btrfs     ...,subvol=/+subvolumes/var      0 0
UUID=<btrfs volume uuid>    /var/log              btrfs     ...,subvol=/+subvolumes/var/log  0 0
UUID=<btrfs volume uuid>    /home                 btrfs     ...,subvol=/+subvolumes/home     0 0

The third line for /var/log is unnecessary [1].

Making the mountpoint an optional property also allows users to simplify their mount structure by creating only a single subvolume with a mountpoint and then structuring their subvolumes under that:

/
|- +subvolumes
   |- root
      |- var
      |  |- log
      |- home

requiring only

UUID=<btrfs volume uuid>    /                     btrfs     ...,subvol=/+subvolumes/root     0 0

(or no fstab at all).

[1] Mount options might be a reason to have a subvolume mounted at its original path, however this doesn't work for most options currently:

Most mount options apply to the whole filesystem and only options in the first mounted subvolume will take effect. This is due to lack of implementation and may change in the future. This means that (for example) you can’t set per-subvolume nodatacow, nodatasum, or compress using mount options. This should eventually be fixed, but it has proved to be difficult to implement correctly within the Linux VFS framework.

https://btrfs.readthedocs.io/en/latest/btrfs-man5.html#btrfs-specific-mount-options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant