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 \
319 || bad_msg "Failed to mount /dev as ${devfs}"
321 # http://git.busybox.net/busybox/plain/docs/mdev.txt
323 mount -t devpts devpts /dev/pts || bad_msg "Failed to mount /dev/pts"
324 mdev -s || bad_msg "Failed to receive dynamic updates from mdev"
329 # If last command failed send error message and fall back to a shell
330 if [ "$retcode" != '0' ]
333 error_string="${error_string:-run command}"
334 bad_msg 'Failed to $1; failing back to the shell...'
340 # msg functions arguments
346 msg_string="${msg_string:-...}"
347 [ "$2" != 1 ] && echo -e "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
352 msg_string="${msg_string:-...}"
355 splash 'verbose' > /dev/null &
356 echo -e "${BAD}!!${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
362 msg_string="${msg_string:-...}"
363 [ "$2" != 1 ] && echo -e "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
367 if [ "${CRYPT_SILENT}" = '1' ]
369 eval $1 >/dev/null 2>/dev/null
371 splash 'verbose' > /dev/null &
375 splash set_msg 'Disk unlocked.'
381 # $1 = variable whose value is the path (examples: "REAL_ROOT",
384 # $3 = optional explanations for failure
386 eval local oldvalue='$'${1}
388 [ \( $# != 2 \) -a \( $# != 3 \) ] && \
389 bad_msg "Bad invocation of function whereis, please file a bug \
390 report with this message" && exit 1
391 [ -n "${3}" ] && local explnt=" or : ${3}" || local explnt="."
393 bad_msg "Could not find the ${2} in ${oldvalue}${explnt}"
394 echo ' Please specify another value or: press Enter for the same, type "shell" for a shell, or "q" to skip...'
395 echo -n "${2}(${oldvalue}) :: "
397 case `eval echo '$'${1}` in
399 eval ${1}'='${oldvalue}
400 warn_msg "Skipping step, this will likely cause a boot failure."
404 eval ${1}'='${oldvalue}
405 echo "To leave and try again just press <Ctrl>+D"
409 eval ${1}'='${oldvalue}
415 if [ "${KV_2_6_OR_GREATER}" ]
417 echo /sbin/mdev > /proc/sys/kernel/hotplug
422 # slowusb already set?
423 if [ "${DO_slowusb}" = "1" ]
428 local usb_storage_dir="/sys/bus/usb/drivers/usb-storage"
429 if [ ! -d "${usb_storage_dir}" ]
431 # no automated slowusb required. no usb-storage devices attached.
434 for x in "${usb_storage_dir}"/*
436 [ -d "${x}" ] && [ "${x}" != "${usb_storage_dir}/module" ] \
437 && { DO_slowusb="1" ; break ; }
442 if [ "${KV_2_6_OR_GREATER}" ]
445 good_msg 'Activating mdev'
452 # Scan CMDLINE for any "doscsi" or "noscsi"-type arguments
460 if [ "${y}" = "do${x}" ]
462 MY_HWOPTS="${MY_HWOPTS} $x"
463 elif [ "${y}" = "no${x}" ]
465 MY_HWOPTS="`echo ${MY_HWOPTS} | sed -e \"s/${x}//g\" -`"
467 if [ "$(echo ${y} | cut -b -7)" = "keymap=" ]
469 MY_HWOPTS="${MY_HWOPTS} keymap"
474 # Shouldnt need to sort this as the following loop should figure out the
475 # duplicates and strip them out
476 #MY_HWOPTS=`echo ${MY_HWOPTS}| sort`
478 for x in ${MY_HWOPTS}
481 for y in ${TMP_HWOPTS}
483 if [ "${y}" = "${x}" ]
488 TMP_HWOPTS="${TMP_HWOPTS} ${x}"
489 eval DO_`echo ${x} | sed 's/-//'`=1
492 MY_HWOPTS=${TMP_HWOPTS}
496 # Load modules listed in MY_HWOPTS if /lib/modules exists for the running
498 if [ -d "/lib/modules/${KV}" ]
500 good_msg 'Loading modules'
501 # Load appropriate kernel modules
502 for modules in $MY_HWOPTS
504 modules_scan $modules
507 good_msg 'Skipping module load; no modules in the ramdisk!'
512 if [ "${DO_keymap}" ]
514 if [ ! -e /dev/vc/0 -a ! -e /dev/tty0 ]
517 mount -o bind ${NEW_ROOT}/dev /dev
519 [ ! -e /dev/tty0 ] && ln -s /dev/tty1 /dev/tty0
521 [ -f /lib/keymaps/keymapList ] && chooseKeymap
523 [ "${DEVBIND}" = '1' ] && umount /dev
525 if [ -e /etc/sysconfig/keyboard -a "${CDROOT}" = '1' ]
527 mkdir -p ${NEW_ROOT}/etc/sysconfig/
528 cp /etc/sysconfig/keyboard ${NEW_ROOT}/etc/sysconfig/keyboard
534 good_msg "Loading keymaps"
535 if [ -z "${keymap}" ]
537 splash 'verbose' > /dev/null &
538 cat /lib/keymaps/keymapList
539 read -t 10 -p '<< Load keymap (Enter for default): ' keymap
541 1|azerty) keymap=azerty ;;
544 4|br-a) keymap=br-a ;;
545 5|br-l) keymap=br-l ;;
548 8|croat) keymap=croat ;;
552 12|dvorak) keymap=dvorak ;;
574 34|sk-y) keymap=sk-y ;;
575 35|sk-z) keymap=sk-z ;;
576 36|slovene) keymap=slovene ;;
577 37|trf) keymap=trf ;;
578 38|trq) keymap=trq ;;
582 42|wangbe) keymap=wangbe ;;
585 if [ -e /lib/keymaps/${keymap}.map ]
587 good_msg "Loading the ''${keymap}'' keymap"
588 loadkmap < /lib/keymaps/${keymap}.map
590 # echo ${keymap} | egrep -e "[0-9]+" >/dev/null 2>&1
593 # xkeymap=`tail -n 7 /lib/keymaps/keymapList | grep ${keymap} | sed -r "s/.*\s+${keymap}\s+([a-z-]+).*/\1/g" | egrep -v 1`
595 mkdir -p /etc/sysconfig
596 # echo "XKEYBOARD=${xkeymap}" > /etc/sysconfig/keyboard
597 echo "XKEYBOARD=${keymap}" > /etc/sysconfig/keyboard
598 splash set_msg "Set keymap to ${keymap}"
599 elif [ -z "${keymap}" ]
602 good_msg "Keeping default keymap"
603 splash set_msg "Keeping default keymap"
605 bad_msg "Sorry, but keymap ''${keymap}'' is invalid!"
612 #good_msg 'Checking if volumes need to be started...'
614 # Here, we check for /dev/device-mapper, and if it exists, we setup a
615 # a symlink, which should hopefully fix bug #142775 and bug #147015
616 if [ -e /dev/device-mapper ] && [ ! -e /dev/mapper/control ]
619 ln -sf /dev/device-mapper /dev/mapper/control
622 if [ "${USE_MDADM}" = '1' ]
624 /sbin/mdadm --assemble --scan
627 if [ "${USE_DMRAID_NORMAL}" = '1' ]
629 if [ -e '/sbin/dmraid' ]
631 good_msg "Activating Device-Mapper RAID(s)"
632 if [ '${DMRAID_OPTS}' = '' ]
636 /sbin/dmraid -ay ${DMRAID_OPTS}
641 if [ "${USE_LVM_NORMAL}" = '1' ]
645 for dev in ${RAID_DEVICES}
647 setup_md_device "${dev}"
650 # This is needed for /bin/lvm to accept the following logic
651 lvm_commands="#! /bin/lvm"
653 # If there is a cahe, update it. Unbreak at least dmcrypt
654 [ -d /etc/lvm/cache ] && lvm_commands="${lvm_commands} \nvgscan"
656 # To activate volumegroups on all devices in the cache
657 lvm_commands="${lvm_commands} \nvgchange -ay --sysinit"
659 # And finally execute it all (/proc/... needed if lvm is compiled without readline)
660 good_msg "Scanning for and activating Volume Groups"
661 printf "%b\n" "${lvm_commands}" | /bin/lvm /proc/self/fd/0
663 # Disable EVMS since lvm is activated and they dont work together.
664 if [ "${USE_EVMS_NORMAL}" = '1' ]
666 bad_msg "Disabling EVMS Support because LVM started"
667 bad_msg "Do not add dolvm to the cmdline if this is not what you want"
668 bad_msg "LVM and EVMS do not work well together"
672 bad_msg "vgscan or vgchange not found: skipping LVM volume group activation!"
676 if [ "${USE_EVMS_NORMAL}" = '1' ]
678 if [ -e '/sbin/evms_activate' ]
680 good_msg "Activating EVMS"
688 if [ ! -n "${ISCSI_NOIBFT}" ]
690 good_msg "Activating iSCSI via iBFT"
694 if [ -n "${ISCSI_INITIATORNAME}" ] && [ -n "${ISCSI_TARGET}" ] && [ -n "${ISCSI_ADDRESS}" ]
696 good_msg "Activating iSCSI via cmdline"
698 if [ "${ISCSI_TGPT}" ]
700 ADDITIONAL="${ADDITIONAL} -g ${ISCSI_TGPT}"
702 ADDITIONAL="${ADDITIONAL} -g 1"
705 if [ "${ISCSI_PORT}" ]
707 ADDITIONAL="${ADDITIONAL} -p ${ISCSI_PORT}"
710 if [ "${ISCSI_USERNAME}" ]
712 ADDITIONAL="${ADDITIONAL} -u ${ISCSI_USERNAME}"
715 if [ "${ISCSI_PASSWORD}" ]
717 ADDITIONAL="${ADDITIONAL} -w ${ISCSI_PASSWORD}"
720 if [ "${ISCSI_USERNAME_IN}" ]
722 ADDITIONAL="${ADDITIONAL} -U ${ISCSI_USERNAME_IN}"
725 if [ "${ISCSI_PASSWORD_IN}" ]
727 ADDITIONAL="${ADDITIONAL} -W ${ISCSI_PASSWORD_IN}"
730 if [ "${ISCSI_DEBUG}" ]
732 ADDITIONAL="${ADDITIONAL} -d ${ISCSI_DEBUG}"
735 iscsistart -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -a "${ISCSI_ADDRESS}" ${ADDITIONAL}
737 # let iscsid settle - otherwise mounting the iSCSI-disk will fail (very rarely, though)
744 # It is either the root or a swap, other devices are supported in the scripts provided with sys-fs/cryptsetup-luks
747 # please use 'tr' and this line, or remove it
748 # eval local TYPE=`uppercase $1`
759 eval local LUKS_DEVICE='"${CRYPT_'${TYPE}'}"' LUKS_NAME="$1" LUKS_KEY='"${CRYPT_'${TYPE}'_KEY}"' LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"'
760 local DEV_ERROR=0 KEY_ERROR=0 KEYDEV_ERROR=0
761 local mntkey="/mnt/key/" cryptsetup_options=''
763 [ ! -e /sbin/cryptsetup ] && bad_msg "The ramdisk does not support LUKS" && exit 1
767 # if crypt_silent=1 and some error occurs, enter shell quietly
768 if [ \( ${CRYPT_SILENT} -eq 1 \) -a \( \( \( ${DEV_ERROR} -eq 1 \) -o \( ${KEY_ERROR} -eq 1 \) \) -o \( ${KEYDEV_ERROR} -eq 1 \) \) ]
771 elif [ ${DEV_ERROR} -eq 1 ]
773 whereis "LUKS_DEVICE" "${LUKS_NAME}"
775 elif [ ${KEY_ERROR} -eq 1 ]
777 whereis "LUKS_KEY" "${LUKS_NAME} key"
779 elif [ ${KEYDEV_ERROR} -eq 1 ]
781 whereis "LUKS_KEYDEV" "${LUKS_NAME} key device"
784 case "${LUKS_DEVICE}" in
789 if [ "${retval}" -ne 0 ]; then
790 REAL_LUKS=`findfs "${LUKS_DEVICE}" 2>/dev/null`
794 if [ "$retval" -ne 0 ]; then
795 REAL_LUKS=`busybox findfs "${LUKS_DEVICE}" 2>/dev/null`
799 if [ "${retval}" -ne 0 ]; then
800 REAL_LUKS=`blkid -l -t "${LUKS_DEVICE}" | cut -d ":" -f 1 2>/dev/null`
804 if [ "${retval}" -eq 0 ] && [ -n "${REAL_LUKS}" ]; then
805 good_msg "Detected device ${REAL_LUKS}"
806 LUKS_DEVICE="${REAL_LUKS}"
811 setup_md_device ${LUKS_DEVICE}
812 cryptsetup isLuks ${LUKS_DEVICE}
815 bad_msg "The LUKS device ${LUKS_DEVICE} does not contain a LUKS header" ${CRYPT_SILENT}
820 if [ -n "${LUKS_KEY}" ]
822 if [ ! -e "${mntkey}${LUKS_KEY}" ]
824 if [ -b "${LUKS_KEYDEV}" ]
825 then good_msg "Using key device ${LUKS_KEYDEV}." ${CRYPT_SILENT}
827 good_msg "Please insert removable device ${LUKS_KEYDEV} for ${LUKS_NAME}" ${CRYPT_SILENT}
828 # abort after 10 secs
830 while [ ${count} -gt 0 ]
834 if [ -b "${LUKS_KEYDEV}" ]
836 good_msg "Removable device ${LUKS_KEYDEV} detected." ${CRYPT_SILENT}
840 if [ ! -b "${LUKS_KEYDEV}" ]
842 eval CRYPT_${TYPE}_KEY=${LUKS_KEY}
844 eval LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"'
845 if [ ! -b "${LUKS_KEYDEV}" ]; then
847 bad_msg "Removable device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT}
850 # continue otherwise will mount keydev which is mounted by bootstrap
854 # At this point a device was recognized, now let's see if the key is there
855 [ ! -d "$mntkey" ] && mkdir -p ${mntkey} 2>/dev/null >/dev/null
857 mount -n -o ro ${LUKS_KEYDEV} ${mntkey} >/dev/null 2>/dev/null
861 bad_msg "Mounting of device ${LUKS_KEYDEV} failed." ${CRYPT_SILENT}
864 good_msg "Removable device ${LUKS_KEYDEV} mounted." ${CRYPT_SILENT}
867 if [ ! -e "${mntkey}${LUKS_KEY}" ]; then
868 umount -n ${mntkey} 2>/dev/null >/dev/null
871 bad_msg "Key {LUKS_KEY} on device ${LUKS_KEYDEV} not found." ${CRYPT_SILENT}
876 # At this point a candidate key exists (either mounted before or not)
877 good_msg "${LUKS_KEY} on device ${LUKS_KEYDEV} found" ${CRYPT_SILENT}
878 if [ $(echo ${LUKS_KEY} | grep -o '.gpg$') = ".gpg" ] && [ -e /sbin/gpg ] ; then
879 [ -e /dev/tty ] && mv /dev/tty /dev/tty.org
881 cryptsetup_options="-d -"
882 gpg_cmd="/sbin/gpg --logger-file /dev/null --quiet --decrypt ${mntkey}${LUKS_KEY} |"
884 cryptsetup_options="-d ${mntkey}${LUKS_KEY}"
887 # At this point, keyfile or not, we're ready!
888 crypt_filter "${gpg_cmd}cryptsetup ${cryptsetup_options} luksOpen ${LUKS_DEVICE} ${LUKS_NAME}"
891 good_msg "LUKS device ${LUKS_DEVICE} opened" ${CRYPT_SILENT}
894 bad_msg "Failed to open LUKS device ${LUKS_DEVICE}" ${CRYPT_SILENT}
902 umount ${mntkey} 2>/dev/null >/dev/null
903 rmdir -p ${mntkey} 2>/dev/null >/dev/null
908 # if key is set but key device isn't, find it
910 [ -n "${CRYPT_ROOT_KEY}" ] && [ -z "${CRYPT_ROOT_KEYDEV}" ] \
911 && sleep 6 && bootstrapKey "ROOT"
913 if [ -n "${CRYPT_ROOT}" ]; then
915 if [ -n "${REAL_ROOT}" ]
920 REAL_ROOT="/dev/mapper/root"
924 # same for swap, but no need to sleep if root was unencrypted
925 [ -n "${CRYPT_SWAP_KEY}" ] && [ -z "${CRYPT_SWAP_KEYDEV}" ] \
926 && { [ -z "${CRYPT_ROOT}" ] && sleep 6; bootstrapKey "SWAP"; }
928 if [ -n "${CRYPT_SWAP}" ]; then
930 if [ -z "${REAL_RESUME}" ]
932 # Resume from swap as default
933 REAL_RESUME="/dev/mapper/swap"
939 # Sleep a specific number of seconds if SDELAY is set
942 good_msg 'Waiting ${SDELAY} seconds...'
945 good_msg 'Hint: Use parameter scandelay[=seconds] if you need waiting here'
950 # if QUIET is set make the kernel less chatty
951 [ -n "$QUIET" ] && echo '0' > /proc/sys/kernel/printk
955 # if QUIET is set make the kernel less chatty
956 [ -n "$QUIET" ] && echo '6' > /proc/sys/kernel/printk
961 if [ "${CDROOT}" = '1' ]
963 if [ -x /${NEW_ROOT}/mnt/cdrom/cdupdate.sh ]
965 good_msg "Running cdupdate.sh"
966 ${NEW_ROOT}/mnt/cdrom/cdupdate.sh
969 bad_msg "Executing cdupdate.sh failed!"
973 good_msg 'No cdupdate.sh script found, skipping...'
979 # start BTRFS volume detection, if available
980 [ -x /sbin/btrfsctl ] && /sbin/btrfsctl -a
986 [ -z "$1" ] && device="${REAL_ROOT}" || device="$1"
987 [ -z "${device}" ] && return # LiveCD
989 if [ `echo ${device}|sed -e 's#\(luks:\)\?\(/dev/md\)[[:digit:]]\+#\2#'` = "/dev/md" ]
991 good_msg 'Detected real_root as a md device. Setting up the device node...'
992 MD_NUMBER=`echo ${device}|sed -e 's#\(luks:\)\?/dev/md\([[:digit:]]\+\)#\2#'`
993 if [ ! -e /dev/md${MD_NUMBER} ]
995 mknod /dev/md${MD_NUMBER} b 9 ${MD_NUMBER} >/dev/null 2>&1
996 [ $? -ne 0 ] && bad_msg "Creation of /dev/md${MD_NUMBER} failed..."
998 mdstart ${MDPART} /dev/md${MD_NUMBER}
1005 good_msg 'Starting debug shell as requested by "debug" option.'
1006 good_msg 'Type "exit" to continue with normal bootup.'
1007 [ -x /bin/sh ] && /bin/sh || /bin/ash
1012 if [ -d /proc/suspend2 -o -d /sys/power/suspend2 -o -d /sys/power/tuxonice ]; then
1020 # determine swap resume partition
1021 local device=$(ls -lL "${REAL_RESUME}" | sed 's/\ */ /g' | cut -d \ -f 5-6 | sed 's/,\ */:/')
1022 [ -f /sys/power/resume ] && echo "${device}" > /sys/power/resume
1027 if grep "splash=" /proc/cmdline > /dev/null 2>&1; then
1028 splash_theme=$(cat /proc/cmdline | sed 's/.*splash=/splash=/' | sed 's/ .*//' | sed 's/.*theme://' | sed 's/,.*//')
1031 local tuxonice_userui_program="/sys/power/tuxonice/user_interface/program"
1032 local tuxonice_do_resume="/sys/power/tuxonice/do_resume"
1033 local tuxonice_resumedev="/sys/power/tuxonice/resume"
1034 local tuxonice_replace_swsusp="/sys/power/tuxonice/replace_swsusp"
1037 # Backward compatibility
1039 if [ -e /sys/power/suspend2 ]; then
1040 tuxonice_userui_program="/sys/power/suspend2/user_interface/program"
1041 tuxonice_do_resume="/sys/power/suspend2/do_resume"
1042 tuxonice_resumedev="/sys/power/suspend2/resume"
1043 tuxonice_replace_swsusp="/sys/power/suspend2/replace_swsusp"
1044 elif [ -e /proc/suspend2 ]; then
1045 tuxonice_userui_program="/proc/suspend2/userui_program"
1046 tuxonice_do_resume="/proc/suspend2/do_resume"
1047 tuxonice_resumedev="/proc/suspend2/resume"
1048 tuxonice_replace_swsusp="/proc/suspend2/replace_swsusp"
1051 # if 'use_swsusp' is given, use swsusp instead
1052 if grep "use_swsusp" /proc/cmdline > /dev/null 2>&1; then
1053 echo 0 > ${tuxonice_replace_swsusp}
1058 modules_scan tuxonice
1060 # we both configure tuxonice and activate resuming,
1061 # however the kernel will resume only if an image is found
1063 if ! grep suspend_noui /proc/cmdline > /dev/null 2>&1; then
1064 which suspend2ui_text > /dev/null 2>&1 && which suspend2ui_text > "${tuxonice_userui_program}"
1065 which tuxoniceui_text > /dev/null 2>&1 && which tuxoniceui_text > "${tuxonice_userui_program}"
1067 if [ -n "${splash_theme}" ]; then
1068 ln -s /etc/splash/${splash_theme} /etc/splash/suspend2
1069 ln -s /etc/splash/${splash_theme} /etc/splash/tuxonice
1071 which suspend2ui_fbsplash > /dev/null 2>&1 && which suspend2ui_fbsplash > "${tuxonice_userui_program}"
1072 which tuxoniceui_fbsplash > /dev/null 2>&1 && which tuxoniceui_fbsplash > "${tuxonice_userui_program}"
1076 echo "${REAL_RESUME}" > "${tuxonice_resumedev}"
1077 echo > "${tuxonice_do_resume}"
1081 CDROM="${NEW_ROOT}/mnt/cdrom"
1082 for loop in ${LOOPS}
1084 if [ -e "${CDROM}""${loop}" ]
1092 LOOPTYPE="${LOOP##*.}"
1093 [ "${LOOPTYPE}" == "loop" ] && LOOPTYPE="normal"
1094 [ "${LOOP}" == "/zisofs" ] && LOOPTYPE="${LOOP#/}"
1095 [ -z "${LOOPTYPE}" ] && LOOPTYPE="noloop"
1099 echo $(( $(hexdump -n 4 -s $((316 + 12 * $2)) -e '"%i"' $1) * 512))
1105 if [ "${USE_UNIONFS_NORMAL}" = '1' ]
1107 # Directory used for rw changes in union mount filesystem
1112 # CHANGES=$MEMORY/unionfs_changes/default
1114 # CHANGES=$MEMORY/unionfs_changes/$UID
1117 # mkdir -p ${MEMORY}
1119 good_msg "Loading fuse module"
1120 modprobe fuse > /dev/null 2>&1
1121 # if [ -n "${UNIONFS}" ]
1123 # CHANGESDEV=${UNIONFS}
1124 # good_msg "mounting $CHANGESDEV to $MEMORY for unionfs support"
1125 # mount -t auto $CHANGESDEV $MEMORY
1126 # # mount tmpfs only in the case when changes= boot parameter was
1127 # # empty or we were not able to mount the storage device
1129 # if [ ${ret} -ne 0 ]
1131 # bad_msg "mount of $CHANGESDEV failed falling back to ramdisk based unionfs"
1132 # mount -t tmpfs tmpfs $MEMORY
1134 # if [ "${CDROOT}" -eq '1' -a ! -f ${MEMORY}/livecd.unionfs ]
1137 # bad_msg "failed to find livecd.unionfs file on $CHANGESDEV"
1138 # bad_msg "create a livecd.unionfs file on this device if you wish to use it for unionfs"
1139 # bad_msg "falling back to ramdisk based unionfs for safety"
1140 # mount -t tmpfs tmpfs $MEMORY
1143 # good_msg "Mounting ramdisk to $MEMORY for unionfs support..."
1144 # mount -t tmpfs tmpfs $MEMORY
1150 # mount -t unionfs -o dirs=$CHANGES=rw unionfs ${UNION}
1151 good_msg "Creating union mount"
1152 unionfs -o allow_other,cow,noinitgroups,suid,dev,default_permissions,use_ino ${rw_dir}=RW:${ro_dir}=RO ${UNION} 2>/dev/null
1156 bad_msg "Can't setup union mount!"
1157 USE_UNIONFS_NORMAL=0
1160 USE_UNIONFS_NORMAL=0