diff --git a/nixos/modules/system/boot/stage-2-init.sh b/nixos/modules/system/boot/stage-2-init.sh index b83012dfda7e..49764b75a557 100644 --- a/nixos/modules/system/boot/stage-2-init.sh +++ b/nixos/modules/system/boot/stage-2-init.sh @@ -159,6 +159,6 @@ exec {logOutFd}>&- {logErrFd}>&- # Start systemd. echo "starting systemd..." -PATH=/run/current-system/systemd/lib/systemd \ +PATH=/run/current-system/systemd/lib/systemd:@fsPackagesPath@ \ LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive \ exec systemd diff --git a/nixos/modules/system/boot/stage-2.nix b/nixos/modules/system/boot/stage-2.nix index 9fd89b6319db..55e6b19c67fd 100644 --- a/nixos/modules/system/boot/stage-2.nix +++ b/nixos/modules/system/boot/stage-2.nix @@ -17,6 +17,7 @@ let pkgs.utillinux pkgs.openresolv ]; + fsPackagesPath = lib.makeBinPath config.system.fsPackages; postBootCommands = pkgs.writeText "local-cmds" '' ${config.boot.postBootCommands} diff --git a/nixos/release.nix b/nixos/release.nix index b25c684ff47a..b80ab44eced5 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -291,6 +291,7 @@ in rec { tests.firefox = callTest tests/firefox.nix {}; tests.flatpak = callTest tests/flatpak.nix {}; tests.firewall = callTest tests/firewall.nix {}; + tests.fsck = callTest tests/fsck.nix {}; tests.fwupd = callTest tests/fwupd.nix {}; tests.gdk-pixbuf = callTest tests/gdk-pixbuf.nix {}; #tests.gitlab = callTest tests/gitlab.nix {}; diff --git a/nixos/tests/fsck.nix b/nixos/tests/fsck.nix new file mode 100644 index 000000000000..f943bb7f2350 --- /dev/null +++ b/nixos/tests/fsck.nix @@ -0,0 +1,29 @@ +import ./make-test.nix { + name = "fsck"; + + machine = { lib, ... }: { + virtualisation.emptyDiskImages = [ 1 ]; + + fileSystems = lib.mkVMOverride { + "/mnt" = { + device = "/dev/vdb"; + fsType = "ext4"; + autoFormat = true; + }; + }; + }; + + testScript = '' + $machine->waitForUnit('default.target'); + + subtest "root fs is fsckd", sub { + $machine->succeed('journalctl -b | grep "fsck.ext4.*/dev/vda"'); + }; + + subtest "mnt fs is fsckd", sub { + $machine->succeed('journalctl -b | grep "fsck.*/dev/vdb.*clean"'); + $machine->succeed('grep "Requires=systemd-fsck@dev-vdb.service" /run/systemd/generator/mnt.mount'); + $machine->succeed('grep "After=systemd-fsck@dev-vdb.service" /run/systemd/generator/mnt.mount'); + }; + ''; +}