Skip to content

Btrfs mountoptions guardrails#1221

Open
sedlund wants to merge 3 commits intonix-community:masterfrom
sedlund:btrfs-mountoptions-guardrails
Open

Btrfs mountoptions guardrails#1221
sedlund wants to merge 3 commits intonix-community:masterfrom
sedlund:btrfs-mountoptions-guardrails

Conversation

@sedlund
Copy link
Copy Markdown
Contributor

@sedlund sedlund commented Mar 2, 2026

⚠️ Breaking Change

This introduces strict validation of Btrfs subvolume mount option consistency by default.
Configurations that previously relied on divergent filesystem-wide mount options may now fail evaluation.


Problem

Btrfs mount options are largely filesystem-wide, but disko allows per-subvolume mountOptions to diverge.
When they do, the effective behavior depends on mount ordering, which is not explicit and can lead to non-deterministic results.

Approach

Introduce a deterministic, Btrfs-specific guardrail:

  • Compare filesystem-wide option sets across all mounted subvolumes.

  • Allow only a conservative whitelist of clearly per-mount VFS flags to differ:

    • ro / rw
    • nosuid / suid
    • nodev / dev
    • noexec / exec
    • atime variants (noatime, relatime, strictatime, lazytime, etc.)
  • Ignore defaults, subvol=..., and userspace helper options (e.g. X-mount.mkdir).

  • Treat subvolumes using the default subvolume mountOptions = [ "defaults" ] as inheriting the top-level Btrfs mount options for the consistency check.

  • Compare option sets order-insensitively and by option key/value for filesystem-wide options.

Policy / Options

Two new Btrfs module options:

  • enforceConsistentMountOptions (default: true)
    Throw an evaluation error if non-whitelisted inconsistencies are detected.

  • warnOnInconsistentMountOptions (default: true)
    When strict mode is disabled, emit a warning unless this is set to false.

Why Btrfs-specific?

This behavior is specific to Btrfs subvolume multi-mount semantics, where many mount options are effectively filesystem-wide. Other filesystems do not exhibit the same ambiguity in disko’s model.

Tests

Added coverage for both allowed and rejected Btrfs subvolume mount option divergence.

  • btrfs-mountoptions-per-mount-allowed

    • Verifies that whitelisted per-mount VFS flags may differ across mounted subvolumes under strict mode.
    • Covers noexec, nosuid, nodev, and noatime.
    • Verifies that all configured subvolumes mount successfully.
    • Verifies that each subvolume mount contains its expected option.
    • Verifies that these per-mount options do not propagate to the root mount.
  • btrfs-mountoptions-consistency-guardrail

    • Verifies that conflicting non-whitelisted filesystem-wide options across mounted subvolumes are rejected during evaluation.
    • Uses a conflicting compress= configuration to confirm the guardrail throws under the default strict mode.

The implementation also treats subvolumes using the default subvolume mountOptions = [ "defaults" ] as inheriting the top-level Btrfs mount options for the consistency check, and ignores defaults, subvol=..., and X-mount.mkdir when comparing filesystem-wide option sets.


Fixes #331

@sedlund sedlund force-pushed the btrfs-mountoptions-guardrails branch from 81701fd to c06e927 Compare March 2, 2026 08:33
@sedlund sedlund marked this pull request as ready for review March 2, 2026 08:43
@sedlund sedlund force-pushed the btrfs-mountoptions-guardrails branch 3 times, most recently from ba54e7a to 7ef2289 Compare March 2, 2026 14:53
@sedlund sedlund force-pushed the btrfs-mountoptions-guardrails branch 2 times, most recently from 89d1754 to 330b3b8 Compare March 14, 2026 02:58
sedlund added 3 commits March 14, 2026 11:00
Add strict-by-default consistency guardrails for filesystem-wide Btrfs mountOptions with a conservative per-mount whitelist.

Use top-level btrfs mountOptions as canonical and treat subvolume filesystem-wide options as key/value overrides so omitted keys are inherited.
@sedlund sedlund force-pushed the btrfs-mountoptions-guardrails branch from 330b3b8 to da7dccd Compare March 14, 2026 03:00
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

Successfully merging this pull request may close these issues.

btrfs example and enabling compression failing

1 participant