commit: ea892515ef3a46171d288d9c119defedf8dbee28 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> AuthorDate: Sun Jan 5 20:45:51 2020 +0000 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> CommitDate: Sun Jan 5 20:57:16 2020 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=ea892515
initrd.scripts: modules_scan(): Cache found rootfs Calling findfs() isn't a cheap operation especially when slow media like optical drives are involved. WIth this change, a statefile (GK_ROOTFS_DETECTED_STATEFILE) will be created when rootfs was found which will allow us to skip further findfs() calls when present. Link: https://forums.gentoo.org/viewtopic-t-1105908.html Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> defaults/initrd.defaults | 1 + defaults/initrd.scripts | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults index 268a7be..198800b 100644 --- a/defaults/initrd.defaults +++ b/defaults/initrd.defaults @@ -90,6 +90,7 @@ GK_NET_TIMEOUT_DHCP=10 GK_NET_TIMEOUT_INTERFACE=10 GK_PROMPT_FILE='/tmp/current_prompt' GK_PROMPT_TIMEOUT=0 +GK_ROOTFS_DETECTED_STATEFILE="/tmp/rootfs.detected" GK_SHELL_LOCKFILE='/tmp/rescueshell.lock' GK_SSHD_LOCKFILE='/tmp/remote-rescueshell.lock' GK_SSHD_PIDFILE='/var/run/dropbear.pid' diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 4b43d33..73cd94c 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -100,9 +100,16 @@ modules_scan() { then if [ "${smart_loading}" = "yes" ] then - _root_dev=$(findfs "${REAL_ROOT}" 2>/dev/null) + if [ ! -f "${GK_ROOTFS_DETECTED_STATEFILE}" ] + then + _root_dev=$(findfs "${REAL_ROOT}" 2>/dev/null) + if [ $? -eq 0 ] && [ -n "${_root_dev}" ] && [ -b "${_root_dev}" ] + then + echo "${_root_dev}" > "${GK_ROOTFS_DETECTED_STATEFILE}" + fi + fi - if [ $? -eq 0 ] && [ -n "${_root_dev}" ] && [ -b "${_root_dev}" ] + if [ -f "${GK_ROOTFS_DETECTED_STATEFILE}" ] then log_msg "${root_dev_found}" printf "%b" "${root_dev_found}"