Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/
Date: Fri, 28 Aug 2020 20:18:53
Message-Id: 1598632559.05f968fda2c6839744b36c442b3feaa6de974e63.whissi@gentoo
1 commit: 05f968fda2c6839744b36c442b3feaa6de974e63
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Fri Aug 28 13:38:41 2020 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Fri Aug 28 16:35:59 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=05f968fd
7
8 defaults/linuxrc: Try to determine filesystem type
9
10 'mount -t auto' will not trigger module loading for filesystem kernel modules.
11 Therefore we try to determine filesystem to trigger module loading in case
12 filesystem isn't built into the kernel.
13
14 Bug: https://bugs.gentoo.org/739250
15 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
16
17 defaults/initrd.scripts | 42 +++++++++++++++++++++++++++++++++++++++++-
18 defaults/linuxrc | 6 +++++-
19 2 files changed, 46 insertions(+), 2 deletions(-)
20
21 diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
22 index ee7ca2c..36f4791 100644
23 --- a/defaults/initrd.scripts
24 +++ b/defaults/initrd.scripts
25 @@ -198,6 +198,8 @@ findmediamount() {
26 fi
27 good_msg "Attempting to mount media: ${x}" ${CRYPT_SILENT}
28
29 + CDROOT_TYPE=$(determine_fs "${x}" "${CDROOT_TYPE}")
30 +
31 run mount -t ${CDROOT_TYPE} ${x} ${mntcddir} >/dev/null 2>&1
32 if [ $? -eq 0 ]
33 then
34 @@ -233,6 +235,31 @@ findmediamount() {
35 [ -n "${result}" ] || bad_msg "Media not found" ${CRYPT_SILENT}
36 }
37
38 +determine_fs() {
39 + local _dev="${1}"
40 + local _orig="${2:-auto}"
41 + local _fs line
42 +
43 + _fs=$(udevadm info --query=env --name="$_dev" 2>/dev/null | \
44 + while read line || [ -n "${line}" ]
45 + do
46 + if str_starts ${line} "ID_FS_TYPE="
47 + then
48 + echo ${line#ID_FS_TYPE=}
49 + break
50 + fi
51 + done
52 + )
53 + _fs=${_fs:-auto}
54 +
55 + if [ "${_fs}" = "auto" ]
56 + then
57 + _fs="${_orig}"
58 + fi
59 +
60 + echo "${_fs}"
61 +}
62 +
63 devicelist() {
64 # Locate the cdrom device with our media on it.
65 # CDROM DEVICES
66 @@ -697,7 +724,9 @@ setup_aufs() {
67 then
68 good_msg "Mounting ${aufs_dev} to ${aufs_memory} for aufs support"
69
70 - if ! run mount -t auto "${aufs_dev}" "${aufs_dev_mnt}" >/dev/null 2>&1
71 + local mounttype=$(determine_fs "${aufs_dev}" "auto")
72 +
73 + if ! run mount -t ${mounttype} "${aufs_dev}" "${aufs_dev_mnt}" >/dev/null 2>&1
74 then
75 bad_msg "Mount of ${aufs_dev} failed, falling back to ramdisk based aufs"
76 unset aufs_dev
77 @@ -2727,6 +2756,17 @@ get_zfs_property() {
78 echo "$(zfs get -H -o value ${propertyname} "${device}" 2>/dev/null)"
79 }
80
81 +# Returns TRUE if $1 contains literal string $2 at the
82 +# beginning and is not empty
83 +str_starts() {
84 + if [ "${1#"${2}"*}" != "${1}" ]
85 + then
86 + return 0
87 + fi
88 +
89 + return 1
90 +}
91 +
92 # If the kernel is handed a mount option is does not recognize, it WILL fail to
93 # mount. util-linux handles auto/noauto, but busybox passes it straight to the kernel
94 # which then rejects the mount.
95
96 diff --git a/defaults/linuxrc b/defaults/linuxrc
97 index b42366f..061d3e0 100644
98 --- a/defaults/linuxrc
99 +++ b/defaults/linuxrc
100 @@ -910,6 +910,10 @@ do
101 # If $REAL_ROOT is a symlink
102 # Resolve it like util-linux mount does
103 [ -L ${REAL_ROOT} ] && REAL_ROOT=$(readlink -f ${REAL_ROOT})
104 +
105 + # determine fs -- 'auto' will not trigger module loading!
106 + ROOTFSTYPE=$(determine_fs "${REAL_ROOT}" "${ROOTFSTYPE}")
107 +
108 # mount ro so fsck doesn't barf later
109 if [ "${REAL_ROOTFLAGS}" = '' ]
110 then
111 @@ -1028,7 +1032,7 @@ then
112 MOUNTTYPE="ext2"
113 ;;
114 *)
115 - MOUNTTYPE="${LOOPTYPE}"
116 + MOUNTTYPE=$(determine_fs "/dev/mapper/root" "${MOUNTTYPE}")
117 ;;
118 esac
119 run mount -t "${MOUNTTYPE}" -o ro /dev/mapper/root "${NEW_ROOT}/mnt/livecd"