1 import ./make-test-python.nix ({ lib, pkgs, ... }: {
2 name = "systemd-initrd-swraid";
4 nodes.machine = { pkgs, ... }: {
7 emptyDiskImages = [ 512 512 ];
11 boot.loader.systemd-boot.enable = true;
12 boot.loader.efi.canTouchEfiVariables = true;
14 environment.systemPackages = with pkgs; [ mdadm e2fsprogs ]; # for mdadm and mkfs.ext4
18 emergencyAccess = true;
23 ARRAY /dev/md0 devices=/dev/vdc,/dev/vdd
26 kernelModules = [ "raid0" ];
29 specialisation.boot-swraid.configuration.virtualisation.bootDevice = "/dev/disk/by-label/testraid";
34 machine.succeed("mdadm --create --force /dev/md0 -n 2 --level=raid0 /dev/vdc /dev/vdd")
35 machine.succeed("mkfs.ext4 -L testraid /dev/md0")
36 machine.succeed("mkdir -p /mnt && mount /dev/md0 /mnt && echo hello > /mnt/test && umount /mnt")
39 machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-swraid.conf")
40 machine.succeed("sync")
42 machine.wait_for_unit("multi-user.target")
44 # Ensure we have successfully booted from the RAID
45 assert "(initrd)" in machine.succeed("systemd-analyze") # booted with systemd in stage 1
46 assert "/dev/md0 on / type ext4" in machine.succeed("mount")
47 assert "hello" in machine.succeed("cat /test")
48 assert "md0" in machine.succeed("cat /proc/mdstat")