summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatt McHenry <github@matt.mchenryfamily.org>2018-08-21 21:39:27 -0400
committerRobin Gloster <mail@glob.in>2018-08-28 17:12:49 +0200
commit94a906b59a7c73f6a0b6ef120f89ee0f927f0dc9 (patch)
tree5607fda8ea37abcf44ae1b23ec211757a1ba3cd9
parent69b4f427b67fe83ddb2bb3ee113770aa802e5643 (diff)
downloadnixpkgs-94a906b59a7c73f6a0b6ef120f89ee0f927f0dc9.tar
nixpkgs-94a906b59a7c73f6a0b6ef120f89ee0f927f0dc9.tar.gz
nixpkgs-94a906b59a7c73f6a0b6ef120f89ee0f927f0dc9.tar.bz2
nixpkgs-94a906b59a7c73f6a0b6ef120f89ee0f927f0dc9.tar.lz
nixpkgs-94a906b59a7c73f6a0b6ef120f89ee0f927f0dc9.tar.xz
nixpkgs-94a906b59a7c73f6a0b6ef120f89ee0f927f0dc9.tar.zst
nixpkgs-94a906b59a7c73f6a0b6ef120f89ee0f927f0dc9.zip
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.
-rw-r--r--nixos/modules/system/boot/stage-2-init.sh2
-rw-r--r--nixos/modules/system/boot/stage-2.nix1
-rw-r--r--nixos/release.nix1
-rw-r--r--nixos/tests/fsck.nix29
4 files changed, 32 insertions, 1 deletions
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');
+    };
+  '';
+}