diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2015-12-06 23:39:47 +0000 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2015-12-09 15:45:09 +0000 |
commit | 95beada655754fffaca24c92067df1070943a9f4 (patch) | |
tree | ec77caccfe72f741585e03e1c6714a9094b8d9b2 | |
parent | fa82bf1b5801b220102521addc876b80d8696afc (diff) |
Only run fsck if enabled in /etc/fstab (pass != 0)
hooks/functions: Don't install fsck for a mountpoint with pass = 0, and do
nothing if all mountpoints have pass=0
scripts/functions: Change _checkfs_once to fail quietly if fsck is missing
scripts/local: Only call _checkfs_once if pass != 0
Closes: #797361
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rwxr-xr-x | hooks/fsck | 20 | ||||
-rw-r--r-- | scripts/functions | 4 | ||||
-rw-r--r-- | scripts/local | 4 |
3 files changed, 20 insertions, 8 deletions
@@ -39,6 +39,7 @@ _read_fstab_entry () { echo "MNT_FSNAME=$MNT_FSNAME" echo "MNT_DIR=$MNT_DIR" echo "MNT_TYPE=$MNT_TYPE" + echo "MNT_PASS=$MNT_PASS" break 2 fi MNT_DIR="" @@ -47,13 +48,13 @@ _read_fstab_entry () { done } -# Find a specific fstab entry and print its type (if found) +# Find a specific fstab entry and print its type (if found, and pass != 0) # $1=mountpoint -get_fstype_fstab () { +get_fsck_type_fstab () { eval "$(_read_fstab_entry "$1")" # Not found by default. - if [ "$1" = "$MNT_DIR" ]; then + if [ "$1" = "$MNT_DIR" ] && [ "$MNT_PASS" != 0 ]; then case "$MNT_TYPE" in auto) if command -v blkid >/dev/null 2>&1 ; then @@ -73,9 +74,9 @@ get_fstype_fstab () { fi } -get_fstypes() { - get_fstype_fstab / - get_fstype_fstab /usr +get_fsck_types() { + get_fsck_type_fstab / + get_fsck_type_fstab /usr } case $1 in @@ -92,6 +93,11 @@ fi . /usr/share/initramfs-tools/scripts/functions . /usr/share/initramfs-tools/hook-functions +fsck_types="$(get_fsck_types | sort | uniq)" + +if [ -z "$fsck_types" ]; then + exit 0 +fi copy_exec /sbin/fsck copy_exec /sbin/logsave @@ -105,7 +111,7 @@ cat >"${DESTDIR}/etc/e2fsck.conf" <<EOF broken_system_clock=1 EOF -for type in $(get_fstypes | sort | uniq); do +for type in $fsck_types; do if [ "$type" = 'auto' ] ; then echo "Warning: couldn't identify filesystem type for fsck hook, ignoring." continue diff --git a/scripts/functions b/scripts/functions index 8b93c6b..aa53010 100644 --- a/scripts/functions +++ b/scripts/functions @@ -349,6 +349,10 @@ _checkfs_once() TYPE=$(get_fstype "$1") FSCKCODE=0 + if ! command -v fsck >/dev/null 2>&1; then + log_warning_msg "fsck not present, so skipping $NAME file system" + return + fi if [ "$fastboot" = "y" ] ; then log_warning_msg "Fast boot enabled, so skipping $NAME file system check." return diff --git a/scripts/local b/scripts/local index f6424f0..25584fc 100644 --- a/scripts/local +++ b/scripts/local @@ -175,7 +175,9 @@ local_mount_fs() # FIXME This has no error checking modprobe "${MNT_TYPE}" - checkfs "$MNT_FSNAME" "$MNT_DIR" + if [ "$MNT_PASS" != 0 ]; then + checkfs "$MNT_FSNAME" "$MNT_DIR" + fi # FIXME This has no error checking # Mount filesystem |