about summary refs log tree commit diff
path: root/nixos/tests/systemd-initrd-luks-password.nix
diff options
context:
space:
mode:
authorNick Cao <nickcao@nichi.co>2022-11-21 14:49:20 +0800
committerNick Cao <nickcao@nichi.co>2022-11-21 14:49:20 +0800
commit46328f5596bcc2743f727e3ab884dea362c627d8 (patch)
tree72ead5c4e72e3176ff02d3f4dc68df8817a3e271 /nixos/tests/systemd-initrd-luks-password.nix
parent51e4bd298f8a1b449aa6784dbfdf7d575e0c2549 (diff)
nixosTests.systemd-initrd-luks-password: test mounting device unlocked in initrd after switching root
Diffstat (limited to 'nixos/tests/systemd-initrd-luks-password.nix')
-rw-r--r--nixos/tests/systemd-initrd-luks-password.nix5
1 files changed, 5 insertions, 0 deletions
diff --git a/nixos/tests/systemd-initrd-luks-password.nix b/nixos/tests/systemd-initrd-luks-password.nix
index e8e651f7b35f8..55d0b4324b400 100644
--- a/nixos/tests/systemd-initrd-luks-password.nix
+++ b/nixos/tests/systemd-initrd-luks-password.nix
@@ -23,6 +23,8 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
         cryptroot2.device = "/dev/vdd";
       };
       virtualisation.bootDevice = "/dev/mapper/cryptroot";
+      # test mounting device unlocked in initrd after switching root
+      virtualisation.fileSystems."/cryptroot2".device = "/dev/mapper/cryptroot2";
     };
   };
 
@@ -31,6 +33,8 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
     machine.wait_for_unit("multi-user.target")
     machine.succeed("echo -n supersecret | cryptsetup luksFormat -q --iter-time=1 /dev/vdc -")
     machine.succeed("echo -n supersecret | cryptsetup luksFormat -q --iter-time=1 /dev/vdd -")
+    machine.succeed("echo -n supersecret | cryptsetup luksOpen   -q               /dev/vdd cryptroot2")
+    machine.succeed("mkfs.ext4 /dev/mapper/cryptroot2")
 
     # Boot from the encrypted disk
     machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-luks.conf")
@@ -44,5 +48,6 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
     machine.wait_for_unit("multi-user.target")
 
     assert "/dev/mapper/cryptroot on / type ext4" in machine.succeed("mount")
+    assert "/dev/mapper/cryptroot2 on /cryptroot2 type ext4" in machine.succeed("mount")
   '';
 })