mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-02 03:43:06 +00:00
24bf6e9cb8
Before this change, the hash of the etc metadata image was included in the mount unit that's responsible for mounting this metadata image in the initrd. And because this metadata image changes with every change to the etc contents, the initrd would be rebuild every time as well. This can lead to a lot of rebuilds (especially when revision info is included in /etc/os-release) and all these initrd archives use up a lot of space on the ESP. With this change, we instead include a symlink to the metadata image in the top-level directory, in the same way as we already do for things like init and prepare-root, and we deduce the store path from the init= kernel parameter, in the same way as we already do to find the path to init and prepare-root. Doing so avoids rebuilding the initrd all the time.
51 lines
1.9 KiB
Nix
51 lines
1.9 KiB
Nix
import ./make-test-python.nix ({ lib, pkgs, ... }: {
|
|
name = "systemd-initrd-simple";
|
|
|
|
nodes.machine = { pkgs, ... }: {
|
|
testing.initrdBackdoor = true;
|
|
boot.initrd.systemd.enable = true;
|
|
virtualisation.fileSystems."/".autoResize = true;
|
|
};
|
|
|
|
testScript = ''
|
|
import subprocess
|
|
|
|
with subtest("testing initrd backdoor"):
|
|
machine.wait_for_unit("initrd.target")
|
|
machine.succeed("systemctl status initrd-fs.target")
|
|
machine.switch_root()
|
|
|
|
with subtest("handover to stage-2 systemd works"):
|
|
machine.wait_for_unit("multi-user.target")
|
|
machine.succeed("systemd-analyze | grep -q '(initrd)'") # direct handover
|
|
machine.succeed("touch /testfile") # / is writable
|
|
machine.fail("touch /nix/store/testfile") # /nix/store is not writable
|
|
# Special filesystems are mounted by systemd
|
|
machine.succeed("[ -e /run/booted-system ]") # /run
|
|
machine.succeed("[ -e /sys/class ]") # /sys
|
|
machine.succeed("[ -e /dev/null ]") # /dev
|
|
machine.succeed("[ -e /proc/1 ]") # /proc
|
|
# stage-2-init mounted more special filesystems
|
|
machine.succeed("[ -e /dev/shm ]") # /dev/shm
|
|
machine.succeed("[ -e /dev/pts/ptmx ]") # /dev/pts
|
|
machine.succeed("[ -e /run/keys ]") # /run/keys
|
|
# /nixos-closure didn't leak into stage-2
|
|
machine.succeed("[ ! -e /nixos-closure ]")
|
|
|
|
with subtest("groups work"):
|
|
machine.fail("journalctl -b 0 | grep 'systemd-udevd.*Unknown group.*ignoring'")
|
|
|
|
with subtest("growfs works"):
|
|
oldAvail = machine.succeed("df --output=avail / | sed 1d")
|
|
machine.shutdown()
|
|
|
|
subprocess.check_call(["qemu-img", "resize", "vm-state-machine/machine.qcow2", "+1G"])
|
|
|
|
machine.start()
|
|
machine.switch_root()
|
|
newAvail = machine.succeed("df --output=avail / | sed 1d")
|
|
|
|
assert int(oldAvail) < int(newAvail), "File system did not grow"
|
|
'';
|
|
})
|