aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2020-08-28 15:38:41 +0200
committerThomas Deutschmann <whissi@gentoo.org>2020-08-28 18:35:59 +0200
commit05f968fda2c6839744b36c442b3feaa6de974e63 (patch)
tree035d108aeb9bb1305f6208984c52b8b2733dce75
parentdefaults/linuxrc: Add gk.udev.debug to run udevd in debug mode (diff)
downloadgenkernel-05f968fda2c6839744b36c442b3feaa6de974e63.tar.gz
genkernel-05f968fda2c6839744b36c442b3feaa6de974e63.tar.bz2
genkernel-05f968fda2c6839744b36c442b3feaa6de974e63.zip
defaults/linuxrc: Try to determine filesystem type
'mount -t auto' will not trigger module loading for filesystem kernel modules. Therefore we try to determine filesystem to trigger module loading in case filesystem isn't built into the kernel. Bug: https://bugs.gentoo.org/739250 Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
-rw-r--r--defaults/initrd.scripts42
-rw-r--r--defaults/linuxrc6
2 files changed, 46 insertions, 2 deletions
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index ee7ca2c..36f4791 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -198,6 +198,8 @@ findmediamount() {
fi
good_msg "Attempting to mount media: ${x}" ${CRYPT_SILENT}
+ CDROOT_TYPE=$(determine_fs "${x}" "${CDROOT_TYPE}")
+
run mount -t ${CDROOT_TYPE} ${x} ${mntcddir} >/dev/null 2>&1
if [ $? -eq 0 ]
then
@@ -233,6 +235,31 @@ findmediamount() {
[ -n "${result}" ] || bad_msg "Media not found" ${CRYPT_SILENT}
}
+determine_fs() {
+ local _dev="${1}"
+ local _orig="${2:-auto}"
+ local _fs line
+
+ _fs=$(udevadm info --query=env --name="$_dev" 2>/dev/null | \
+ while read line || [ -n "${line}" ]
+ do
+ if str_starts ${line} "ID_FS_TYPE="
+ then
+ echo ${line#ID_FS_TYPE=}
+ break
+ fi
+ done
+ )
+ _fs=${_fs:-auto}
+
+ if [ "${_fs}" = "auto" ]
+ then
+ _fs="${_orig}"
+ fi
+
+ echo "${_fs}"
+}
+
devicelist() {
# Locate the cdrom device with our media on it.
# CDROM DEVICES
@@ -697,7 +724,9 @@ setup_aufs() {
then
good_msg "Mounting ${aufs_dev} to ${aufs_memory} for aufs support"
- if ! run mount -t auto "${aufs_dev}" "${aufs_dev_mnt}" >/dev/null 2>&1
+ local mounttype=$(determine_fs "${aufs_dev}" "auto")
+
+ if ! run mount -t ${mounttype} "${aufs_dev}" "${aufs_dev_mnt}" >/dev/null 2>&1
then
bad_msg "Mount of ${aufs_dev} failed, falling back to ramdisk based aufs"
unset aufs_dev
@@ -2727,6 +2756,17 @@ get_zfs_property() {
echo "$(zfs get -H -o value ${propertyname} "${device}" 2>/dev/null)"
}
+# Returns TRUE if $1 contains literal string $2 at the
+# beginning and is not empty
+str_starts() {
+ if [ "${1#"${2}"*}" != "${1}" ]
+ then
+ return 0
+ fi
+
+ return 1
+}
+
# If the kernel is handed a mount option is does not recognize, it WILL fail to
# mount. util-linux handles auto/noauto, but busybox passes it straight to the kernel
# which then rejects the mount.
diff --git a/defaults/linuxrc b/defaults/linuxrc
index b42366f..061d3e0 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -910,6 +910,10 @@ do
# If $REAL_ROOT is a symlink
# Resolve it like util-linux mount does
[ -L ${REAL_ROOT} ] && REAL_ROOT=$(readlink -f ${REAL_ROOT})
+
+ # determine fs -- 'auto' will not trigger module loading!
+ ROOTFSTYPE=$(determine_fs "${REAL_ROOT}" "${ROOTFSTYPE}")
+
# mount ro so fsck doesn't barf later
if [ "${REAL_ROOTFLAGS}" = '' ]
then
@@ -1028,7 +1032,7 @@ then
MOUNTTYPE="ext2"
;;
*)
- MOUNTTYPE="${LOOPTYPE}"
+ MOUNTTYPE=$(determine_fs "/dev/mapper/root" "${MOUNTTYPE}")
;;
esac
run mount -t "${MOUNTTYPE}" -o ro /dev/mapper/root "${NEW_ROOT}/mnt/livecd"