-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
stage-2-init: fix false positives for RO Nix store mounts #375257
Merged
Merged
+76
−1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
6.topic: nixos
Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS
8.has: module (update)
This PR changes an existing module in `nixos/`
labels
Jan 20, 2025
numinit
force-pushed
the
stage2/fix-store-remount
branch
from
January 20, 2025 07:07
0098d16
to
dd92244
Compare
numinit
force-pushed
the
stage2/fix-store-remount
branch
2 times, most recently
from
January 20, 2025 07:39
12347d3
to
734b798
Compare
- Test RO store mount even given the presence of filesystems with options ending in "ro" - Test postBootCommands in stage2
numinit
force-pushed
the
stage2/fix-store-remount
branch
from
January 20, 2025 07:53
734b798
to
381e1f8
Compare
Mic92
reviewed
Jan 20, 2025
We need to take the "top" mount instead of any mount, which is the last line printed by findmnt. Additionally, make the regex more strict, so we don't select mount options ending in ro (like `errors=remount-ro` from ext4, or overlay paths ending in 'ro') and accidentally leave the Nix store RW after boot.
numinit
force-pushed
the
stage2/fix-store-remount
branch
from
January 20, 2025 08:27
381e1f8
to
2f3a80c
Compare
One edgecase I considered is that if the store is under a readonly mount (as opposed to one itself) we will still perform the RO bind mount, but I'm not sure this is actually worth changing. |
r-vdp
approved these changes
Jan 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff LGTM
wegank
added
the
12.approvals: 1
This PR was reviewed and approved by one reputable person
label
Feb 1, 2025
Working on several boxes in prod already that had this problem :-) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
6.topic: nixos
Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS
8.has: module (update)
This PR changes an existing module in `nixos/`
8.has: tests
This PR has tests
10.rebuild-darwin: 1-10
10.rebuild-linux: 1-10
12.approvals: 1
This PR was reviewed and approved by one reputable person
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Mounting an ext4 Nix store with the option
errors=remount-ro
results in the store not being remounted as RO after stage2 runs. In fact, many mount options involving "ro" at the end of the option are susceptible to this.We need to take the "top" mount instead of any mount, which is the last line printed by findmnt. Additionally, make the regex more strict, so we don't select mount options ending in ro (like
errors=remount-ro
fromext4, or overlay paths ending in 'ro') and accidentally leave the Nix store RW after boot.
The tests for this look a little tortured, because of how the tests overlay mount the Nix store. It is much easier to hit this on real hardware, with a single mountpoint (though, incidentally, I first hit this with an overlay).
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.