[Nix-dev] systemd in initrd

Luca Bruno lethalman88 at gmail.com
Thu Aug 21 15:39:10 CEST 2014


systemd is able to run in initrd, from the start to the end [1][2],
including the switch root:

My proposal is to use systemd to drive the initrd process for one reason
in particular: ordering of file system mounts. Two examples:
- My PR [3] about having nixos installed in a subdirectory, which
requires first mounting the device in a directory, then bind mounting to
the root /.
- Possibility of a tree of file system mounts for lvm and encrypted
devices. You know we currently use preLVM.

In other words, currently the mounted file systems in the initrd has no
specified order, apart hardcoded dependencies like in the case of preLVM.

The advantages of using systemd are:
- Sharing the same description of mounts and services both on the nixos
host and initrd
- Using the dependency resolution of systemd
- Describing how file systems have to be mounted as services, e.g. in
the case of crypt devices with custom commands, instead of relying on
specific code straight in the initrd.
- Better hooking system in the initrd (generalizes the point above).
Currently there are a couple of pre/post variables, while with systemd
services may be more flexible.

The disadvantage is that adding systemd to initrd is another level of
complexity, and ram usage at boot. Not only, probably after choosing to
use systemd, I guess we are not going to maintain the old way of
building the initrd. So it's either systemd, or not.

About encrypted devices, systemd is able to ask the password through its
agents [4].

Arch linux has is able to use systemd inside initrd [5]. They currently
have their own way to build the initrd, so they are not replacing the
whole process with systemd (not yet), rather replace some of the basic
hooks with systemd.
In our case, we would be able to replace the whole initrd process with
systemd while keeping, at least initially, the same nixos interface.

I hope in an active discussion about this issue, and in a possible
resolution.

Best regards,

[1] http://www.freedesktop.org/software/systemd/man/bootup.html
[2] http://www.freedesktop.org/wiki/Software/systemd/InitrdInterface/
[3] https://github.com/NixOS/nixpkgs/pull/3143
[4]
http://www.freedesktop.org/software/systemd/man/systemd-cryptsetup@.service.html
[5] https://wiki.archlinux.org/index.php/mkinitcpio#HOOKS


More information about the nix-dev mailing list