diff -rupN mkinitcpio-0.5.19/hooks/filesystems mkinitcpio-0.5.19.new/hooks/filesystems --- mkinitcpio-0.5.19/hooks/filesystems 2008-05-19 08:56:43.000000000 -0700 +++ mkinitcpio-0.5.19.new/hooks/filesystems 2008-06-05 00:42:08.000000000 -0700 @@ -1,26 +1,39 @@ -# vim: set ft=sh: +# vim: set ft=sh: emacs: -*- sh -*- run_hook () { msg -n ":: Loading root filesystem module..." - if [ -n "${rootfstype}" ]; then - FSTYPE="${rootfstype}" - else - if [ ! -e "${root}" ]; then - msg "\nAttempting to create root device '${root}'" - if [ -n "${rootdelay}" ]; then - msg -n "Waiting for devices to settle..." - /bin/sleep "${rootdelay}" - msg "done." - export rootdelay=0 - fi + # Turn rootdelay=XXX into rootpoll=XXX; this is because rootpoll + # is superior to rootdelay in that it waits at most the same + # amount of time as rootdelay would, but usually waits much less. + if [ -n "${rootdelay}" ]; then + echo "Consider using rootpoll=${rootdelay} instead of " + echo "rootdelay=${rootdelay}; rootpoll is faster." + fi + export rootpoll=${rootpoll:-$rootdelay} + export rootdelay=${rootdelay:+0} + # If the root device file does not exist, then we may have to wait for + # it to be created. This is because some devices are discovered + # dynamically by the kernel and this can take time. + if [ ! -b "${root}" ]; then + if [ -n "${rootpoll}" -a "${rootpoll}" != "0" ]; then + msg -n "\nWaiting for devices to settle..." + while [ "${rootpoll}" -gt "0" -a ! -b "${root}" ]; do + /bin/sleep 1 + rootpoll=$((${rootpoll}-1)) + done + msg "done." + fi + + # If the root device still does not exist, try parseblock as a way + # to detect and create it. + if [ ! -b "${root}" ]; then + msg "\nRoot device '${root}' doesn't exist, attempting to create it" eval $(/bin/parseblock "${root}") if [ "${BLOCKNAME}" = "unknown" ]; then - FSTYPE="unknown" echo "ERROR: Failed to parse block device name for '${root}'" elif [ -z "${BLOCKDEVICE}" ]; then - FSTYPE="unknown" echo "ERROR: Failed to parse block device ids for '${root}'" else export root="${BLOCKNAME}" @@ -28,18 +41,22 @@ run_hook () /bin/mknod "${BLOCKNAME}" b ${BLOCKDEVICE} >/dev/null fi fi + fi - if [ -e "${root}" ]; then - eval $( /bin/fstype < "${root}" ) - else - FSTYPE="unknown" - fi - + # Now load the module for the root fs + if [ -n "${rootfstype}" ]; then + FSTYPE="${rootfstype}" + elif [ -b "${root}" ]; then + eval $( /bin/fstype < "${root}" ) + else + FSTYPE="unknown" fi - msg " ${FSTYPE}" + if [ "${FSTYPE}" = "unknown" ]; then - echo "ERROR: root fs cannot be detected. Try using the rootfstype= kernel parameter." + echo -n "ERROR: root fs cannot be detected. Try using the " + echo "rootfstype= kernel parameter." else + msg "Detected filesystem type ${FSTYPE} on ${root}" kinit_params="${kinit_params} rootfstype=${FSTYPE}" /sbin/modprobe -q "${FSTYPE}" >/dev/null 2>&1 fi diff -rupN mkinitcpio-0.5.19/hooks/fw mkinitcpio-0.5.19.new/hooks/fw --- mkinitcpio-0.5.19/hooks/fw 2008-05-19 08:56:43.000000000 -0700 +++ mkinitcpio-0.5.19.new/hooks/fw 2008-06-05 00:42:20.000000000 -0700 @@ -1,8 +1,9 @@ -# vim: set ft=sh: +# vim: set ft=sh: emacs: -*- sh -*- run_hook () { - #if we have to root delay, default to 5 seconds - # this will be handled by kinit and/or the - # filesystems hook - export rootdelay=${rootdelay:-6} + # Booting from fw devices often requires that we wait until the + # device is ready. The rootpoll option is the best way to do + # this. This is the sole purpose of the fw hook - to set the + # rootpoll value if it wasn't already set. + export rootpoll=${rootpoll:-15} } diff -rupN mkinitcpio-0.5.19/hooks/usb mkinitcpio-0.5.19.new/hooks/usb --- mkinitcpio-0.5.19/hooks/usb 2008-05-19 08:56:43.000000000 -0700 +++ mkinitcpio-0.5.19.new/hooks/usb 2008-06-05 00:42:13.000000000 -0700 @@ -1,8 +1,9 @@ -# vim: set ft=sh: +# vim: set ft=sh: emacs: -*- sh -*- run_hook () { - #if we have to root delay, default to 5 seconds - # this will be handled by kinit and/or the - # filesystems hook - export rootdelay=${rootdelay:-6} + # Booting from usb devices often requires that we wait until the + # device is ready. The rootpoll option is the best way to do + # this. This is the sole purpose of the usb hook - to set the + # rootpoll value if it wasn't already set. + export rootpoll=${rootpoll:-15} } diff -rupN mkinitcpio-0.5.19/init mkinitcpio-0.5.19.new/init --- mkinitcpio-0.5.19/init 2008-05-19 08:56:43.000000000 -0700 +++ mkinitcpio-0.5.19.new/init 2008-06-05 00:39:13.000000000 -0700 @@ -21,7 +21,7 @@ for cmd in ${CMDLINE}; do \#*) break ;; # ignore everything after a # in the commandline [0123456Ss]) export runlevel="${cmd}" ;; single) export runlevel="S" ;; #some people use 'single' - #Allow "init=X" to pass-through + # Allow "init=X" to pass-through init=*) kinit_params="${kinit_params} ${cmd}" ;; # only export stuff that does work with dash :) *=*) cmd="$(replace -s= "${cmd}" '.' '_')" @@ -78,47 +78,27 @@ if [ -e "/hooks" ]; then done fi -if [ "${rootdelay}" != "0" ]; then - msg -n "Waiting for devices to settle..." - /bin/sleep "${rootdelay}" - export rootdelay=0 - export kinit_params="$kinit_params rootdelay=0" - msg "done." -fi - +# Now if a break was requested, do it now; if the root device doesn't +# exist, this will give the user a chance to diagnose why without +# being forced to reboot if [ "${break}" = "y" ]; then echo ":: Break requested, type 'exit' to resume operation" echo " NOTE: klibc contains no 'ls' binary, use 'echo *' instead" PS1="ramfs$ " /bin/sh -i fi +# If the root device still does not exist, then we're screwed. Alert the +# user and reboot. if [ ! -b "${root}" ]; then - # This duplicates code from the filesystem hook - # without this, mkinitcpio would fail for users who use - # neither the udev hook, nor the filesystem hook - msg "\nRoot device '${root}' doesn't exist, attempting to create it" - - eval $(/bin/parseblock "${root}") - if [ "${BLOCKNAME}" = "unknown" ]; then - echo "ERROR: Failed to parse block device name for '${root}'" - elif [ -z "${BLOCKDEVICE}" ]; then - echo "ERROR: Failed to parse block device ids for '${root}'" - else - export root="${BLOCKNAME}" - echo "/bin/mknod \"${BLOCKNAME}\" b ${BLOCKDEVICE}" - /bin/mknod "${BLOCKNAME}" b ${BLOCKDEVICE} >/dev/null - fi - if [ ! -b "${root}" ]; then - err "Unable to create/detect root device '${root}'" - echo "Dropping to a recovery shell... type 'exit' to reboot" - echo "NOTE: klibc contains no 'ls' binary, use 'echo *' instead" - echo "" - echo "If the device '${root}' gets created while you are here," - echo "try adding 'rootdelay=8' or higher to the kernel command-line" - PS1="ramfs$ " /bin/sh -i - msg "Rebooting..." - /bin/reboot - fi + err "Unable to create/detect root device '${root}'" + echo "Dropping to a recovery shell... type 'exit' to reboot" + echo "NOTE: klibc contains no 'ls' binary, use 'echo *' instead" + echo "" + echo "If the device '${root}' gets created while you are here," + echo "try adding 'rootpoll=15' or higher to the kernel command-line" + PS1="ramfs$ " /bin/sh -i + msg "Rebooting..." + /bin/reboot fi msg ":: Initramfs Completed - control passing to kinit" @@ -126,7 +106,7 @@ if [ -f "/message" ]; then msg "$(cat /message)" fi -#Special handling if udev is running +# Special handling if udev is running udevpid=$(/bin/minips -C udevd -o pid=) if [ -n "${udevpid}" ]; then /bin/kill -9 ${udevpid}