linuxrc: use "quiet" cmdline argument for a really quiet initramfs initialization

"quiet" is already used by the kernel to avoid printing messages on the
console unless they are errors or warnings. Genkernel should do the same
wrt its initramfs initialization code.
This has also the advantage of improving the boot speed.
cleanup-cruft
Fabio Erculiani 12 years ago
parent 499f2d98b6
commit 9ead931af1

@ -16,15 +16,16 @@ modules_scan() {
local loaded local loaded
MODS=$(cat /etc/modules/${1} 2>/dev/null) MODS=$(cat /etc/modules/${1} 2>/dev/null)
[ -n "${MODS}" ] && echo -ne "${BOLD} ::${NORMAL} " [ -n "${MODS}" ] && [ -z "${QUIET}" ] && \
[ -n "${MODS}" ] && echo -ne "Loading from ${1}: " echo -ne "${BOLD} ::${NORMAL} Loading from ${1}: "
for x in ${MODS} for x in ${MODS}
do do
MLOAD=$(echo ${MLIST} | sed -e "s/.*${x}.*/${x}/") MLOAD=$(echo ${MLIST} | sed -e "s/.*${x}.*/${x}/")
if [ "${MLOAD}" = "${x}" ] # Only module to no-load if [ "${MLOAD}" = "${x}" ] # Only module to no-load
then then
echo -e "${BOLD} ::${NORMAL} Skipping ${x}..." [ -z "${QUIET}" ] && \
echo -e "${BOLD} ::${NORMAL} Skipping ${x}..."
elif [ "${MLOAD}" = "${MLIST}" ] elif [ "${MLOAD}" = "${MLIST}" ]
then then
if [ -n "${DEBUG}" ]; then if [ -n "${DEBUG}" ]; then
@ -33,17 +34,21 @@ modules_scan() {
fi fi
modprobe ${x} > /dev/null 2>&1 modprobe ${x} > /dev/null 2>&1
loaded=${?} loaded=${?}
[ -n "${DEBUG}" -a "${loaded}" = "0" ] && \ [ -n "${DEBUG}" -a "${loaded}" = "0" ] && \
echo "loaded" echo "loaded"
[ -n "${DEBUG}" -a "${loaded}" != "0" ] && \ [ -n "${DEBUG}" -a "${loaded}" != "0" ] && \
echo "not loaded" echo "not loaded"
[ -z "${DEBUG}" -a "${loaded}" = "0" ] && \ [ -z "${DEBUG}" -a "${loaded}" = "0" ] && \
[ -z "${QUIET}" ] && \
echo -en "${x} " echo -en "${x} "
else else
echo -e "${BOLD} ::${NORMAL} Skipping ${x}..." [ -z "${QUIET}" ] && \
echo -e "${BOLD} ::${NORMAL} Skipping ${x}..."
fi fi
done done
[ -n "${MODS}" ] && echo [ -n "${MODS}" ] && [ -z "${QUIET}" ] && echo
} }
uppercase(){ uppercase(){
@ -378,6 +383,8 @@ test_success() {
# $2 hide flag # $2 hide flag
good_msg() { good_msg() {
[ -n "${QUIET}" ] && [ -z "${DEBUG}" ] && return 0
msg_string=$1 msg_string=$1
msg_string="${msg_string:-...}" msg_string="${msg_string:-...}"
[ "$2" != 1 ] && echo -e "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}" [ "$2" != 1 ] && echo -e "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
@ -424,12 +431,15 @@ prompt_user(){
eval local oldvalue='$'${1} eval local oldvalue='$'${1}
[ $# != 2 -a $# != 3 ] && \ [ $# != 2 -a $# != 3 ] && \
bad_msg "Bad invocation of function prompt_user, please file a bug \ bad_msg "Bad invocation of function prompt_user."
report with this message" && exit 1 bad_msg "Please file a bug report with this message" && exit 1
[ -n "${3}" ] && local explnt=" or : ${3}" || local explnt="." [ -n "${3}" ] && local explnt=" or : ${3}" || local explnt="."
bad_msg "Could not find the ${2} in ${oldvalue}${explnt}" bad_msg "Could not find the ${2} in ${oldvalue}${explnt}"
echo ' Please specify another value or: press Enter for the same, type "shell" for a shell, or "q" to skip...' bad_msg "Please specify another value or:"
bad_msg "- press Enter for the same"
bad_msg '- type "shell" for a shell'
bad_msg '- type "q" to skip...'
echo -n "${2}(${oldvalue}) :: " echo -n "${2}(${oldvalue}) :: "
read ${1} read ${1}
case `eval echo '$'${1}` in case `eval echo '$'${1}` in
@ -440,7 +450,7 @@ prompt_user(){
;; ;;
'shell') 'shell')
eval ${1}'='${oldvalue} eval ${1}'='${oldvalue}
echo "To leave and try again just press <Ctrl>+D" warn_msg "To leave and try again just press <Ctrl>+D"
run_shell run_shell
;; ;;
'') '')
@ -600,7 +610,7 @@ chooseKeymap() {
splash set_msg "Set keymap to ${keymap}" splash set_msg "Set keymap to ${keymap}"
elif [ -z "${keymap}" ] elif [ -z "${keymap}" ]
then then
echo good_msg
good_msg "Keeping default keymap" good_msg "Keeping default keymap"
splash set_msg "Keeping default keymap" splash set_msg "Keeping default keymap"
else else

@ -31,8 +31,6 @@ then
[ -e /linuxrc ] && rm /linuxrc [ -e /linuxrc ] && rm /linuxrc
fi fi
quiet_kmsg
CMDLINE=$(cat /proc/cmdline) CMDLINE=$(cat /proc/cmdline)
# Scan CMDLINE for any specified real_root= or cdroot arguments # Scan CMDLINE for any specified real_root= or cdroot arguments
FAKE_ROOT='' FAKE_ROOT=''
@ -41,6 +39,7 @@ FAKE_ROOTFLAGS=''
INIT_OPTS='' INIT_OPTS=''
ROOTFSTYPE='auto' ROOTFSTYPE='auto'
CRYPT_SILENT=0 CRYPT_SILENT=0
QUIET=''
mkdir -p /etc/cmdline /etc/modprobe.d mkdir -p /etc/cmdline /etc/modprobe.d
for x in ${CMDLINE} for x in ${CMDLINE}
@ -118,6 +117,9 @@ do
ZPOOL_FORCE=-f ZPOOL_FORCE=-f
fi fi
;; ;;
quiet)
QUIET=1
;;
# Debug Options # Debug Options
debug) debug)
DEBUG='yes' DEBUG='yes'
@ -270,6 +272,8 @@ do
esac esac
done done
quiet_kmsg
if [ "${CDROOT}" = '0' ] if [ "${CDROOT}" = '0' ]
then then
if [ -z "${REAL_ROOT}" -a "${FAKE_ROOT}" != "/dev/ram0" ] if [ -z "${REAL_ROOT}" -a "${FAKE_ROOT}" != "/dev/ram0" ]
@ -457,17 +461,13 @@ then
if [ "${REAL_ROOT}" = '' ] if [ "${REAL_ROOT}" = '' ]
then then
echo -n -e "${WARN}>>${NORMAL}${BOLD} No bootable medium found. Waiting for new devices" warn_msg "No bootable medium found. Waiting for new devices..."
COUNTER=0 COUNTER=0
while [ ${COUNTER} -lt 3 ]; do while [ ${COUNTER} -lt 3 ]; do
sleep 3 sleep 3
echo -n '.'
let COUNTER=${COUNTER}+1 let COUNTER=${COUNTER}+1
done done
sleep 1 sleep 1
echo -e "${NORMAL}"
bootstrapCD bootstrapCD
fi fi
@ -909,43 +909,42 @@ fi
verbose_kmsg verbose_kmsg
echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting (initramfs)${NORMAL}" good_msg "Booting (initramfs)"
cd "${CHROOT}" cd "${CHROOT}"
mkdir "${CHROOT}/proc" "${CHROOT}/sys" "${CHROOT}/run" 2>/dev/null mkdir "${CHROOT}/proc" "${CHROOT}/sys" "${CHROOT}/run" 2>/dev/null
echo -ne "${BOLD}.${NORMAL}"
# If devtmpfs is mounted, try move it to the new root # If devtmpfs is mounted, try move it to the new root
# If that fails, try to unmount all possible mounts of devtmpfs as stuff breaks otherwise # If that fails, try to unmount all possible mounts of
# devtmpfs as stuff breaks otherwise
for fs in /dev /sys /proc for fs in /dev /sys /proc
do do
if grep -qs "$fs" /proc/mounts if grep -qs "$fs" /proc/mounts
then then
if ! mount --move $fs "${CHROOT}"$fs if ! mount --move $fs "${CHROOT}"$fs
then then
umount $fs || echo '*: Failed to move and unmount the ramdisk $fs!' umount $fs || \
bad_msg "Failed to move and unmount the ramdisk $fs!"
fi fi
fi fi
done done
if [ ! -e "${CHROOT}/dev/console" ] || [ ! -e "${CHROOT}/dev/null" ] if [ ! -e "${CHROOT}/dev/console" ] || [ ! -e "${CHROOT}/dev/null" ]
then then
echo -ne "${BAD}>>${NORMAL}${BOLD} ERROR: your real /dev is missing files required to boot (console and null)${NORMAL}" bad_msg "ERROR: your real /dev is missing console and null"
elif [ -e /etc/initrd.splash -a ! -e "${CHROOT}/dev/tty1" ] elif [ -e /etc/initrd.splash -a ! -e "${CHROOT}/dev/tty1" ]
then then
echo -ne "${BAD}>>${NORMAL}${BOLD} ERROR: your real /dev is missing tty1, which is required for splash${NORMAL}" bad_msg "ERROR: your real /dev is missing tty1, required for splash"
fi fi
echo -e "${BOLD}.${NORMAL}"
exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" "${INIT_OPTS}" exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" "${INIT_OPTS}"
# If we get here, something bad has happened # If we get here, something bad has happened
splash 'verbose' splash 'verbose'
echo "A fatal error has probably occured since ${REAL_INIT:-/sbin/init} did not" bad_msg "A fatal error has occured since ${REAL_INIT:-/sbin/init} did not"
echo "boot correctly. Trying to open a shell..." bad_msg "boot correctly. Trying to open a shell..."
echo
exec /bin/bash exec /bin/bash
exec /bin/sh exec /bin/sh
exec /bin/ash exec /bin/ash

@ -493,6 +493,10 @@ which the ramdisk scripts would recognize.
switch_root into "<CHROOT>/<SUBDIR>" instead of "<CHROOT>/". switch_root into "<CHROOT>/<SUBDIR>" instead of "<CHROOT>/".
<CHROOT> is "/newroot" (or "/union") usually. <CHROOT> is "/newroot" (or "/union") usually.
*quiet*::
Do not print anything but error and warning messages during
the execution of the initramfs init scripts.
*debug*:: *debug*::
Drop into a debug shell early in the process. Drop into a debug shell early in the process.

Loading…
Cancel
Save