diff options
author | Will Fancher <elvishjerricco@gmail.com> | 2023-05-22 09:13:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-22 09:13:00 -0400 |
commit | 636e03bef34e2cc9c19becc28a5aff39cf8aeaa1 (patch) | |
tree | a68f7b213b26ed20eb4dbf4b8028736a203f8c2a /nixos/tests/systemd-repart.nix | |
parent | c7eb65213bd7d95eafb8c5e2e181f04da103d054 (diff) | |
parent | ef80e11032c66d9e978eff9472687c983361fe08 (diff) |
Merge pull request #232533 from nikstur/systemd-repart-create-root
nixos/systemd-repart: enable creating root partition
Diffstat (limited to 'nixos/tests/systemd-repart.nix')
-rw-r--r-- | nixos/tests/systemd-repart.nix | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/nixos/tests/systemd-repart.nix b/nixos/tests/systemd-repart.nix index 5d579ae3371d1..22ea8fbd22711 100644 --- a/nixos/tests/systemd-repart.nix +++ b/nixos/tests/systemd-repart.nix @@ -56,8 +56,8 @@ let # however, creates separate filesystem images without a partition table, so # we have to create a disk image manually. # - # This creates two partitions, an ESP mounted on /dev/vda1 and the root - # partition mounted on /dev/vda2 + # This creates two partitions, an ESP available as /dev/vda1 and the root + # partition available as /dev/vda2. system.build.diskImage = import ../lib/make-disk-image.nix { inherit config pkgs lib; # Use a raw format disk so that it can be resized before starting the @@ -131,4 +131,62 @@ in assert "Growing existing partition 1." in systemd_repart_logs ''; }; + + create-root = makeTest { + name = "systemd-repart-create-root"; + meta.maintainers = with maintainers; [ nikstur ]; + + nodes.machine = { config, lib, pkgs, ... }: { + virtualisation.useDefaultFilesystems = false; + virtualisation.fileSystems = { + "/" = { + device = "/dev/disk/by-partlabel/created-root"; + fsType = "ext4"; + }; + "/nix/store" = { + device = "/dev/vda2"; + fsType = "ext4"; + }; + }; + + # Create an image containing only the Nix store. This enables creating + # the root partition with systemd-repart and then successfully booting + # into a working system. + # + # This creates two partitions, an ESP available as /dev/vda1 and the Nix + # store available as /dev/vda2. + system.build.diskImage = import ../lib/make-disk-image.nix { + inherit config pkgs lib; + onlyNixStore = true; + format = "raw"; + bootSize = "32M"; + additionalSpace = "0M"; + partitionTableType = "efi"; + installBootLoader = false; + copyChannel = false; + }; + + boot.initrd.systemd.enable = true; + + boot.initrd.systemd.repart.enable = true; + boot.initrd.systemd.repart.device = "/dev/vda"; + systemd.repart.partitions = { + "10-root" = { + Type = "root"; + Label = "created-root"; + Format = "ext4"; + }; + }; + }; + + testScript = { nodes, ... }: '' + ${useDiskImage nodes.machine} + + machine.start() + machine.wait_for_unit("multi-user.target") + + systemd_repart_logs = machine.succeed("journalctl --boot --unit systemd-repart.service") + assert "Adding new partition 2 to partition table." in systemd_repart_logs + ''; + }; } |