systemd-stage-1: fsck
This commit is contained in:
parent
a0ba973e13
commit
14b77582da
@ -365,6 +365,7 @@ in {
|
||||
less = "${pkgs.less}/bin/less";
|
||||
mount = "${cfg.package.util-linux}/bin/mount";
|
||||
umount = "${cfg.package.util-linux}/bin/umount";
|
||||
fsck = "${cfg.package.util-linux}/bin/fsck";
|
||||
};
|
||||
|
||||
managerEnvironment.PATH = "/bin:/sbin";
|
||||
|
||||
@ -158,12 +158,41 @@ let
|
||||
|
||||
makeFstabEntries =
|
||||
let
|
||||
fsToSkipCheck = [ "none" "bindfs" "btrfs" "zfs" "tmpfs" "nfs" "nfs4" "vboxsf" "glusterfs" "apfs" "9p" "cifs" "prl_fs" "vmhgfs" ];
|
||||
fsToSkipCheck = [
|
||||
"none"
|
||||
"auto"
|
||||
"overlay"
|
||||
"iso9660"
|
||||
"bindfs"
|
||||
"udf"
|
||||
"btrfs"
|
||||
"zfs"
|
||||
"tmpfs"
|
||||
"bcachefs"
|
||||
"nfs"
|
||||
"nfs4"
|
||||
"nilfs2"
|
||||
"vboxsf"
|
||||
"squashfs"
|
||||
"glusterfs"
|
||||
"apfs"
|
||||
"9p"
|
||||
"cifs"
|
||||
"prl_fs"
|
||||
"vmhgfs"
|
||||
] ++ lib.optionals (!config.boot.initrd.checkJournalingFS) [
|
||||
"ext3"
|
||||
"ext4"
|
||||
"reiserfs"
|
||||
"xfs"
|
||||
"jfs"
|
||||
"f2fs"
|
||||
];
|
||||
isBindMount = fs: builtins.elem "bind" fs.options;
|
||||
skipCheck = fs: fs.noCheck || fs.device == "none" || builtins.elem fs.fsType fsToSkipCheck || isBindMount fs;
|
||||
# https://wiki.archlinux.org/index.php/fstab#Filepath_spaces
|
||||
escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string;
|
||||
in fstabFileSystems: { rootPrefix ? "", excludeChecks ? false, extraOpts ? (fs: []) }: concatMapStrings (fs:
|
||||
in fstabFileSystems: { rootPrefix ? "", extraOpts ? (fs: []) }: concatMapStrings (fs:
|
||||
(optionalString (isBindMount fs) (escape rootPrefix))
|
||||
+ (if fs.device != null then escape fs.device
|
||||
else if fs.label != null then "/dev/disk/by-label/${escape fs.label}"
|
||||
@ -171,14 +200,12 @@ let
|
||||
+ " " + escape fs.mountPoint
|
||||
+ " " + fs.fsType
|
||||
+ " " + escape (builtins.concatStringsSep "," (fs.options ++ (extraOpts fs)))
|
||||
+ " " + (optionalString (!excludeChecks)
|
||||
("0 " + (if skipCheck fs then "0" else if fs.mountPoint == "/" then "1" else "2")))
|
||||
+ " 0 " + (if skipCheck fs then "0" else if fs.mountPoint == "/" then "1" else "2")
|
||||
+ "\n"
|
||||
) fstabFileSystems;
|
||||
|
||||
initrdFstab = pkgs.writeText "initrd-fstab" (makeFstabEntries (filter utils.fsNeededForBoot fileSystems) {
|
||||
rootPrefix = "/sysroot";
|
||||
excludeChecks = true;
|
||||
extraOpts = fs:
|
||||
(optional fs.autoResize "x-systemd.growfs")
|
||||
++ (optional fs.autoFormat "x-systemd.makefs");
|
||||
|
||||
@ -233,6 +233,7 @@ in {
|
||||
freshrss-pgsql = handleTest ./freshrss-pgsql.nix {};
|
||||
frr = handleTest ./frr.nix {};
|
||||
fsck = handleTest ./fsck.nix {};
|
||||
fsck-systemd-stage-1 = handleTest ./fsck.nix { systemdStage1 = true; };
|
||||
ft2-clone = handleTest ./ft2-clone.nix {};
|
||||
mimir = handleTest ./mimir.nix {};
|
||||
garage = handleTest ./garage {};
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
{ system ? builtins.currentSystem
|
||||
, config ? {}
|
||||
, pkgs ? import ../.. { inherit system config; }
|
||||
, systemdStage1 ? false
|
||||
}:
|
||||
|
||||
import ./make-test-python.nix {
|
||||
name = "fsck";
|
||||
|
||||
@ -11,13 +17,17 @@ import ./make-test-python.nix {
|
||||
autoFormat = true;
|
||||
};
|
||||
};
|
||||
|
||||
boot.initrd.systemd.enable = systemdStage1;
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
machine.wait_for_unit("default.target")
|
||||
|
||||
with subtest("root fs is fsckd"):
|
||||
machine.succeed("journalctl -b | grep 'fsck.ext4.*/dev/vda'")
|
||||
machine.succeed("journalctl -b | grep '${if systemdStage1
|
||||
then "fsck.*vda.*clean"
|
||||
else "fsck.ext4.*/dev/vda"}'")
|
||||
|
||||
with subtest("mnt fs is fsckd"):
|
||||
machine.succeed("journalctl -b | grep 'fsck.*/dev/vdb.*clean'")
|
||||
|
||||
@ -4,19 +4,30 @@ Date: Thu, 1 May 2014 14:10:10 +0200
|
||||
Subject: [PATCH] Look for fsck in the right place
|
||||
|
||||
---
|
||||
src/fsck/fsck.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
src/fsck/fsck.c | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
|
||||
index 595434ab57..374a4e6c76 100644
|
||||
index 73c76fceea..d00cea7158 100644
|
||||
--- a/src/fsck/fsck.c
|
||||
+++ b/src/fsck/fsck.c
|
||||
@@ -373,7 +373,7 @@ static int run(int argc, char *argv[]) {
|
||||
@@ -352,6 +352,7 @@ static int run(int argc, char *argv[]) {
|
||||
if (r == 0) {
|
||||
char dash_c[STRLEN("-C") + DECIMAL_STR_MAX(int) + 1];
|
||||
int progress_socket = -1;
|
||||
+ _cleanup_free_ char *fsck_name = NULL;
|
||||
const char *cmdline[9];
|
||||
int i = 0;
|
||||
|
||||
@@ -372,7 +373,10 @@ static int run(int argc, char *argv[]) {
|
||||
} else
|
||||
dash_c[0] = 0;
|
||||
|
||||
- cmdline[i++] = "/sbin/fsck";
|
||||
+ cmdline[i++] = "/run/current-system/sw/bin/fsck";
|
||||
+ r = find_executable("fsck", &fsck_name);
|
||||
+ if (r < 0)
|
||||
+ return r;
|
||||
+ cmdline[i++] = fsck_name;
|
||||
cmdline[i++] = arg_repair;
|
||||
cmdline[i++] = "-T";
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user