Skip to content

Commit

Permalink
systemd: ensure fsck Requires/After links are created in mount units
Browse files Browse the repository at this point in the history
systemd-fsck-generator only produces these lines if it can find the
necessary fsck executable in its PATH.

fixes #29139.
  • Loading branch information
jerith666 authored and globin committed Aug 28, 2018
1 parent 69b4f42 commit 94a906b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nixos/modules/system/boot/stage-2-init.sh
Expand Up @@ -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
1 change: 1 addition & 0 deletions nixos/modules/system/boot/stage-2.nix
Expand Up @@ -17,6 +17,7 @@ let
pkgs.utillinux
pkgs.openresolv
];
fsPackagesPath = lib.makeBinPath config.system.fsPackages;
postBootCommands = pkgs.writeText "local-cmds"
''
${config.boot.postBootCommands}
Expand Down
1 change: 1 addition & 0 deletions nixos/release.nix
Expand Up @@ -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 {};
Expand Down
29 changes: 29 additions & 0 deletions 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');
};
'';
}

0 comments on commit 94a906b

Please sign in to comment.