1 { kernelPackages ? null, flavour, mkXfsFlags ? "" }: let
4 machine.succeed("vgcreate test_vg /dev/vdb /dev/vdc")
5 machine.succeed("lvcreate -L 512M --type raid0 test_vg -n test_lv")
9 machine.succeed("vgcreate test_vg /dev/vdb")
10 machine.succeed("lvcreate -L 512M -T test_vg/test_thin_pool")
11 machine.succeed("lvcreate -n test_lv -V 16G --thinpool test_thin_pool test_vg")
15 machine.succeed("vgcreate test_vg /dev/vdb")
16 machine.succeed("lvcreate --type vdo -n test_lv -L 6G -V 12G test_vg/vdo_pool_lv")
22 boot.initrd.kernelModules = [
30 boot.thin.enable = true;
31 dmeventd.enable = true;
37 boot.vdo.enable = true;
38 dmeventd.enable = true;
45 "test_lv" in machine.succeed("lvs --select segtype=raid0")
49 "test_lv" in machine.succeed("lvs --select segtype=thin-pool")
53 "test_lv" in machine.succeed("lvs --select segtype=vdo")
57 in import ../make-test-python.nix ({ pkgs, lib, ... }: {
58 name = "lvm2-${flavour}-systemd-stage-1";
59 meta.maintainers = lib.teams.helsinki-systems.members;
61 nodes.machine = { pkgs, lib, ... }: {
62 imports = [ extraConfig ];
65 emptyDiskImages = [ 8192 8192 ];
68 # To boot off the LVM disk, we need to have a init script which comes from the Nix store.
69 mountHostNixStore = true;
71 boot.loader.systemd-boot.enable = true;
72 boot.loader.efi.canTouchEfiVariables = true;
74 environment.systemPackages = with pkgs; [ xfsprogs ];
78 emergencyAccess = true;
80 initrd.services.lvm.enable = true;
81 kernelPackages = lib.mkIf (kernelPackages != null) kernelPackages;
84 specialisation.boot-lvm.configuration.virtualisation = {
85 useDefaultFilesystems = false;
88 device = "/dev/test_vg/test_lv";
93 rootDevice = "/dev/test_vg/test_lv";
98 machine.wait_for_unit("multi-user.target")
99 # Create a VG for the root
101 machine.succeed("mkfs.xfs ${mkXfsFlags} /dev/test_vg/test_lv")
102 machine.succeed("mkdir -p /mnt && mount /dev/test_vg/test_lv /mnt && echo hello > /mnt/test && umount /mnt")
105 machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-lvm.conf")
106 machine.succeed("sync")
108 machine.wait_for_unit("multi-user.target")
110 # Ensure we have successfully booted from LVM
111 assert "(initrd)" in machine.succeed("systemd-analyze") # booted with systemd in stage 1
112 assert "/dev/mapper/test_vg-test_lv on / type xfs" in machine.succeed("mount")
113 assert "hello" in machine.succeed("cat /test")