Skip to content

nixos/iscsi-root-initiator: support systemd stage 1 - #545932

Open
sochotnicky wants to merge 1 commit into
NixOS:masterfrom
sochotnicky:iscsi-root-systemd-stage1
Open

nixos/iscsi-root-initiator: support systemd stage 1#545932
sochotnicky wants to merge 1 commit into
NixOS:masterfrom
sochotnicky:iscsi-root-systemd-stage1

Conversation

@sochotnicky

@sochotnicky sochotnicky commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

The scripted initrd is no longer the default and is slated for removal in 26.11 (#287308),
but boot.iscsi-initiator asserted against systemd stage 1, leaving no supported
way to boot from iSCSI root.

Add a systemd stage 1 code path that runs iscsid and the target login as real
units ordered on the dependency graph (network-online.target -> iscsid ->
iscsi-login -> initrd-root-device.target -> sysroot.mount), rather than a
one-shot script in preLVMCommands. This also removes the race the scripted path
has between iSCSI login and DHCP, since networkd ordering is a real dependency
instead of an enumerate-at-an-instant loop.

Initrd networking itself is left to boot.initrd.network.enable and networkd,
configured from the ip= kernel parameter or the networking.* options, so the
module only owns the iSCSI session.

Worth noting - if dhcp is used both initrd and stage2 boot need to use the same mac to get same IP (or bad things happen ™️) i.e. dhcpV4Config.ClientIdentifier = "mac"; on given device makes sure they don't generate different client IDs. Not sure how to best communicate - we could add an assertion/warning.

The scripted path is unchanged and no module options were added, removed or
renamed. Add a nixos test covering the systemd stage 1 case: one node exports a
LUN, another installs onto it, and a third boots from it with a systemd initrd.

Note that there's already #263417 but it's been almost 3 years. Approach is similar, I didn't touch multipath since I have don't use it and it's harder for me to validate.

TODO:

  • Test in my homelab confirmed
  • Not sure how to communicate networkConfig.KeepConfiguration = "yes"; requirement in stage2 so things don't get disrupted?
  • Shall we wipe the scripted config completely? I think yes, but for now I kept it
  • Worth a release notes update I think (wait until previous is decided)

Assisted-by: Claude Opus 5 (High)

Things done

The scripted initrd is no longer the default and is slated for removal in
26.11, but boot.iscsi-initiator asserted against systemd stage 1, leaving
no supported way to boot from iSCSI root.

Add a systemd stage 1 code path that runs iscsid and the target login as
real units ordered on the dependency graph (network-online.target ->
iscsid -> iscsi-login -> initrd-root-device.target -> sysroot.mount),
rather than a one-shot script in preLVMCommands. This also removes the
race the scripted path has between iSCSI login and DHCP, since networkd
ordering is a real dependency instead of an enumerate-at-an-instant loop.

Initrd networking itself is left to boot.initrd.network.enable and
networkd, configured from the `ip=` kernel parameter or the networking.*
options, so the module only owns the iSCSI session. Bridged setups can be
expressed with the normal networkd options outside this module.

The scripted path is unchanged and no module options were added, removed
or renamed. Add a nixos test covering the systemd stage 1 case: one node
exports a LUN, another installs onto it, and a third boots from it with a
systemd initrd.

Assisted-by: Claude Opus 5 (High)
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. llm-assisted Contributions that include code generation with LLMs 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: documentation This PR adds or changes documentation labels Jul 26, 2026
@sochotnicky
sochotnicky requested review from dasJ and helsinki-Jo July 26, 2026 19:17
@sochotnicky
sochotnicky marked this pull request as ready for review July 26, 2026 21:54
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: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. llm-assisted Contributions that include code generation with LLMs

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant