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

nixos/stage-1.init.sh: Prevent unsafe remount and correct fstab syntax #358035

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Princemachiavelli
Copy link
Contributor

@Princemachiavelli Princemachiavelli commented Nov 22, 2024

Description

The legacy stage-1 generates the /etc/fstab from fsInfo but incorrectly adds a trailing , character to the mount options. While does not appear to have caused any issue yet we should trim the trailing , to be safe.

Generated /etc/fstab during stage-1:

tmpfs /mnt-root tmpfs mode=0755,

stage-1 also currently remounts all fileSystems as a fix for busybox not respecting mount options on bind (and rbind) mount points. This results in a unintended errors during stage-1 if a file system such as NFS is mounted which does allow remounting with all of the original options present (i.e some options can only be set during the initial mount).

Error during stage-1 mounting NFS share:

mount: mounting server.example.test:/nix/store on /mnt-root/nix/.ro-store failed: Invalid argument

Things done

Built and ran legacyPackages.x86_64-linux.nixosTests.early-mount-options.

  • Built on platform(s)
    • [] x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@github-actions 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 Nov 22, 2024
@Princemachiavelli Princemachiavelli marked this pull request as ready for review November 22, 2024 02:08
We should not remount all filesystem types since not all filesystems
are safe to remount and some (nfs) return errors if remounted with
certain mount options.
Copy link
Contributor

@ConnorBaker ConnorBaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I'd like a second set of eyes on it though before it's merged.

@ConnorBaker
Copy link
Contributor

@ElvishJerricco @tpwrules would either of you have a chance to take a look at this PR?

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Nov 23, 2024
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/` 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants