at 25.11-pre 1.8 kB view raw
1import ./make-test-python.nix ( 2 { lib, pkgs, ... }: 3 { 4 name = "systemd-initrd-btrfs-raid"; 5 6 nodes.machine = 7 { pkgs, ... }: 8 { 9 # Use systemd-boot 10 virtualisation = { 11 emptyDiskImages = [ 12 512 13 512 14 ]; 15 useBootLoader = true; 16 # Booting off the BTRFS RAID requires an available init script from the Nix store 17 mountHostNixStore = true; 18 useEFIBoot = true; 19 }; 20 boot.loader.systemd-boot.enable = true; 21 boot.loader.efi.canTouchEfiVariables = true; 22 23 environment.systemPackages = with pkgs; [ btrfs-progs ]; 24 boot.initrd.systemd = { 25 enable = true; 26 emergencyAccess = true; 27 }; 28 29 specialisation.boot-btrfs-raid.configuration = { 30 fileSystems = lib.mkVMOverride { 31 "/".fsType = lib.mkForce "btrfs"; 32 }; 33 virtualisation.rootDevice = "/dev/vdb"; 34 }; 35 }; 36 37 testScript = '' 38 # Create RAID 39 machine.succeed("mkfs.btrfs -d raid0 /dev/vdb /dev/vdc") 40 machine.succeed("mkdir -p /mnt && mount /dev/vdb /mnt && echo hello > /mnt/test && umount /mnt") 41 42 # Boot from the RAID 43 machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-btrfs-raid.conf") 44 machine.succeed("sync") 45 machine.crash() 46 machine.wait_for_unit("multi-user.target") 47 48 # Ensure we have successfully booted from the RAID 49 assert "(initrd)" in machine.succeed("systemd-analyze") # booted with systemd in stage 1 50 assert "/dev/vdb on / type btrfs" in machine.succeed("mount") 51 assert "hello" in machine.succeed("cat /test") 52 assert "Total devices 2" in machine.succeed("btrfs filesystem show") 53 ''; 54 } 55)