6 echo -ne "\033[0G\033[0K"
12 echo "$1" | cut -d= -f2-
20 echo ${module} >> /etc/modules/extra_load
23 modules_scan extra_load
28 [ -d "/etc/modules/${1}" ] || touch /etc/modules/${1}
30 [ -f "/etc/modules/${1}" ] && MODS=`cat /etc/modules/${1}`
33 MLOAD=`echo ${MLIST} | sed -e "s/.*${x}.*/${x}/"`
34 if [ "${MLOAD}" = "${x}" ] # Only module to no-load
36 echo -e "${BOLD} ::${NORMAL} Skipping ${x}..."
37 elif [ "${MLOAD}" = "${MLIST}" ] # == No change == No specified no-load
39 [ -n "${DEBUG}" ] && echo -ne "${BOLD} ::${NORMAL} Checking for ${x}..."
40 # find -name does not work since the return status is always zero
41 if find /lib/modules/${KV} | grep /"${x}${KSUFF}" >/dev/null 2>&1
43 echo -ne "${BOLD} ::${NORMAL} Scanning for ${x}..."
49 echo -e "${BOLD} ::${NORMAL} Skipping ${x}..."
56 echo $1 | tr 'a-z' 'A-Z'
61 # $1 = mount dir name / media name
62 # $2 = recognition file
63 # $3 = variable to have the device path
64 # $4 = directory before /mnt, like NEW_ROOT
65 # args remaining are possible devices
67 local media=$1 recon=$2 vrbl=$3
68 local mntdir="${4}/mnt/${media}"
71 good_msg "Looking for the ${media}" ${CRYPT_SILENT}
75 [ ! -d "${mntdir}" ] && mkdir -p ${mntdir} 2>/dev/null >/dev/null
76 if [ -n "${ISOBOOT}" ]
78 mntcddir="${mntdir%${media}}iso"
79 if [ ! -f ${mntcddir} ]
89 # Check for a block device to mount
95 # If disk and it has at least one partition, skip.
96 # We use /sys/block/${bsn}/${bsn}[0-9]* to make sure that we
97 # don't skip device mapper devices. Even the craziest scenario
98 # deserves a fair chance.
100 for part in `ls /sys/block/${bsn}/${bsn}[0-9]* 2>/dev/null`
109 good_msg "Attempting to mount media:- ${x}" ${CRYPT_SILENT}
111 # if [ "${media}" = "cdrom" ]; then
112 # mount -r -t iso9660 ${x} ${mntdir} &>/dev/null
114 # mount -r -t auto ${x} ${mntdir} &>/dev/null
116 mount -r -t ${CDROOT_TYPE} ${x} ${mntcddir} >/dev/null 2>&1
119 if [ -n "${ISOBOOT}" ]; then
120 if [ -f ${mntcddir}/${ISOBOOT} ]; then
121 mount -o loop ${mntcddir}/${ISOBOOT} ${mntdir}
122 if [ "$?" = "0" ]; then
123 good_msg "iso mounted on ${mntdir}"
128 # Check for the media
129 if [ -f "${mntdir}/${recon}" ]
131 #set REAL_ROOT, CRYPT_ROOT_KEYDEV or whatever ${vrbl} is
132 eval ${vrbl}'='"${x}"
133 good_msg "Media found on ${x}" ${CRYPT_SILENT}
143 eval local result='$'${vrbl}
145 [ -n "${result}" ] || bad_msg "Media not found" ${CRYPT_SILENT}
149 # Locate the cdrom device with our media on it.
151 local DEVICES="/dev/cdroms/* /dev/ide/cd/* /dev/sr*"
152 # USB Keychain/Storage
153 DEVICES="$DEVICES /dev/sd*"
155 DEVICES="$DEVICES /dev/hd*"
156 # USB using the USB Block Driver
157 DEVICES="$DEVICES /dev/ubd* /dev/ubd/*"
159 DEVICES="$DEVICES /dev/iseries/vcd*"
164 local DEVICES=`devicelist`
165 # The device was specified on the command line, so there's no need to scan
166 # a bunch of extra devices
167 [ -n "${CDROOT_DEV}" ] && DEVICES="${CDROOT_DEV}"
169 findmediamount "cdrom" "${SUBDIR}/livecd" "REAL_ROOT" "${NEW_ROOT}" ${DEVICES}
174 local KEYDEVS=`devicelist`
175 eval local keyloc='"${CRYPT_'${1}'_KEY}"'
177 findmediamount "key" "${keyloc}" "CRYPT_${1}_KEYDEV" "" ${KEYDEVS}
180 cache_cd_contents() {
181 # Check loop file exists and cache to ramdisk if DO_cache is enabled
182 if [ "${LOOPTYPE}" != "noloop" ] && [ "${LOOPTYPE}" != "sgimips" ]
187 # TODO: Check the size of the image versus the size of our tmpfs
188 # along with the amount of available RAM and increase tmpfs size
189 # if necessary. (Not having awk sucks...)
191 # for i in $(cat /proc/meminfo | grep -e ^MemFree -e ^Cached | \
192 # cut -d: -f2 | cut -dk -f1 | sed -e "s/^\s*//") ; do
193 # z=$(($z + $i)) ; done
195 good_msg "Copying loop file for caching..."
196 # Verify that the needed directory exists
197 mkdir -p "$(dirname ${NEW_ROOT}/mnt/${LOOP})"
198 cp -a ${NEW_ROOT}/mnt/cdrom/${LOOP} ${NEW_ROOT}/mnt/${LOOP}
201 bad_msg "Failed to cache the loop file! Lack of space?"
202 rm -rf ${NEW_ROOT}/mnt/livecd.* 2>/dev/null
203 rm -rf ${NEW_ROOT}/mnt/image.* 2>/dev/null
204 rm -rf ${NEW_ROOT}/mnt/zisofs 2>/dev/null
213 mount -t sysfs /sys /sys >/dev/null 2>&1
215 [ ${ret} -eq 0 ] || bad_msg "Failed to mount /sys!"
219 if [ "${IP}" != '' ] || busybox udhcpc -n -T 15 -q
221 [ -e /rootpath ] && NFSROOT=`cat /rootpath`
223 if [ "${NFSROOT}" = '' ]
226 OPTIONS=`busybox dmesg | grep rootserver | sed -e "s/,/ /g"`
227 for OPTION in $OPTIONS
229 if [ `echo $OPTION | sed -e "s/=/ /g" | cut -d " " -f 1` = 'rootserver' ]
231 NFSIP=`echo $OPTION | sed -e "s/=/ /g" | cut -d " " -f 2`
236 OPTIONS=`busybox dmesg | grep rootpath | sed -e "s/,/ /g"`
237 for OPTION in $OPTIONS
239 if [ `echo $OPTION | sed -e "s/=/ /g" | cut -d " " -f 1` = 'rootpath' ]
241 NFSPATH=`echo $OPTION | sed -e "s/=/ /g" | cut -d " " -f 2`
246 if [ "${NFSIP}" != '' ] && [ "$NFSPATH" != '' ]
248 NFSROOT="${NFSIP}:${NFSPATH}"
250 bad_msg "The DHCP Server did not send a valid root-path."
251 bad_msg "Please check your DHCP setup, or provide a nfsroot=<...> parameter."
255 if [ "${NFSROOT}" != '' ]
257 NFSOPTIONS=${NFSROOT#*,}
258 NFSROOT=${NFSROOT%%,*}
259 if [ "${NFSOPTIONS}" = "${NFSROOT}" ]
261 NFSOPTIONS=$DEFAULT_NFSOPTIONS
263 NFSOPTIONS="${DEFAULT_NFSOPTIONS},${NFSOPTIONS}"
266 if [ "${CDROOT}" != '0' ]
268 good_msg "Attempting to mount NFS CD image on ${NFSROOT} with options ${NFSOPTIONS}"
269 mount -t nfs -o ${NFSOPTIONS} ${NFSROOT} ${NEW_ROOT}/mnt/cdrom
274 bad_msg "NFS Mounting failed. Is the path corrent ?"
277 good_msg "Attempting to mount NFS root on ${NFSROOT} with options ${NFSOPTIONS}"
278 mount -t nfs -o ${NFSOPTIONS} ${NFSROOT} ${NEW_ROOT}
283 bad_msg "NFS Mounting failed. Is the path correct ?"
285 # FIXME: Need to start portmap and the other rpc daemons in
286 # order to remount rw.
294 if [ "${LOOP}" = '' -o ! -e "mnt/cdrom/${LOOP}" ]
297 bad_msg "Invalid loop location: ${LOOP}"
298 bad_msg 'Please export LOOP with a valid location, or reboot and pass a proper loop=...'
299 bad_msg 'kernel command line!'
310 # busybox udev replacement
316 # If last command failed send error message and fall back to a shell
317 if [ "$retcode" != '0' ]
320 error_string="${error_string:-run command}"
321 bad_msg 'Failed to $1; failing back to the shell...'
327 # msg functions arguments
333 msg_string="${msg_string:-...}"
334 [ "$2" != 1 ] && echo -e "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
339 msg_string="${msg_string:-...}"
342 splash 'verbose' > /dev/null &
343 echo -e "${BAD}!!${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
349 msg_string="${msg_string:-...}"
350 [ "$2" != 1 ] && echo -e "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
354 if [ "${CRYPT_SILENT}" = '1' ]
356 eval $1 >/dev/null 2>/dev/null
358 splash 'verbose' > /dev/null &
362 splash set_msg 'Disk unlocked.'
368 # $1 = variable whose value is the path (examples: "REAL_ROOT",
371 # $3 = optional explanations for failure
373 eval local oldvalue='$'${1}
375 [ \( $# != 2 \) -a \( $# != 3 \) ] && \
376 bad_msg "Bad invocation of function whereis, please file a bug \
377 report with this message" && exit 1
378 [ -n "${3}" ] && local explnt=" or : ${3}" || local explnt="."
380 bad_msg "Could not find the ${2} in ${oldvalue}${explnt}"
381 echo ' Please specify another value or: press Enter for the same, type "shell" for a shell, or "q" to skip...'
382 echo -n "${2}(${oldvalue}) :: "
384 case `eval echo '$'${1}` in
386 eval ${1}'='${oldvalue}
387 warn_msg "Skipping step, this will likely cause a boot failure."
391 eval ${1}'='${oldvalue}
392 echo "To leave and try again just press <Ctrl>+D"
396 eval ${1}'='${oldvalue}
402 # bind-mount /dev/ so that loop devices can be found
403 mount -o bind ${NEW_ROOT}/dev /dev
407 if [ "${KV_2_6_OR_GREATER}" ]
409 echo /sbin/mdev > /proc/sys/kernel/hotplug
414 # slowusb already set?
415 if [ "${DO_slowusb}" = "1" ]
420 local usb_storage_dir="/sys/bus/usb/drivers/usb-storage"
421 if [ ! -d "${usb_storage_dir}" ]
423 # no automated slowusb required. no usb-storage devices attached.
426 for x in "${usb_storage_dir}"/*
428 [ -d "${x}" ] && [ "${x}" != "${usb_storage_dir}/module" ] \
429 && { DO_slowusb="1" ; break ; }
434 if [ "${KV_2_6_OR_GREATER}" ]
437 good_msg 'Activating mdev'
444 # Scan CMDLINE for any "doscsi" or "noscsi"-type arguments
452 if [ "${y}" = "do${x}" ]
454 MY_HWOPTS="${MY_HWOPTS} $x"
455 elif [ "${y}" = "no${x}" ]
457 MY_HWOPTS="`echo ${MY_HWOPTS} | sed -e \"s/${x}//g\" -`"
459 if [ "$(echo ${y} | cut -b -7)" = "keymap=" ]
461 MY_HWOPTS="${MY_HWOPTS} dokeymap"
466 # Shouldnt need to sort this as the following loop should figure out the
467 # duplicates and strip them out
468 #MY_HWOPTS=`echo ${MY_HWOPTS}| sort`
470 for x in ${MY_HWOPTS}
473 for y in ${TMP_HWOPTS}
475 if [ "${y}" = "${x}" ]
480 TMP_HWOPTS="${TMP_HWOPTS} ${x}"
481 eval DO_`echo ${x} | sed 's/-//'`=1
484 MY_HWOPTS=${TMP_HWOPTS}
488 # Load modules listed in MY_HWOPTS if /lib/modules exists for the running
490 if [ -d "/lib/modules/${KV}" ]
492 good_msg 'Loading modules'
493 # Load appropriate kernel modules
494 for modules in $MY_HWOPTS
496 modules_scan $modules
499 good_msg 'Skipping module load; no modules in the ramdisk!'
504 if [ "${DO_keymap}" ]
506 if [ ! -e /dev/vc/0 -a ! -e /dev/tty0 ]
509 mount -o bind ${NEW_ROOT}/dev /dev
511 [ ! -e /dev/tty0 ] && ln -s /dev/tty1 /dev/tty0
513 [ -f /lib/keymaps/keymapList ] && chooseKeymap
515 [ "${DEVBIND}" = '1' ] && umount /dev
517 if [ -e /etc/sysconfig/keyboard -a "${CDROOT}" = '1' ]
519 mkdir -p ${NEW_ROOT}/etc/sysconfig/
520 cp /etc/sysconfig/keyboard ${NEW_ROOT}/etc/sysconfig/keyboard
526 good_msg "Loading keymaps"
527 if [ -z "${keymap}" ]
529 splash 'verbose' > /dev/null &
530 cat /lib/keymaps/keymapList
531 read -t 10 -p '<< Load keymap (Enter for default): ' keymap
533 1|azerty) keymap=azerty ;;
536 4|br-a) keymap=br-a ;;
537 5|br-l) keymap=br-l ;;
540 8|croat) keymap=croat ;;
544 12|dvorak) keymap=dvorak ;;
566 34|sk-y) keymap=sk-y ;;
567 35|sk-z) keymap=sk-z ;;
568 36|slovene) keymap=slovene ;;
569 37|trf) keymap=trf ;;
570 38|trq) keymap=trq ;;
574 42|wangbe) keymap=wangbe ;;
577 if [ -e /lib/keymaps/${keymap}.map ]
579 good_msg "Loading the ''${keymap}'' keymap"
580 loadkmap < /lib/keymaps/${keymap}.map
582 # echo ${keymap} | egrep -e "[0-9]+" >/dev/null 2>&1
585 # xkeymap=`tail -n 7 /lib/keymaps/keymapList | grep ${keymap} | sed -r "s/.*\s+${keymap}\s+([a-z-]+).*/\1/g" | egrep -v 1`
587 mkdir -p /etc/sysconfig
588 # echo "XKEYBOARD=${xkeymap}" > /etc/sysconfig/keyboard
589 echo "XKEYBOARD=${keymap}" > /etc/sysconfig/keyboard
590 splash set_msg "Set keymap to ${keymap}"
591 elif [ -z "${keymap}" ]
594 good_msg "Keeping default keymap"
595 splash set_msg "Keeping default keymap"
597 bad_msg "Sorry, but keymap ''${keymap}'' is invalid!"
604 #good_msg 'Checking if volumes need to be started...'
606 # Here, we check for /dev/device-mapper, and if it exists, we setup a
607 # a symlink, which should hopefully fix bug #142775 and bug #147015
608 if [ -e /dev/device-mapper ] && [ ! -e /dev/mapper/control ]
611 ln -sf /dev/device-mapper /dev/mapper/control
614 if [ "${USE_MDADM}" = '1' ]
616 if [ ! -e '/etc/mdadm.conf' ]
618 /sbin/mdadm --examine > /etc/mdadm.conf
620 /sbin/mdadm --assemble
623 if [ "${USE_DMRAID_NORMAL}" = '1' ]
625 if [ -e '/sbin/dmraid' ]
627 good_msg "Activating Device-Mapper RAID(s)"
628 if [ '${DMRAID_OPTS}' = '' ]
632 /sbin/dmraid -ay ${DMRAID_OPTS}
637 if [ "${USE_LVM_NORMAL}" = '1' ]
639 if [ -e '/bin/vgscan' -a -e '/bin/vgchange' ]
641 for dev in ${RAID_DEVICES}
643 setup_md_device "${dev}"
646 good_msg "Scanning for Volume Groups"
647 /bin/vgscan --ignorelockingfailure --mknodes 2>/dev/null
649 good_msg "Activating Volume Groups"
650 /bin/vgchange -ay --ignorelockingfailure 2>/dev/null
652 # Disable EVMS since lvm is activated and they dont work together.
653 if [ "${USE_EVMS_NORMAL}" = '1' ]
655 bad_msg "Disabling EVMS Support because LVM started"
656 bad_msg "Do not add dolvm to the cmdline if this is not what you want"
657 bad_msg "LVM and EVMS do not work well together"
661 bad_msg "vgscan or vgchange not found: skipping LVM volume group activation!"
665 if [ "${USE_EVMS_NORMAL}" = '1' ]
667 if [ -e '/sbin/evms_activate' ]
669 good_msg "Activating EVMS"
677 if [ -n "${ISCSI_INITIATORNAME}" ] && [ -n "${ISCSI_TARGET}" ] && [ -n "${ISCSI_ADDRESS}" ]
679 good_msg "Activating iSCSI"
681 if [ "${ISCSI_TGPT}" ]
683 ADDITIONAL="${ADDITIONAL} -g ${ISCSI_TGPT}"
685 ADDITIONAL="${ADDITIONAL} -g 1"
688 if [ "${ISCSI_PORT}" ]
690 ADDITIONAL="${ADDITIONAL} -p ${ISCSI_PORT}"
693 if [ "${ISCSI_USERNAME}" ]
695 ADDITIONAL="${ADDITIONAL} -u ${ISCSI_USERNAME}"
698 if [ "${ISCSI_PASSWORD}" ]
700 ADDITIONAL="${ADDITIONAL} -w ${ISCSI_PASSWORD}"
703 if [ "${ISCSI_USERNAME_IN}" ]
705 ADDITIONAL="${ADDITIONAL} -U ${ISCSI_USERNAME_IN}"
708 if [ "${ISCSI_PASSWORD_IN}" ]
710 ADDITIONAL="${ADDITIONAL} -W ${ISCSI_PASSWORD_IN}"
713 if [ "${ISCSI_DEBUG}" ]
715 ADDITIONAL="${ADDITIONAL} -d ${ISCSI_DEBUG}"
718 iscsistart -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -a "${ISCSI_ADDRESS}" ${ADDITIONAL}
724 # It is either the root or a swap, other devices are supported in the scripts provided with sys-fs/cryptsetup-luks
727 # please use 'tr' and this line, or remove it
728 # eval local TYPE=`uppercase $1`
739 eval local LUKS_DEVICE='"${CRYPT_'${TYPE}'}"' LUKS_NAME="$1" LUKS_KEY='"${CRYPT_'${TYPE}'_KEY}"' LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"'
740 local DEV_ERROR=0 KEY_ERROR=0 KEYDEV_ERROR=0
741 local mntkey="/mnt/key/" cryptsetup_options=''
743 [ ! -e /sbin/cryptsetup ] && bad_msg "The ramdisk does not support LUKS" && exit 1
746 # if crypt_silent=1 and some error occurs, enter shell quietly
747 if [ \( ${CRYPT_SILENT} -eq 1 \) -a \( \( \( ${DEV_ERROR} -eq 1 \) -o \( ${KEY_ERROR} -eq 1 \) \) -o \( ${KEYDEV_ERROR} -eq 1 \) \) ]
750 elif [ ${DEV_ERROR} -eq 1 ]
752 whereis "LUKS_DEVICE" "${LUKS_NAME}"
754 elif [ ${KEY_ERROR} -eq 1 ]
756 whereis "LUKS_KEY" "${LUKS_NAME} key"
758 elif [ ${KEYDEV_ERROR} -eq 1 ]
760 whereis "LUKS_KEYDEV" "${LUKS_NAME} key device"
763 setup_md_device ${LUKS_DEVICE}
764 cryptsetup isLuks ${LUKS_DEVICE}
767 bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" ${CRYPT_SILENT}
772 if [ -n "${LUKS_KEY}" ]
774 if [ ! -e "${mntkey}${LUKS_KEY}" ]
776 if [ -b "${LUKS_KEYDEV}" ]
777 then good_msg "Using key device ${LUKS_KEYDEV}." ${CRYPT_SILENT}
779 good_msg "Please insert removable device ${LUKS_KEYDEV} for ${LUKS_NAME}" ${CRYPT_SILENT}
780 # abort after 10 secs
782 while [ ${count} -gt 0 ]
786 if [ -b "${LUKS_KEYDEV}" ]
788 good_msg "Removable device ${LUKS_KEYDEV} detected." ${CRYPT_SILENT}
792 if [ ! -b "${LUKS_KEYDEV}" ]
794 eval CRYPT_${TYPE}_KEY=${LUKS_KEY}
796 eval LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"'
797 if [ ! -b "${LUKS_KEYDEV}" ]; then
799 bad_msg "Removable device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT}
802 # continue otherwise will mount keydev which is mounted by bootstrap
806 # At this point a device was recognized, now let's see if the key is there
807 [ ! -d "$mntkey" ] && mkdir -p ${mntkey} 2>/dev/null >/dev/null
809 mount -n -o ro ${LUKS_KEYDEV} ${mntkey} >/dev/null 2>/dev/null
813 bad_msg "Mounting of device ${LUKS_KEYDEV} failed." ${CRYPT_SILENT}
816 good_msg "Removable device ${LUKS_KEYDEV} mounted." ${CRYPT_SILENT}
819 if [ ! -e "${mntkey}${LUKS_KEY}" ]; then
820 umount -n ${mntkey} 2>/dev/null >/dev/null
823 bad_msg "Key {LUKS_KEY} on device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT}
828 # At this point a candidate key exists (either mounted before or not)
829 good_msg "${LUKS_KEY} on device ${LUKS_KEYDEV} found" ${CRYPT_SILENT}
830 cryptsetup_options="-d ${mntkey}${LUKS_KEY}"
832 # At this point, keyfile or not, we're ready!
833 crypt_filter "cryptsetup ${cryptsetup_options} luksOpen ${LUKS_DEVICE} ${LUKS_NAME}"
836 good_msg "LUKS device ${LUKS_DEVICE} opened" ${CRYPT_SILENT}
839 bad_msg "Failed to open LUKS device ${LUKS_DEVICE}" ${CRYPT_SILENT}
847 umount ${mntkey} 2>/dev/null >/dev/null
848 rmdir -p ${mntkey} 2>/dev/null >/dev/null
853 # if key is set but key device isn't, find it
855 [ -n "${CRYPT_ROOT_KEY}" ] && [ -z "${CRYPT_ROOT_KEYDEV}" ] \
856 && sleep 6 && bootstrapKey "ROOT"
858 if [ -n "${CRYPT_ROOT}" ]; then
860 if [ -n "${REAL_ROOT}" ]
865 REAL_ROOT="/dev/mapper/root"
869 # same for swap, but no need to sleep if root was unencrypted
870 [ -n "${CRYPT_SWAP_KEY}" ] && [ -z "${CRYPT_SWAP_KEYDEV}" ] \
871 && { [ -z "${CRYPT_ROOT}" ] && sleep 6; bootstrapKey "SWAP"; }
873 if [ -n "${CRYPT_SWAP}" ]; then
875 if [ -z "${REAL_RESUME}" ]
877 # Resume from swap as default
878 REAL_RESUME="/dev/mapper/swap"
884 # Sleep a specific number of seconds if SDELAY is set otherwise only sleep
885 # 3 seconds, which is a much better default than 1 second (previous default)
895 # if QUIET is set make the kernel less chatty
896 [ -n "$QUIET" ] && echo '0' > /proc/sys/kernel/printk
900 # if QUIET is set make the kernel less chatty
901 [ -n "$QUIET" ] && echo '6' > /proc/sys/kernel/printk
906 if [ "${CDROOT}" = '1' ]
908 if [ -x /${NEW_ROOT}/mnt/cdrom/cdupdate.sh ]
910 good_msg "Running cdupdate.sh"
911 ${NEW_ROOT}/mnt/cdrom/cdupdate.sh
914 bad_msg "Executing cdupdate.sh failed!"
918 good_msg 'No cdupdate.sh script found, skipping...'
926 [ -z "$1" ] && device="${REAL_ROOT}" || device="$1"
927 [ -z "${device}" ] && return # LiveCD
929 if [ `echo ${device}|sed -e 's#\(luks:\)\?\(/dev/md\)[[:digit:]]\+#\2#'` = "/dev/md" ]
931 good_msg 'Detected real_root as a md device. Setting up the device node...'
932 MD_NUMBER=`echo ${device}|sed -e 's#\(luks:\)\?/dev/md\([[:digit:]]\+\)#\2#'`
933 if [ ! -e /dev/md${MD_NUMBER} ]
935 mknod /dev/md${MD_NUMBER} b 9 ${MD_NUMBER} >/dev/null 2>&1
936 [ $? -ne 0 ] && bad_msg "Creation of /dev/md${MD_NUMBER} failed..."
938 mdstart ${MDPART} /dev/md${MD_NUMBER}
945 good_msg 'Starting debug shell as requested by "debug" option.'
946 good_msg 'Type "exit" to continue with normal bootup.'
947 [ -x /bin/sh ] && /bin/sh || /bin/ash
952 if [ -d /proc/suspend2 -o -d /sys/power/suspend2 -o -d /sys/power/tuxonice ]; then
960 # determine swap resume partition
961 local device=$(ls -lL "${REAL_RESUME}" | sed 's/\ */ /g' | cut -d \ -f 5-6 | sed 's/,\ */:/')
962 [ -f /sys/power/resume ] && echo "${device}" > /sys/power/resume
967 if grep "splash=" /proc/cmdline > /dev/null 2>&1; then
968 splash_theme=$(cat /proc/cmdline | sed 's/.*splash=/splash=/' | sed 's/ .*//' | sed 's/.*theme://' | sed 's/,.*//')
971 local tuxonice_userui_program="/sys/power/tuxonice/user_interface/program"
972 local tuxonice_do_resume="/sys/power/tuxonice/do_resume"
973 local tuxonice_resumedev="/sys/power/tuxonice/resume"
974 local tuxonice_replace_swsusp="/sys/power/tuxonice/replace_swsusp"
977 # Backward compatibility
979 if [ -e /sys/power/suspend2 ]; then
980 tuxonice_userui_program="/sys/power/suspend2/user_interface/program"
981 tuxonice_do_resume="/sys/power/suspend2/do_resume"
982 tuxonice_resumedev="/sys/power/suspend2/resume"
983 tuxonice_replace_swsusp="/sys/power/suspend2/replace_swsusp"
984 elif [ -e /proc/suspend2 ]; then
985 tuxonice_userui_program="/proc/suspend2/userui_program"
986 tuxonice_do_resume="/proc/suspend2/do_resume"
987 tuxonice_resumedev="/proc/suspend2/resume"
988 tuxonice_replace_swsusp="/proc/suspend2/replace_swsusp"
991 # if 'use_swsusp' is given, use swsusp instead
992 if grep "use_swsusp" /proc/cmdline > /dev/null 2>&1; then
993 echo 0 > ${tuxonice_replace_swsusp}
998 modules_scan tuxonice
1000 # we both configure tuxonice and activate resuming,
1001 # however the kernel will resume only if an image is found
1003 if ! grep suspend_noui /proc/cmdline > /dev/null 2>&1; then
1004 which suspend2ui_text > /dev/null 2>&1 && which suspend2ui_text > "${tuxonice_userui_program}"
1005 which tuxoniceui_text > /dev/null 2>&1 && which tuxoniceui_text > "${tuxonice_userui_program}"
1007 if [ -n "${splash_theme}" ]; then
1008 ln -s /etc/splash/${splash_theme} /etc/splash/suspend2
1009 ln -s /etc/splash/${splash_theme} /etc/splash/tuxonice
1011 which suspend2ui_fbsplash > /dev/null 2>&1 && which suspend2ui_fbsplash > "${tuxonice_userui_program}"
1012 which tuxoniceui_fbsplash > /dev/null 2>&1 && which tuxoniceui_fbsplash > "${tuxonice_userui_program}"
1016 echo "${REAL_RESUME}" > "${tuxonice_resumedev}"
1017 echo > "${tuxonice_do_resume}"
1021 CDROM="${NEW_ROOT}/mnt/cdrom"
1022 for loop in ${LOOPS}
1024 if [ -e "${CDROM}""${loop}" ]
1032 LOOPTYPE="${LOOP##*.}"
1033 [ "${LOOPTYPE}" == "loop" ] && LOOPTYPE="normal"
1034 [ "${LOOP}" == "/zisofs" ] && LOOPTYPE="${LOOP#/}"
1035 [ -z "${LOOPTYPE}" ] && LOOPTYPE="noloop"
1039 echo $(( $(hexdump -n 4 -s $((316 + 12 * $2)) -e '"%i"' $1) * 512))
1045 if [ "${USE_UNIONFS_NORMAL}" = '1' ]
1047 # Directory used for rw changes in union mount filesystem
1052 # CHANGES=$MEMORY/unionfs_changes/default
1054 # CHANGES=$MEMORY/unionfs_changes/$UID
1057 # mkdir -p ${MEMORY}
1059 good_msg "Loading fuse module"
1060 modprobe fuse > /dev/null 2>&1
1061 # if [ -n "${UNIONFS}" ]
1063 # CHANGESDEV=${UNIONFS}
1064 # good_msg "mounting $CHANGESDEV to $MEMORY for unionfs support"
1065 # mount -t auto $CHANGESDEV $MEMORY
1066 # # mount tmpfs only in the case when changes= boot parameter was
1067 # # empty or we were not able to mount the storage device
1069 # if [ ${ret} -ne 0 ]
1071 # bad_msg "mount of $CHANGESDEV failed falling back to ramdisk based unionfs"
1072 # mount -t tmpfs tmpfs $MEMORY
1074 # if [ "${CDROOT}" -eq '1' -a ! -f ${MEMORY}/livecd.unionfs ]
1077 # bad_msg "failed to find livecd.unionfs file on $CHANGESDEV"
1078 # bad_msg "create a livecd.unionfs file on this device if you wish to use it for unionfs"
1079 # bad_msg "falling back to ramdisk based unionfs for safety"
1080 # mount -t tmpfs tmpfs $MEMORY
1083 # good_msg "Mounting ramdisk to $MEMORY for unionfs support..."
1084 # mount -t tmpfs tmpfs $MEMORY
1090 # mount -t unionfs -o dirs=$CHANGES=rw unionfs ${UNION}
1091 good_msg "Creating union mount"
1092 unionfs -o allow_other,cow,noinitgroups,suid,dev,default_permissions,use_ino ${rw_dir}=RW:${ro_dir}=RO ${UNION} 2>/dev/null
1096 bad_msg "Can't setup union mount!"
1097 USE_UNIONFS_NORMAL=0
1100 USE_UNIONFS_NORMAL=0