+grep -q "devicetimeout=*" /proc/cmdline
+if [ $? -eq 0 ]
+then
+ for opt in `cat /proc/cmdline`
+ do
+ echo "$opt" | grep -q "devicetimeout="
+ if [ $? -eq 0 ]
+ then
+ DEVTIMEOUT=`echo $opt | cut -d'=' -f2`
+ fi
+ done
+else
+ DEVTIMEOUT=10
+fi
+echo -e " ${BOLD}${BLUE}*${NORM} Waiting $DEVTIMEOUT seconds for devices to settle..."
+sleep $DEVTIMEOUT
+
+# if root=/dev/XXX was specified on the command line, use that as the new root
+# instead of searching for the media and using it. if it fails, fall back to the media
+grep -q "root=/dev/*" /proc/cmdline
+if [ $? -eq 0 ]
+then
+ for opt in `cat /proc/cmdline`
+ do
+ echo "$opt" | grep -q "root="
+ if [ $? -eq 0 ]
+ then
+ ROOTDEV=`echo $opt | cut -d'=' -f2`
+ fi
+ done
+ mkdir -p /newroot
+ # check the specified root device to see if it has an init
+ mount $ROOTDEV /newroot
+ if [ $? -ne 0 ]
+ then
+ echo -e " ${BOLD}${RED}*${NORM} Unable to mount the specified root device! Falling back to the live media."
+ find_and_mount_media
+ else
+ if [ -x /newroot/sbin/init ]
+ then
+ echo -e " ${BOLD}${BLUE}*${NORM} Mounted root device $ROOTDEV."
+ else
+ echo -e " ${BOLD}${RED}*${NORM} The specified root device ($ROOTDEV) does not appear to be usable! Falling back to the live media."
+ umount /newroot
+ find_and_mount_media
+ fi
+ fi
+else
+ find_and_mount_media
+fi
+
+echo -e "${BOLD}${BLUE}*${NORM} Switching root.\n"
+echo "$PRINTK" > /proc/sys/kernel/printk
+echo > /proc/sys/kernel/hotplug
+umount /sys
+umount /proc
+exec /bin/switch_root /newroot /sbin/init
+
+echo "Something's broken, here's a shell."
+exec /bin/sh