3
0
Fork 0
forked from mirrors/nixpkgs

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.
This commit is contained in:
Matt McHenry 2018-08-21 21:39:27 -04:00 committed by Robin Gloster
parent 69b4f427b6
commit 94a906b59a
4 changed files with 32 additions and 1 deletions

View file

@ -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

View file

@ -17,6 +17,7 @@ let
pkgs.utillinux
pkgs.openresolv
];
fsPackagesPath = lib.makeBinPath config.system.fsPackages;
postBootCommands = pkgs.writeText "local-cmds"
''
${config.boot.postBootCommands}

View file

@ -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 {};

29
nixos/tests/fsck.nix Normal file
View file

@ -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');
};
'';
}