nixos/systemd/initrd: follow init param symlinks#209964
nixos/systemd/initrd: follow init param symlinks#209964ElvishJerricco merged 1 commit intoNixOS:masterfrom
Conversation
088b65b to
eebf78c
Compare
eebf78c to
39f2146
Compare
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/2467 |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/2550 |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-ready-for-review/3032/2683 |
|
Wouldn't it be better to just chroot into |
Yes, I agree. I think I got stuck on what path to use for |
|
Well, the I guess it's technically possible that the coreutils in initrd has been overriden or something like such that it isn't part of the system generation's runtime dependencies, but that seems like it isn't worth working around. |
39f2146 to
58a3738
Compare
|
Updated to use chroot and re-tested. |
philiptaron
left a comment
There was a problem hiding this comment.
$ journalctl -b -u initrd-nixos-activation
Feb 21 08:16:34 localhost systemd[1]: initrd-nixos-activation.service: starting held back, waiting for: initrd-fs.target
Feb 21 08:16:37 localhost systemd[1]: initrd-nixos-activation.service: Reinstalled deserialized job initrd-nixos-activation.service/start as 33
Feb 21 08:16:37 localhost systemd[1]: initrd-nixos-activation.service: starting held back, waiting for: initrd-fs.target
Feb 21 08:16:37 localhost systemd[1]: initrd-nixos-activation.service: AssertPathExists=/etc/initrd-release succeeded.
Feb 21 08:16:37 localhost systemd[1]: initrd-nixos-activation.service: Will spawn child (service_enter_start): /nix/store/ck5cf7fg48r7jh1w8fxgri5kqs5gy1hn-unit-script-initrd-nixos-activation-start/bin/initrd-nixos-activation-start
Feb 21 08:16:37 localhost systemd[1]: initrd-nixos-activation.service: Passing 0 fds to service
Feb 21 08:16:37 localhost systemd[1]: initrd-nixos-activation.service: About to execute: /nix/store/ck5cf7fg48r7jh1w8fxgri5kqs5gy1hn-unit-script-initrd-nixos-activation-start/bin/initrd-nixos-activation-start
Feb 21 08:16:37 localhost systemd[1]: initrd-nixos-activation.service: Forked /nix/store/ck5cf7fg48r7jh1w8fxgri5kqs5gy1hn-unit-script-initrd-nixos-activation-start/bin/initrd-nixos-activation-start as 486
Feb 21 08:16:37 localhost systemd[1]: initrd-nixos-activation.service: Changed dead -> start
Feb 21 08:16:37 localhost systemd[1]: Starting NixOS Activation...
Feb 21 08:16:37 localhost (on-start)[486]: Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Feb 21 08:16:37 localhost (on-start)[486]: Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Feb 21 08:16:37 localhost initrd-nixos-activation-start[486]: booting system configuration /nix/store/vh11rbcx3w3innm2q2x2rsnydlynlg1p-nixos-system-zebul-24.05.20240218.58a3738
Feb 21 08:16:37 localhost initrd-nixos-activation-start[486]: running activation script...
Feb 21 08:16:38 localhost initrd-nixos-activation-start[517]: setting up /etc...
Feb 21 08:16:38 localhost systemd[1]: initrd-nixos-activation.service: Child 486 belongs to initrd-nixos-activation.service.
Feb 21 08:16:38 localhost systemd[1]: initrd-nixos-activation.service: Main process exited, code=exited, status=0/SUCCESS (success)
Feb 21 08:16:38 localhost systemd[1]: initrd-nixos-activation.service: Deactivated successfully.
Feb 21 08:16:38 localhost systemd[1]: initrd-nixos-activation.service: Service will not restart (restart setting)
Feb 21 08:16:38 localhost systemd[1]: initrd-nixos-activation.service: Changed start -> dead
Feb 21 08:16:38 localhost systemd[1]: initrd-nixos-activation.service: Job 33 initrd-nixos-activation.service/start finished, result=done
Feb 21 08:16:38 localhost systemd[1]: Finished NixOS Activation.
Feb 21 08:16:38 localhost systemd[1]: initrd-nixos-activation.service: Consumed 136ms CPU time.
Feb 21 08:16:38 localhost systemd[1]: initrd-nixos-activation.service: Releasing resources...
Feb 21 08:16:38 zebul systemd[1]: initrd-nixos-activation.service: Collecting.
|
|
|
Nevermind, the issue was something else. And now I've tested this change with extlinux. |
|
Is there anything that prevents this PR from being merged? |
|
@ofborg test systemd-initrd-simple |
|
Unrelated error, but otherwise successful.
|
Description of changes
Fixes an incompatibility between
boot.initrd.systemdandboot.loader.generationsDir. Fixes #219767.The
initrd-nixos-activationservice determines which system closure to activate by inspecting theinitkernel parameter. It assumes that theinitparameter is a full path to the system closure, such that takingdirnameand appending/prepare-rootwill point to the right script.However, some boot loaders pass an
initpath which includes symlinks. For example, on a system usingboot.loader.generationsDir,init=/boot/default/initwhere/boot/defaultis a symlink to a folder like/boot/system-38, which in turn containsinit, a symlink to theinitscript in the system closure in the Nix store. This setup breaks withboot.initrd.systemdbecause theinitrd-nixos-activationscript fails to find and activate the system.This change resolves symlinks in the
initparameter.It does this by repeatedly callingIt now usesreadlink -mbecause the filesystem is mounted at/sysroot, so absolute symlinks will terminate symlink resolution.chroot.Testing
Tested booting with these configurations:
init= absolute path)/boot#198728 (init= relative link -> absolute link -> absolute path)Things done
sandbox = trueset innix.conf? (See Nix manual)systemd-initrd-simplesystemd-initrd-btrfs-raidsystemd-initrd-networkdnix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes