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/bcache: install udev rules outside initrd too [version 3] #26354

Merged
merged 3 commits into from Jun 10, 2017

Conversation

bjornfor
Copy link
Contributor

@bjornfor bjornfor commented Jun 3, 2017

Motivation for this change

This is an alternative version of #26344, with what I consider better stage-1.nix changes.

Should fix #26281 ("Bcache udev rules not installed outside initrd").

(Apparently I cannot verify that these rules are working by generating symlinks to bcache devices in /dev/disk/by-*, because on my system I run LVM on top of bcache.)

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@bjornfor, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @wkennington and @abbradar to be potential reviewers.

@abbradar
Copy link
Member

abbradar commented Jun 3, 2017

Thanks again! I cannot verify that it works locally because I moved to SSD-only without cache since then. @dfoxfranke, can you test this branch? I can spin up a VM later if needed.

So that

 $ nix-build -A bcache-tools.src

gives

 /nix/store/HASH-bcache-tools-1.0.7.tar.gz

instead of

 /nix/store/HASH-v1.0.7.tar.gz
Or else `services.udev.packages = [ bcache-tools ]` cannot be used.

To not break bcache in the initrd I'm modifying this in stage-1.nix:

  -  --replace /bin/sh ${extraUtils}/bin/sh
  +  --replace ${bash}/bin/sh ${extraUtils}/bin/sh

Reasoning behind that change:

* If not modifying the /bin/sh pattern in any way, it will also match
  ${bash}/bin/sh, creating a broken path like
  /nix/store/HASH-bash/nix/store/HASH-bash/bin/sh in the udev rule file.

* The addition of /bin/sh was done in 775f381
  ("stage-1: add bcache support"). It seems somewhat plausible that
  no new users have appeared since then and we can take this opportunity
  to back out of this change without much fear of regressions.

  If there _are_ regressions, they should be in the form of build time
  errors, not runtime (boot), due to how the udev rule output is checked
  for invalid path references. So low risk, IMHO.

* An alternative approach could be to copy the /bin/sh substitute rule
  over to the non-initrd udev rules implementation in NixOS, but I think
  this way is better:
  - The rules file comes with a working path out of the box.
  - We can use more precise pattern matching when modifying the udev
    rules for the initrd.
Adds /dev/disk/by-{id,label}/* symlinks for bcache device nodes, in the
final rootfs.

Symlinks will only be created for bcache devices that contain
filesystems. So if you have a blank bcache device or run LVM on top of
bcache you will not get this kind of symlink.
@bjornfor bjornfor merged commit 5b48368 into NixOS:master Jun 10, 2017
@bjornfor
Copy link
Contributor Author

I applied it to master. (I have tested that it doesn't break my bcache + LVM setup.)

@bjornfor bjornfor deleted the bcache-udev-rules-v3 branch June 10, 2017 16:09
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.

Bcache udev rules not installed outside initrd
3 participants