[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#767471: [initramfs-tools] / formatted as ext3 but mounted as ext4 not fsck-able



I ran into the same problem.

The root cause of the problem is that the logic for selecting the fsck programs to include in the initramfs is not the same as the logic
for deciding which fsck program to run during boot.

During build /usr/share/initramfs-tools/hooks/fsck parses /etc/fstab to determine the type and then includes fsck.$type. If $type is auto an attempt is made to guess it with blkid.

During boot scrips/functions guesses the type using /bin/fstype falling back to blkid and /lib/udev/vol_id. It then runs fsck -t $type.

In my opinion the logic used during boot should be used during build to determine the required fsck programs.
The attached patch tries to do that.



--- /usr/share/initramfs-tools/hooks/fsck.orig	2015-05-02 19:11:30.143672644 +0200
+++ /usr/share/initramfs-tools/hooks/fsck	2015-05-14 20:56:08.815857800 +0200
@@ -54,22 +54,12 @@
 
 	# Not found by default.
 	if [ "$1" = "$MNT_DIR" ]; then
-		case "$MNT_TYPE" in
-			auto)
-				if command -v blkid >/dev/null 2>&1 ; then
-					MNT_FSNAME=$(resolve_device "$MNT_FSNAME")
-					MNT_TYPE=$(blkid -o value -s TYPE "${MNT_FSNAME}")
-				fi
-				if [ -z "${MNT_TYPE}" ]; then
-					MNT_TYPE="auto"
-				fi
-				echo "$MNT_TYPE"
-				;;
-			*)
-				echo "$MNT_TYPE"
-				;;
-		esac
-
+		MNT_FSNAME=$(resolve_device "$MNT_FSNAME")
+		MNT_TYPE_GUESSED=$(PATH="$PATH:/usr/lib/klibc/bin" get_fstype "$MNT_FSNAME")
+		if [ "${MNT_TYPE_GUESSED}" != "unknown" ]; then
+			MNT_TYPE="${MNT_TYPE_GUESSED}"
+		fi
+		echo "$MNT_TYPE"
 	fi
 }
 

Reply to: