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 # Use devtmpfs if enabled in kernel,
311 # else tmpfs. Always run mdev just in case
313 if grep -qs devtmpfs /proc/filesystems ; then
317 # Options copied from /etc/init.d/udev-mount, should probably be kept in sync
318 mount -t $devfs -o "exec,nosuid,mode=0755,size=10M" udev /dev
320 # http://git.busybox.net/busybox/plain/docs/mdev.txt
322 mount -t devpts devpts /dev/pts
328 # If last command failed send error message and fall back to a shell
329 if [ "$retcode" != '0' ]
332 error_string="${error_string:-run command}"
333 bad_msg 'Failed to $1; failing back to the shell...'
339 # msg functions arguments
345 msg_string="${msg_string:-...}"
346 [ "$2" != 1 ] && echo -e "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
351 msg_string="${msg_string:-...}"
354 splash 'verbose' > /dev/null &
355 echo -e "${BAD}!!${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
361 msg_string="${msg_string:-...}"
362 [ "$2" != 1 ] && echo -e "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
366 if [ "${CRYPT_SILENT}" = '1' ]
368 eval $1 >/dev/null 2>/dev/null
370 splash 'verbose' > /dev/null &
374 splash set_msg 'Disk unlocked.'
380 # $1 = variable whose value is the path (examples: "REAL_ROOT",
383 # $3 = optional explanations for failure
385 eval local oldvalue='$'${1}
387 [ \( $# != 2 \) -a \( $# != 3 \) ] && \
388 bad_msg "Bad invocation of function whereis, please file a bug \
389 report with this message" && exit 1
390 [ -n "${3}" ] && local explnt=" or : ${3}" || local explnt="."
392 bad_msg "Could not find the ${2} in ${oldvalue}${explnt}"
393 echo ' Please specify another value or: press Enter for the same, type "shell" for a shell, or "q" to skip...'
394 echo -n "${2}(${oldvalue}) :: "
396 case `eval echo '$'${1}` in
398 eval ${1}'='${oldvalue}
399 warn_msg "Skipping step, this will likely cause a boot failure."
403 eval ${1}'='${oldvalue}
404 echo "To leave and try again just press <Ctrl>+D"
408 eval ${1}'='${oldvalue}
414 if [ "${KV_2_6_OR_GREATER}" ]
416 echo /sbin/mdev > /proc/sys/kernel/hotplug
421 # slowusb already set?
422 if [ "${DO_slowusb}" = "1" ]
427 local usb_storage_dir="/sys/bus/usb/drivers/usb-storage"
428 if [ ! -d "${usb_storage_dir}" ]
430 # no automated slowusb required. no usb-storage devices attached.
433 for x in "${usb_storage_dir}"/*
435 [ -d "${x}" ] && [ "${x}" != "${usb_storage_dir}/module" ] \
436 && { DO_slowusb="1" ; break ; }
441 if [ "${KV_2_6_OR_GREATER}" ]
444 good_msg 'Activating mdev'
451 # Scan CMDLINE for any "doscsi" or "noscsi"-type arguments
459 if [ "${y}" = "do${x}" ]
461 MY_HWOPTS="${MY_HWOPTS} $x"
462 elif [ "${y}" = "no${x}" ]
464 MY_HWOPTS="`echo ${MY_HWOPTS} | sed -e \"s/${x}//g\" -`"
466 if [ "$(echo ${y} | cut -b -7)" = "keymap=" ]
468 MY_HWOPTS="${MY_HWOPTS} dokeymap"
473 # Shouldnt need to sort this as the following loop should figure out the
474 # duplicates and strip them out
475 #MY_HWOPTS=`echo ${MY_HWOPTS}| sort`
477 for x in ${MY_HWOPTS}
480 for y in ${TMP_HWOPTS}
482 if [ "${y}" = "${x}" ]
487 TMP_HWOPTS="${TMP_HWOPTS} ${x}"
488 eval DO_`echo ${x} | sed 's/-//'`=1
491 MY_HWOPTS=${TMP_HWOPTS}
495 # Load modules listed in MY_HWOPTS if /lib/modules exists for the running
497 if [ -d "/lib/modules/${KV}" ]
499 good_msg 'Loading modules'
500 # Load appropriate kernel modules
501 for modules in $MY_HWOPTS
503 modules_scan $modules
506 good_msg 'Skipping module load; no modules in the ramdisk!'
511 if [ "${DO_keymap}" ]
513 if [ ! -e /dev/vc/0 -a ! -e /dev/tty0 ]
516 mount -o bind ${NEW_ROOT}/dev /dev
518 [ ! -e /dev/tty0 ] && ln -s /dev/tty1 /dev/tty0
520 [ -f /lib/keymaps/keymapList ] && chooseKeymap
522 [ "${DEVBIND}" = '1' ] && umount /dev
524 if [ -e /etc/sysconfig/keyboard -a "${CDROOT}" = '1' ]
526 mkdir -p ${NEW_ROOT}/etc/sysconfig/
527 cp /etc/sysconfig/keyboard ${NEW_ROOT}/etc/sysconfig/keyboard
533 good_msg "Loading keymaps"
534 if [ -z "${keymap}" ]
536 splash 'verbose' > /dev/null &
537 cat /lib/keymaps/keymapList
538 read -t 10 -p '<< Load keymap (Enter for default): ' keymap
540 1|azerty) keymap=azerty ;;
543 4|br-a) keymap=br-a ;;
544 5|br-l) keymap=br-l ;;
547 8|croat) keymap=croat ;;
551 12|dvorak) keymap=dvorak ;;
573 34|sk-y) keymap=sk-y ;;
574 35|sk-z) keymap=sk-z ;;
575 36|slovene) keymap=slovene ;;
576 37|trf) keymap=trf ;;
577 38|trq) keymap=trq ;;
581 42|wangbe) keymap=wangbe ;;
584 if [ -e /lib/keymaps/${keymap}.map ]
586 good_msg "Loading the ''${keymap}'' keymap"
587 loadkmap < /lib/keymaps/${keymap}.map
589 # echo ${keymap} | egrep -e "[0-9]+" >/dev/null 2>&1
592 # xkeymap=`tail -n 7 /lib/keymaps/keymapList | grep ${keymap} | sed -r "s/.*\s+${keymap}\s+([a-z-]+).*/\1/g" | egrep -v 1`
594 mkdir -p /etc/sysconfig
595 # echo "XKEYBOARD=${xkeymap}" > /etc/sysconfig/keyboard
596 echo "XKEYBOARD=${keymap}" > /etc/sysconfig/keyboard
597 splash set_msg "Set keymap to ${keymap}"
598 elif [ -z "${keymap}" ]
601 good_msg "Keeping default keymap"
602 splash set_msg "Keeping default keymap"
604 bad_msg "Sorry, but keymap ''${keymap}'' is invalid!"
611 #good_msg 'Checking if volumes need to be started...'
613 # Here, we check for /dev/device-mapper, and if it exists, we setup a
614 # a symlink, which should hopefully fix bug #142775 and bug #147015
615 if [ -e /dev/device-mapper ] && [ ! -e /dev/mapper/control ]
618 ln -sf /dev/device-mapper /dev/mapper/control
621 if [ "${USE_MDADM}" = '1' ]
623 if [ ! -e '/etc/mdadm.conf' ]
625 echo "DEVICE /dev/sd[a-z]* /dev/hd[a-z]*" >/etc/mdadm.conf
626 /sbin/mdadm --examine --scan >>/etc/mdadm.conf
628 /sbin/mdadm --assemble --scan
631 if [ "${USE_DMRAID_NORMAL}" = '1' ]
633 if [ -e '/sbin/dmraid' ]
635 good_msg "Activating Device-Mapper RAID(s)"
636 if [ '${DMRAID_OPTS}' = '' ]
640 /sbin/dmraid -ay ${DMRAID_OPTS}
645 if [ "${USE_LVM_NORMAL}" = '1' ]
649 for dev in ${RAID_DEVICES}
651 setup_md_device "${dev}"
654 # This is needed for /bin/lvm to accept the following logic
655 lvm_commands="#! /bin/lvm"
657 # If there is a cahe, update it. Unbreak at least dmcrypt
658 [ -d /etc/lvm/cache ] && lvm_commands="${lvm_commands} \nvgscan"
660 # To activate volumegroups on all devices in the cache
661 lvm_commands="${lvm_commands} \nvgchange -ay --sysinit"
663 # And finally execute it all (/proc/... needed if lvm is compiled without readline)
664 good_msg "Scanning for and activating Volume Groups"
665 printf "%b\n" "${lvm_commands}" | /bin/lvm /proc/self/fd/0
667 # Disable EVMS since lvm is activated and they dont work together.
668 if [ "${USE_EVMS_NORMAL}" = '1' ]
670 bad_msg "Disabling EVMS Support because LVM started"
671 bad_msg "Do not add dolvm to the cmdline if this is not what you want"
672 bad_msg "LVM and EVMS do not work well together"
676 bad_msg "vgscan or vgchange not found: skipping LVM volume group activation!"
680 if [ "${USE_EVMS_NORMAL}" = '1' ]
682 if [ -e '/sbin/evms_activate' ]
684 good_msg "Activating EVMS"
692 if [ -n "${ISCSI_INITIATORNAME}" ] && [ -n "${ISCSI_TARGET}" ] && [ -n "${ISCSI_ADDRESS}" ]
694 good_msg "Activating iSCSI"
696 if [ "${ISCSI_TGPT}" ]
698 ADDITIONAL="${ADDITIONAL} -g ${ISCSI_TGPT}"
700 ADDITIONAL="${ADDITIONAL} -g 1"
703 if [ "${ISCSI_PORT}" ]
705 ADDITIONAL="${ADDITIONAL} -p ${ISCSI_PORT}"
708 if [ "${ISCSI_USERNAME}" ]
710 ADDITIONAL="${ADDITIONAL} -u ${ISCSI_USERNAME}"
713 if [ "${ISCSI_PASSWORD}" ]
715 ADDITIONAL="${ADDITIONAL} -w ${ISCSI_PASSWORD}"
718 if [ "${ISCSI_USERNAME_IN}" ]
720 ADDITIONAL="${ADDITIONAL} -U ${ISCSI_USERNAME_IN}"
723 if [ "${ISCSI_PASSWORD_IN}" ]
725 ADDITIONAL="${ADDITIONAL} -W ${ISCSI_PASSWORD_IN}"
728 if [ "${ISCSI_DEBUG}" ]
730 ADDITIONAL="${ADDITIONAL} -d ${ISCSI_DEBUG}"
733 iscsistart -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -a "${ISCSI_ADDRESS}" ${ADDITIONAL}
735 # let iscsid settle - otherwise mounting the iSCSI-disk will fail (very rarely, though)
742 # It is either the root or a swap, other devices are supported in the scripts provided with sys-fs/cryptsetup-luks
745 # please use 'tr' and this line, or remove it
746 # eval local TYPE=`uppercase $1`
757 eval local LUKS_DEVICE='"${CRYPT_'${TYPE}'}"' LUKS_NAME="$1" LUKS_KEY='"${CRYPT_'${TYPE}'_KEY}"' LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"'
758 local DEV_ERROR=0 KEY_ERROR=0 KEYDEV_ERROR=0
759 local mntkey="/mnt/key/" cryptsetup_options=''
761 [ ! -e /sbin/cryptsetup ] && bad_msg "The ramdisk does not support LUKS" && exit 1
765 # if crypt_silent=1 and some error occurs, enter shell quietly
766 if [ \( ${CRYPT_SILENT} -eq 1 \) -a \( \( \( ${DEV_ERROR} -eq 1 \) -o \( ${KEY_ERROR} -eq 1 \) \) -o \( ${KEYDEV_ERROR} -eq 1 \) \) ]
769 elif [ ${DEV_ERROR} -eq 1 ]
771 whereis "LUKS_DEVICE" "${LUKS_NAME}"
773 elif [ ${KEY_ERROR} -eq 1 ]
775 whereis "LUKS_KEY" "${LUKS_NAME} key"
777 elif [ ${KEYDEV_ERROR} -eq 1 ]
779 whereis "LUKS_KEYDEV" "${LUKS_NAME} key device"
782 case "${LUKS_DEVICE}" in
787 if [ "${retval}" -ne 0 ]; then
788 REAL_LUKS=`findfs "${LUKS_DEVICE}" 2>/dev/null`
792 if [ "$retval" -ne 0 ]; then
793 REAL_LUKS=`busybox findfs "${LUKS_DEVICE}" 2>/dev/null`
797 if [ "${retval}" -ne 0 ]; then
798 REAL_LUKS=`blkid -l -t "${LUKS_DEVICE}" | cut -d ":" -f 1 2>/dev/null`
802 if [ "${retval}" -eq 0 ] && [ -n "${REAL_LUKS}" ]; then
803 good_msg "Detected device ${REAL_LUKS}"
804 LUKS_DEVICE="${REAL_LUKS}"
809 setup_md_device ${LUKS_DEVICE}
810 cryptsetup isLuks ${LUKS_DEVICE}
813 bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" ${CRYPT_SILENT}
818 if [ -n "${LUKS_KEY}" ]
820 if [ ! -e "${mntkey}${LUKS_KEY}" ]
822 if [ -b "${LUKS_KEYDEV}" ]
823 then good_msg "Using key device ${LUKS_KEYDEV}." ${CRYPT_SILENT}
825 good_msg "Please insert removable device ${LUKS_KEYDEV} for ${LUKS_NAME}" ${CRYPT_SILENT}
826 # abort after 10 secs
828 while [ ${count} -gt 0 ]
832 if [ -b "${LUKS_KEYDEV}" ]
834 good_msg "Removable device ${LUKS_KEYDEV} detected." ${CRYPT_SILENT}
838 if [ ! -b "${LUKS_KEYDEV}" ]
840 eval CRYPT_${TYPE}_KEY=${LUKS_KEY}
842 eval LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"'
843 if [ ! -b "${LUKS_KEYDEV}" ]; then
845 bad_msg "Removable device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT}
848 # continue otherwise will mount keydev which is mounted by bootstrap
852 # At this point a device was recognized, now let's see if the key is there
853 [ ! -d "$mntkey" ] && mkdir -p ${mntkey} 2>/dev/null >/dev/null
855 mount -n -o ro ${LUKS_KEYDEV} ${mntkey} >/dev/null 2>/dev/null
859 bad_msg "Mounting of device ${LUKS_KEYDEV} failed." ${CRYPT_SILENT}
862 good_msg "Removable device ${LUKS_KEYDEV} mounted." ${CRYPT_SILENT}
865 if [ ! -e "${mntkey}${LUKS_KEY}" ]; then
866 umount -n ${mntkey} 2>/dev/null >/dev/null
869 bad_msg "Key {LUKS_KEY} on device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT}
874 # At this point a candidate key exists (either mounted before or not)
875 good_msg "${LUKS_KEY} on device ${LUKS_KEYDEV} found" ${CRYPT_SILENT}
876 if [ $(echo ${LUKS_KEY} | grep -o '.gpg$') = ".gpg" ] && [ -e /sbin/gpg ] ; then
877 [ -e /dev/tty ] && mv /dev/tty /dev/tty.org
879 cryptsetup_options="-d -"
880 gpg_cmd="/sbin/gpg --logger-file /dev/null --quiet --decrypt ${mntkey}${LUKS_KEY} |"
882 cryptsetup_options="-d ${mntkey}${LUKS_KEY}"
885 # At this point, keyfile or not, we're ready!
886 crypt_filter "${gpg_cmd}cryptsetup ${cryptsetup_options} luksOpen ${LUKS_DEVICE} ${LUKS_NAME}"
889 good_msg "LUKS device ${LUKS_DEVICE} opened" ${CRYPT_SILENT}
892 bad_msg "Failed to open LUKS device ${LUKS_DEVICE}" ${CRYPT_SILENT}
900 umount ${mntkey} 2>/dev/null >/dev/null
901 rmdir -p ${mntkey} 2>/dev/null >/dev/null
906 # if key is set but key device isn't, find it
908 [ -n "${CRYPT_ROOT_KEY}" ] && [ -z "${CRYPT_ROOT_KEYDEV}" ] \
909 && sleep 6 && bootstrapKey "ROOT"
911 if [ -n "${CRYPT_ROOT}" ]; then
913 if [ -n "${REAL_ROOT}" ]
918 REAL_ROOT="/dev/mapper/root"
922 # same for swap, but no need to sleep if root was unencrypted
923 [ -n "${CRYPT_SWAP_KEY}" ] && [ -z "${CRYPT_SWAP_KEYDEV}" ] \
924 && { [ -z "${CRYPT_ROOT}" ] && sleep 6; bootstrapKey "SWAP"; }
926 if [ -n "${CRYPT_SWAP}" ]; then
928 if [ -z "${REAL_RESUME}" ]
930 # Resume from swap as default
931 REAL_RESUME="/dev/mapper/swap"
937 # Sleep a specific number of seconds if SDELAY is set
940 good_msg 'Waiting ${SDELAY} seconds...'
943 good_msg 'Hint: Use parameter scandelay[=seconds] if you need waiting here'
948 # if QUIET is set make the kernel less chatty
949 [ -n "$QUIET" ] && echo '0' > /proc/sys/kernel/printk
953 # if QUIET is set make the kernel less chatty
954 [ -n "$QUIET" ] && echo '6' > /proc/sys/kernel/printk
959 if [ "${CDROOT}" = '1' ]
961 if [ -x /${NEW_ROOT}/mnt/cdrom/cdupdate.sh ]
963 good_msg "Running cdupdate.sh"
964 ${NEW_ROOT}/mnt/cdrom/cdupdate.sh
967 bad_msg "Executing cdupdate.sh failed!"
971 good_msg 'No cdupdate.sh script found, skipping...'
977 # start BTRFS volume detection, if available
978 [ -x /sbin/btrfsctl ] && /sbin/btrfsctl -a
984 [ -z "$1" ] && device="${REAL_ROOT}" || device="$1"
985 [ -z "${device}" ] && return # LiveCD
987 if [ `echo ${device}|sed -e 's#\(luks:\)\?\(/dev/md\)[[:digit:]]\+#\2#'` = "/dev/md" ]
989 good_msg 'Detected real_root as a md device. Setting up the device node...'
990 MD_NUMBER=`echo ${device}|sed -e 's#\(luks:\)\?/dev/md\([[:digit:]]\+\)#\2#'`
991 if [ ! -e /dev/md${MD_NUMBER} ]
993 mknod /dev/md${MD_NUMBER} b 9 ${MD_NUMBER} >/dev/null 2>&1
994 [ $? -ne 0 ] && bad_msg "Creation of /dev/md${MD_NUMBER} failed..."
996 mdstart ${MDPART} /dev/md${MD_NUMBER}
1003 good_msg 'Starting debug shell as requested by "debug" option.'
1004 good_msg 'Type "exit" to continue with normal bootup.'
1005 [ -x /bin/sh ] && /bin/sh || /bin/ash
1010 if [ -d /proc/suspend2 -o -d /sys/power/suspend2 -o -d /sys/power/tuxonice ]; then
1018 # determine swap resume partition
1019 local device=$(ls -lL "${REAL_RESUME}" | sed 's/\ */ /g' | cut -d \ -f 5-6 | sed 's/,\ */:/')
1020 [ -f /sys/power/resume ] && echo "${device}" > /sys/power/resume
1025 if grep "splash=" /proc/cmdline > /dev/null 2>&1; then
1026 splash_theme=$(cat /proc/cmdline | sed 's/.*splash=/splash=/' | sed 's/ .*//' | sed 's/.*theme://' | sed 's/,.*//')
1029 local tuxonice_userui_program="/sys/power/tuxonice/user_interface/program"
1030 local tuxonice_do_resume="/sys/power/tuxonice/do_resume"
1031 local tuxonice_resumedev="/sys/power/tuxonice/resume"
1032 local tuxonice_replace_swsusp="/sys/power/tuxonice/replace_swsusp"
1035 # Backward compatibility
1037 if [ -e /sys/power/suspend2 ]; then
1038 tuxonice_userui_program="/sys/power/suspend2/user_interface/program"
1039 tuxonice_do_resume="/sys/power/suspend2/do_resume"
1040 tuxonice_resumedev="/sys/power/suspend2/resume"
1041 tuxonice_replace_swsusp="/sys/power/suspend2/replace_swsusp"
1042 elif [ -e /proc/suspend2 ]; then
1043 tuxonice_userui_program="/proc/suspend2/userui_program"
1044 tuxonice_do_resume="/proc/suspend2/do_resume"
1045 tuxonice_resumedev="/proc/suspend2/resume"
1046 tuxonice_replace_swsusp="/proc/suspend2/replace_swsusp"
1049 # if 'use_swsusp' is given, use swsusp instead
1050 if grep "use_swsusp" /proc/cmdline > /dev/null 2>&1; then
1051 echo 0 > ${tuxonice_replace_swsusp}
1056 modules_scan tuxonice
1058 # we both configure tuxonice and activate resuming,
1059 # however the kernel will resume only if an image is found
1061 if ! grep suspend_noui /proc/cmdline > /dev/null 2>&1; then
1062 which suspend2ui_text > /dev/null 2>&1 && which suspend2ui_text > "${tuxonice_userui_program}"
1063 which tuxoniceui_text > /dev/null 2>&1 && which tuxoniceui_text > "${tuxonice_userui_program}"
1065 if [ -n "${splash_theme}" ]; then
1066 ln -s /etc/splash/${splash_theme} /etc/splash/suspend2
1067 ln -s /etc/splash/${splash_theme} /etc/splash/tuxonice
1069 which suspend2ui_fbsplash > /dev/null 2>&1 && which suspend2ui_fbsplash > "${tuxonice_userui_program}"
1070 which tuxoniceui_fbsplash > /dev/null 2>&1 && which tuxoniceui_fbsplash > "${tuxonice_userui_program}"
1074 echo "${REAL_RESUME}" > "${tuxonice_resumedev}"
1075 echo > "${tuxonice_do_resume}"
1079 CDROM="${NEW_ROOT}/mnt/cdrom"
1080 for loop in ${LOOPS}
1082 if [ -e "${CDROM}""${loop}" ]
1090 LOOPTYPE="${LOOP##*.}"
1091 [ "${LOOPTYPE}" == "loop" ] && LOOPTYPE="normal"
1092 [ "${LOOP}" == "/zisofs" ] && LOOPTYPE="${LOOP#/}"
1093 [ -z "${LOOPTYPE}" ] && LOOPTYPE="noloop"
1097 echo $(( $(hexdump -n 4 -s $((316 + 12 * $2)) -e '"%i"' $1) * 512))
1103 if [ "${USE_UNIONFS_NORMAL}" = '1' ]
1105 # Directory used for rw changes in union mount filesystem
1110 # CHANGES=$MEMORY/unionfs_changes/default
1112 # CHANGES=$MEMORY/unionfs_changes/$UID
1115 # mkdir -p ${MEMORY}
1117 good_msg "Loading fuse module"
1118 modprobe fuse > /dev/null 2>&1
1119 # if [ -n "${UNIONFS}" ]
1121 # CHANGESDEV=${UNIONFS}
1122 # good_msg "mounting $CHANGESDEV to $MEMORY for unionfs support"
1123 # mount -t auto $CHANGESDEV $MEMORY
1124 # # mount tmpfs only in the case when changes= boot parameter was
1125 # # empty or we were not able to mount the storage device
1127 # if [ ${ret} -ne 0 ]
1129 # bad_msg "mount of $CHANGESDEV failed falling back to ramdisk based unionfs"
1130 # mount -t tmpfs tmpfs $MEMORY
1132 # if [ "${CDROOT}" -eq '1' -a ! -f ${MEMORY}/livecd.unionfs ]
1135 # bad_msg "failed to find livecd.unionfs file on $CHANGESDEV"
1136 # bad_msg "create a livecd.unionfs file on this device if you wish to use it for unionfs"
1137 # bad_msg "falling back to ramdisk based unionfs for safety"
1138 # mount -t tmpfs tmpfs $MEMORY
1141 # good_msg "Mounting ramdisk to $MEMORY for unionfs support..."
1142 # mount -t tmpfs tmpfs $MEMORY
1148 # mount -t unionfs -o dirs=$CHANGES=rw unionfs ${UNION}
1149 good_msg "Creating union mount"
1150 unionfs -o allow_other,cow,noinitgroups,suid,dev,default_permissions,use_ino ${rw_dir}=RW:${ro_dir}=RO ${UNION} 2>/dev/null
1154 bad_msg "Can't setup union mount!"
1155 USE_UNIONFS_NORMAL=0
1158 USE_UNIONFS_NORMAL=0