aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2019-11-20 01:23:45 +0100
committerThomas Deutschmann <whissi@gentoo.org>2019-11-24 20:59:15 +0100
commiteccc25ea093340a4e3ba662ed8d9e858800cd134 (patch)
treec85c76b3af6214079cd3abf7a7fdf2d1e5ed6093
parentlinuxrc: Fix code style (diff)
downloadgenkernel-eccc25ea093340a4e3ba662ed8d9e858800cd134.tar.gz
genkernel-eccc25ea093340a4e3ba662ed8d9e858800cd134.tar.bz2
genkernel-eccc25ea093340a4e3ba662ed8d9e858800cd134.zip
initrd.scripts: modules_load() refactored
- Add support for LABEL/UUID in root kernel parameter - When loading network, always load all network modules even when root block device is already available - Always load crypto and USB module group when CRYPT_{ROOT,SWAP} is set. - Always load fs module group. - Add gk.hw.load-all kernel command-line argument to allow user to force loading of all module groups. Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
-rw-r--r--defaults/initrd.defaults1
-rw-r--r--defaults/initrd.scripts43
-rw-r--r--defaults/linuxrc8
-rw-r--r--doc/genkernel.8.txt7
4 files changed, 56 insertions, 3 deletions
diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index 8937e65..32f99ec 100644
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -72,6 +72,7 @@ VERIFY=0
IP='dhcp'
GK_BOOTFONT_DISABLED=0
GK_DEBUGMODE_STATEFILE="/tmp/debug.enabled"
+GK_HW_LOAD_ALL_MODULES=0
GK_INIT_LOG='/tmp/init.log'
GK_INIT_LOG_COPYTO=
GK_INIT_LOG_COPYTO_DEFAULT='/genkernel-boot.log'
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 1004ff5..053ac68 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -29,6 +29,37 @@ modules_load() {
modules_scan() {
local MODS
local loaded
+ local smart_loading=yes
+ local _root_dev
+ local root_dev_found="Root block device found, skipping loading of module group \"${1}\" ..."
+
+ if [ "${GK_HW_LOAD_ALL_MODULES}" = '1' ]
+ then
+ smart_loading=
+ elif [ "${1}" = "net" ]
+ then
+ # We already load network modules only when we need
+ # network so don't stop loading network modules when
+ # $REAL_ROOT is already present or we will probably
+ # end up without network we wanted ...
+ smart_loading=
+ elif [ "${1}" = "fs" ]
+ then
+ # We don't know if kernel supports root filesystem so
+ # better load all filesystems ...
+ smart_loading=
+ elif [ -n "${CRYPT_ROOT}" ] || [ -n "${CRYPT_SWAP}" ]
+ then
+ if [ "${1}" = "crypto" ]
+ then
+ smart_loading=
+ elif [ "${1}" = "usb" ]
+ then
+ # We don't know if user is using an USB keyboard to
+ # enter passphrase so better load USB ...
+ smart_loading=
+ fi
+ fi
MODS=$(cat /etc/modules/${1} 2>/dev/null)
[ -n "${MODS}" ] && [ -z "${QUIET}" ] && \
@@ -54,10 +85,16 @@ modules_scan() {
printf "%b\n" "${BOLD} ::${NORMAL} Skipping ${x} ..."
elif [ "${MLOAD}" = "${MLIST}" ]
then
- if [ "${ROOTFSTYPE}" != 'auto' ] && [ -b "${REAL_ROOT}" ]
+ if [ -n "${smart_loading}" ]
then
- echo "Root block device found, continuing ..."
- break
+ _root_dev=$(findfs "${REAL_ROOT}" 2>/dev/null)
+
+ if [ $? -eq 0 ] && [ -n "${_root_dev}" ] && [ -b "${_root_dev}" ]
+ then
+ log_msg "${root_dev_found}"
+ printf "%b" "${root_dev_found}"
+ break
+ fi
fi
if is_debug
diff --git a/defaults/linuxrc b/defaults/linuxrc
index ee46293..f01203b 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -283,6 +283,14 @@ do
fi
unset tmp_disabled
;;
+ gk.hw.load-all=*)
+ tmp_disabled=${x#*=}
+ if is_true "${tmp_disabled}"
+ then
+ GK_HW_LOAD_ALL_MODULES=1
+ fi
+ unset tmp_disabled
+ ;;
gk.log.disabled=*)
tmp_disabled=${x#*=}
if is_true "${tmp_disabled}"
diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index bee3017..cb2009f 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -787,6 +787,13 @@ when not set. This will allow remote user to provide answer through
will load that font. This boolean option allows you to disable
loading of the user embedded bootfont.
+*gk.hw.load-all*=<...>::
+ By default, genkernel loads various module groups (nvme, sata,
+ scsi, pata, usb...) until block device specified in *root* parameter
+ becomes available. This boolean option allows you to force
+ loading of all module groups regardless whether root device is
+ already available.
+
*gk.log.disabled*=<...>::
By default, any shown message and external command calls will be logged
to '/tmp/init.log' in initramfs. This boolean option allows you to