From 94a906b59a7c73f6a0b6ef120f89ee0f927f0dc9 Mon Sep 17 00:00:00 2001 From: Matt McHenry Date: Tue, 21 Aug 2018 21:39:27 -0400 Subject: [PATCH] systemd: ensure fsck Requires/After links are created in mount units systemd-fsck-generator only produces these lines if it can find the necessary fsck executable in its PATH. fixes #29139. --- nixos/modules/system/boot/stage-2-init.sh | 2 +- nixos/modules/system/boot/stage-2.nix | 1 + nixos/release.nix | 1 + nixos/tests/fsck.nix | 29 +++++++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 nixos/tests/fsck.nix diff --git a/nixos/modules/system/boot/stage-2-init.sh b/nixos/modules/system/boot/stage-2-init.sh index b83012dfda7..49764b75a55 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 9fd89b6319d..55e6b19c67f 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 b25c684ff47..b80ab44eced 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 00000000000..f943bb7f235 --- /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'); + }; + ''; +}