5 export PATH="/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
7 echo "/root/lib" >> /etc/ld.so.conf
8 echo "/root/usr/lib" >> /etc/ld.so.conf
10 mountpoint="/live/image"
11 LIVE_MEDIA_PATH="live"
13 root_persistence="live-rw"
14 home_persistence="home-rw"
15 root_snapshot_label="live-sn"
16 home_snapshot_label="home-sn"
19 USERFULLNAME="Live user"
22 mkdir -p "${mountpoint}"
25 # Create /etc/mtab for debug purpose and future syncs
36 [ -f /etc/live.conf ] && . /etc/live.conf
37 export USERNAME USERFULLNAME HOSTNAME
39 . /scripts/live-helpers
41 if [ ! -f /live.vars ]
50 for ARGUMENT in $(cat /proc/cmdline)
58 NOCONSOLEKEYBOARD="Yes"
65 NOLANGUAGESELECTOR="Yes"
69 NOPOWERMANAGEMENT="Yes"
70 NOPROGRAMCRASHES="Yes"
73 NOUPDATENOTIFIER="Yes"
79 export NOACCESSIBILITY NOAPPARMOR NOAPTCDROM NOAUTOLOGIN NOCONSOLEKEYBOARD NOFASTBOOT NOFSTAB NOGNOMEPANEL NOHOSTS NOJOCKEY NOKPERSONALIZER NOLANGUAGESELECTOR NOLOCALES NONETWORKING NOPOLKITCONF NOPOWERMANAGEMENT NOPROGRAMCRASHES NOSUDO NOTIMEZONE NOUPDATENOTIFIER NOUSER NOXAUTOCONFIG NOXAUTOLOGIN NOXSCREENSAVER
83 ACCESS="${ARGUMENT#access=}"
88 DEFCONSOLE="${ARGUMENT#*=}"
100 DEVICE="${ARGUMENT#ethdevice=}"
105 ETHDEVICE="${ARGUMENT#ethdevice=}"
110 ETHDEV_TIMEOUT="${ARGUMENT#ethdevice-timeout=}"
111 export ETHDEV_TIMEOUT
115 FETCH="${ARGUMENT#fetch=}"
120 FORCEPERSISTENTFSCK="Yes"
121 export FORCEPERSISTENTFSCK
125 HOOK="${ARGUMENT#hook=}"
130 FTPFS="${ARGUMENT#ftpfs=}"
135 HTTPFS="${ARGUMENT#httpfs=}"
140 HOSTNAME="${ARGUMENT#hostname=}"
142 export HOSTNAME LIVECONF
146 FROMISO="${ARGUMENT#*=}"
151 USERNAME="${ARGUMENT#username=}"
153 export USERNAME LIVECONF
157 USERFULLNAME="${ARGUMENT#userfullname=}"
159 export USERFULLNAME LIVECONF
168 INTEGRITY_CHECK="Yes"
169 export INTEGRITY_CHECK
173 STATICIP="${ARGUMENT#ip=}"
175 if [ -z "${STATICIP}" ]
183 keyb=*|kbd-chooser/method=*)
188 klayout=*|console-setup/layoutcode=*)
189 KLAYOUT="${ARGUMENT#*=}"
193 kvariant=*|console-setup/variantcode=*)
194 KVARIANT="${ARGUMENT#*=}"
198 kmodel=*|console-setup/modelcode=*)
199 KMODEL="${ARGUMENT#*=}"
204 KOPTIONS="${ARGUMENT#koptions=}"
213 live-media=*|bootfrom=*)
214 LIVE_MEDIA="${ARGUMENT#*=}"
218 live-media-encryption=*|encryption=*)
219 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
220 export LIVE_MEDIA_ENCRYPTION
224 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
225 export LIVE_MEDIA_OFFSET
229 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
230 export LIVE_MEDIA_PATH
233 live-media-timeout=*)
234 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
235 export LIVE_MEDIA_TIMEOUT
238 language=*|debian-installer/language=*)
239 language=${x#debian-installer/language=}
240 locale="$(lang2locale "$language")"
244 locale=*|debian-installer/locale=*)
245 LOCALE="${ARGUMENT#*=}"
250 MODULE="${ARGUMENT#module=}"
255 NETBOOT="${ARGUMENT#netboot=}"
260 NFSOPTS="${ARGUMENT#nfsopts=}"
265 NFS_COW="${ARGUMENT#nfscow=}"
270 NOACCESSIBILITY="Yes"
271 export NOACCESSIBILITY
295 NOCONSOLEKEYBOARD="Yes"
296 export NOCONSOLEKEYBOARD
320 NOKPERSONALIZER="Yes"
321 export NOKPERSONALIZER
325 NOLANGUAGESELECTOR="Yes"
326 export NOLANGUAGESELECTOR
340 NOPOWERMANAGEMENT="Yes"
341 export NOPOWERMANAGEMENT
345 NOPROGRAMCRASHES="Yes"
346 export NOPROGRAMCRASHES
365 NOUPDATENOTIFIER="Yes"
366 export NOUPDATENOTIFIER
381 export NOXSCREENSAVER
390 PERSISTENT="${ARGUMENT#persistent=}"
391 if [ -z "${PERSISTENT}" ]
399 PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
400 export PERSISTENT_PATH
403 persistent-subtext=*)
404 root_persistence="${root_persistence}-${ARGUMENT#persistent-subtext=}"
405 home_persistence="${home_persistence}-${ARGUMENT#persistent-subtext=}"
406 root_snapshot_label="${root_snapshot_label}-${ARGUMENT#persistent-subtext=}"
407 home_snapshot_label="${home_snapshot_label}-${ARGUMENT#persistent-subtext=}"
416 QUICKUSBMODULES="Yes"
417 export QUICKUSBMODULES
420 preseed/file=*|file=*)
421 LOCATION="${ARGUMENT#*=}"
431 location="${ARGUMENT#url=}"
433 mount -o bind /sys /root/sys
434 mount -o bind /proc /root/proc
435 mount -o bind /dev /root/dev
437 mkdir -p /root/var/run/network
438 [ "${NETBOOT}" ] || chroot /root dhclient eth0
439 chroot /root wget -P /tmp "${location}"
440 [ "${NETBOOT}" ] || chroot /root ifconfig eth0 down
446 LOCATION="/tmp/$(basename "${location}")"
450 question="${ARGUMENT%%=*}"
451 value="${ARGUMENT#*=}"
452 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
472 TIMEZONE="${ARGUMENT#timezone=}"
482 TODISK="${ARGUMENT#todisk=}"
493 MODULETORAM="${ARGUMENT#toram=}"
494 export TORAM MODULETORAM
508 SKIP_UNION_MOUNTS="Yes"
509 export SKIP_UNION_MOUNTS
513 ROOT="${ARGUMENT#root=}"
518 UNIONTYPE="${ARGUMENT#union=}"
523 UTC="${ARGUMENT#utc=}"
533 XDRIVER="${ARGUMENT#xdriver=}"
538 XVIDEOMODE="${ARGUMENT#xvideomode=}"
544 # sort of compatibility with netboot.h from linux docs
545 if [ -z "${NETBOOT}" ]
547 if [ "${ROOT}" = "/dev/nfs" ]
551 elif [ "${ROOT}" = "/dev/cifs" ]
558 if [ -z "${MODULE}" ]
564 if [ -z "${UNIONTYPE}" ]
575 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
577 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
579 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
591 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
597 uuid="$(cat /conf/uuid.conf)"
599 for try_uuid_file in "${path}/.disk/live-uuid"*
601 [ -e "${try_uuid_file}" ] || continue
603 try_uuid="$(cat "${try_uuid_file}")"
605 if [ "${uuid}" = "${try_uuid}" ]
614 get_backing_device ()
617 *.squashfs|*.ext2|*.ext3|*.ext4|*.jffs2)
618 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
626 panic "Unrecognized live filesystem: ${1}"
631 match_files_in_dir ()
633 # Does any files match pattern ${1} ?
636 if [ "$(echo ${pattern})" != "${pattern}" ]
644 mount_images_in_directory ()
651 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
652 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
653 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
654 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
655 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
656 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
658 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
659 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
661 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
667 sysfs_path="${1#/sys}"
669 if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-|platform-orion-ehci|platform-mmc|platform-mxsdhci|)"
672 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
684 copyto="${copyfrom}_swap"
686 if [ -z "${MODULETORAM}" ]
688 size=$(fs_size "" ${copyfrom}/${LIVE_MEDIA_PATH} "used")
690 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
692 if [ -f "${MODULETORAMFILE}" ]
694 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
696 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
701 if [ "${copytodev}" = "ram" ]
704 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
705 mount_options="-o size=${size}k"
710 # it should be a writable block device
711 if [ -b "${copytodev}" ]
715 fstype=$(get_fstype "${dev}")
716 freespace=$(fs_size "${dev}")
718 log_warning_msg "${copytodev} is not a block device."
723 if [ "${freespace}" -lt "${size}" ]
725 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
729 # begin copying (or uncompressing)
731 log_begin_msg "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
732 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
734 if [ "${extension}" = "tgz" ]
737 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
738 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
739 mount -r -o move "${copyto}" "${rootmnt}"
742 if [ -n "${MODULETORAMFILE}" ]
746 echo " * Copying $MODULETORAMFILE to RAM" 1>/dev/console
747 rsync -a --progress ${MODULETORAMFILE} ${copyto} 1>/dev/console # copy only the filesystem module
749 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
754 echo " * Copying whole medium to RAM" 1>/dev/console
755 rsync -a --progress ${copyfrom}/* ${copyto} 1>/dev/console # "cp -a" from busybox also copies hidden files
757 mkdir -p ${copyto}/${LIVE_MEDIA_PATH}
758 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH} # "cp -a" from busybox also copies hidden files
763 mount -r -o move ${copyto} ${copyfrom}
774 modprobe -q af_packet # For DHCP
779 # if ethdevice was not specified on the kernel command line
780 # make sure we try to get a working network configuration
781 # for *every* present network device (except for loopback of course)
782 if [ -z "$ETHDEVICE" ] ; then
783 echo "If you want to boot from a specific device use bootoption ethdevice=..."
784 for device in /sys/class/net/*; do
786 if [ "$dev" != "lo" ] ; then
787 ETHDEVICE="$ETHDEVICE $dev"
792 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
793 for device in $(echo $ETHDEVICE | sed 's/,/ /g') ; do
794 devlist="$devlist $device"
797 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
798 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
800 # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
801 # an endless loop; iff execution fails give it two further tries, that's
802 # why we use '$devlist $devlist $devlist' for the other for loop
803 for dev in $devlist $devlist $devlist ; do
804 echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
805 ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
807 sleep "$ETHDEV_TIMEOUT" ; sleep 1
808 if [ -r /proc/"$jobid"/status ] ; then
809 echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
813 # if configuration of device worked we should have an assigned
814 # IP address, iff so let's use the according as $DEVICE for later usage
815 # simple and primitive approach which seems to work fine
816 if ifconfig $dev | grep -q 'inet.*addr:' ; then
822 # source relevant ipconfig output
823 OLDHOSTNAME=${HOSTNAME}
824 . /tmp/net-${DEVICE}.conf
825 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
828 # Check if we have a network device at all
829 if ! ls /sys/class/net/"$DEVICE" > /dev/null 2>&1 && \
830 ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
831 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
832 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
833 ! ls /sys/class/net/ra0 > /dev/null 2>&1
835 panic "No supported network device found, maybe a non-mainline driver is required."
838 if [ "${NFSROOT}" = "auto" ]
840 NFSROOT=${ROOTSERVER}:${ROOTPATH}
843 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
849 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
851 NFSROOT=${ROOTSERVER}:${NFSROOT}
854 log_begin_msg "Trying netboot from ${NFSROOT}"
856 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
873 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
874 mount -t ramfs ram "${mountpoint}"
877 for webfile in HTTPFS FTPFS FETCH
879 url="$(eval echo \"\$\{${webfile}\}\")"
880 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
884 case "${extension}" in
886 if [ "${webfile}" = "FETCH" ]
890 ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
891 rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
892 lfile="$(basename $url)"
893 log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
894 tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
898 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
899 wget "${url}" -O "${dest}/$(basename ${url})"
903 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
904 if [ "${webfile}" = "FTPFS" ]
906 FUSE_MOUNT="curlftpfs"
907 url="$(dirname ${url})"
912 $FUSE_MOUNT "${url}" "${dest}"
914 [ ${?} -eq 0 ] && rc=0
915 [ "${extension}" = "tgz" ] && live_dest="ram"
920 log_begin_msg "Unrecognized archive extension for ${url}"
928 umount "${mountpoint}"
940 if [ -z "${NFSOPTS}" ]
945 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
947 # FIXME: This while loop is an ugly HACK round an nfs bug
949 while [ "$i" -lt 60 ]
951 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
963 if [ -x "/sbin/mount.cifs" ]
965 if [ -z "${NFSOPTS}" ]
967 CIFSOPTS="-ouser=root,password="
969 CIFSOPTS="${NFSOPTS}"
972 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
975 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
989 size=$(fs_size "${fromdev}" "" "used")
991 if [ -b "${fromdev}" ]
994 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
996 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
997 freespace=$(df -k | awk '/'${todev}'/{print $4}')
999 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
1002 tomount="/mnt/tmpsnap"
1004 if [ ! -d "${tomount}" ]
1006 mkdir -p "${tomount}"
1009 fstype=$(get_fstype "${fromdev}")
1011 if [ -n "${fstype}" ]
1014 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
1015 cp -a "${tomount}"/* ${todir}
1018 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
1023 if echo ${fromdev} | grep -qs loop
1025 losetup -d "${fromdev}"
1032 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
1038 # Look for ${snap_label}.* in block devices
1041 if [ "${PERSISTENT}" != "nofiles" ]
1043 # search for image files
1044 snapdata=$(find_files "${PERSISTENT_PATH}${snap_label}.squashfs ${PERSISTENT_PATH}${snap_label}.cpio.gz ${PERSISTENT_PATH}${snap_label}.ext2 ${PERSISTENT_PATH}${snap_label}.ext3 ${PERSISTENT_PATH}${snap_label}.ext4 ${PERSISTENT_PATH}${snap_label}.jffs2")
1047 if [ -z "${snapdata}" ]
1049 snapdata=$(find_cow_device "${snap_label}")
1056 # copy the contents of previously found snapshot to ${snap_mount}
1057 # and remember the device and filename for resync on exit in live-initramfs.init
1063 if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
1065 log_success_msg "found snapshot: ${snapdata}"
1066 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
1067 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
1068 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
1071 if ! try_mount "${snapdev}" "${snapback}" "ro"
1076 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
1078 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
1079 dev=$(get_backing_device "${snapback}/${snapfile}")
1081 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1086 # Unfortunately klibc's cpio is incompatible with the
1087 # rest of the world; everything else requires -u -d,
1088 # while klibc doesn't implement them. Try to detect
1089 # whether it's in use.
1090 cpiopath="$(which cpio)" || true
1091 if [ "$cpiopath" ] && grep -aq /lib/klibc "$cpiopath"
1095 cpioargs='--unconditional --make-directories'
1098 if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null)
1100 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | cpio $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse\""
1104 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
1106 if [ "${RES}" != "0" ]
1108 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
1111 elif [ -b "${snapdata}" ]
1113 # Try to find if it could be a snapshot partition
1115 log_success_msg "found snapshot ${snap_type} device on ${dev}"
1116 if echo "${dev}" | grep -qs loop
1118 # strange things happens, user confused?
1119 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
1120 snapfile=$(basename ${snaploop})
1121 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
1126 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1128 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1131 if [ -n "${snapfile}" ]
1133 # it was a loop device, user confused
1138 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1142 echo "export ${snap_type}SNAP="/cow${snap_mount#$rootmnt}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1148 image_directory="${1}"
1150 addimage_directory="${3}"
1152 case ${UNIONTYPE} in
1154 modprobe -q -b ${UNIONTYPE}
1156 if ! cut -f2 /proc/filesystems | grep -q "^${UNIONTYPE}\$" && [ -x /bin/unionfs-fuse ]
1158 echo "${UNIONTYPE} not available, falling back to unionfs-fuse."
1159 echo "This might be really slow."
1161 UNIONTYPE="unionfs-fuse"
1166 if [ "${UNIONTYPE}" = unionfs-fuse ]
1171 # run-init can't deal with images in a subdir, but we're going to
1172 # move all of these away before it runs anyway. No, we're not,
1173 # put them in / since move-mounting them into / breaks mono and
1178 # Let's just mount the read-only file systems first
1182 if [ "${UNIONTYPE}" = "aufs" ]
1185 noxino_opt="noxino,"
1186 elif [ "${UNIONTYPE}" = "unionfs-fuse" ]
1193 if [ -z "${PLAIN_ROOT}" ]
1195 # Read image names from ${MODULE}.module if it exists
1196 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1198 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1200 image_string="${image_string} ${image_directory}/${IMAGE}"
1202 elif [ -e "${image_directory}/${MODULE}.module" ]
1204 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1206 image_string="${image_string} ${image_directory}/${IMAGE}"
1209 # ${MODULE}.module does not exist, create a list of images
1210 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1212 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1214 if [ -e "${IMAGE}" ]
1216 image_string="${image_string} ${IMAGE}"
1221 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1223 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1225 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1227 if [ -e "${IMAGE}" ]
1229 image_string="${image_string} ${IMAGE}"
1236 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1239 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1243 for image in ${image_string}
1245 imagename=$(basename "${image}")
1247 export image devname
1248 maybe_break live-realpremount
1249 log_begin_msg "Running /scripts/live-realpremount"
1250 run_scripts /scripts/live-realpremount
1253 if [ -d "${image}" ]
1255 # it is a plain directory: do nothing
1256 rofsstring="${image}=${roopt}:${rofsstring}"
1257 rofslist="${image} ${rofslist}"
1258 elif [ -f "${image}" ]
1260 if losetup --help 2>&1 | grep -q -- "-r\b"
1262 backdev=$(get_backing_device "${image}" "-r")
1264 backdev=$(get_backing_device "${image}")
1266 fstype=$(get_fstype "${backdev}")
1268 if [ "${fstype}" = "unknown" ]
1270 panic "Unknown file system type on ${backdev} (${image})"
1273 if [ -z "${fstype}" ]
1275 fstype="${imagename##*.}"
1276 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1279 mkdir -p "${croot}/${imagename}"
1280 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1281 mount -t "${fstype}" -o ro,noatime "${backdev}" "${croot}/${imagename}" || panic "Can not mount ${backdev} (${image}) on ${croot}/${imagename}" && rofsstring="${croot}/${imagename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename} ${rofslist}"
1286 # we have a plain root system
1287 mkdir -p "${croot}/filesystem"
1288 log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
1289 mount -t $(get_fstype "${image_directory}") -o ro,noatime "${image_directory}" "${croot}/filesystem" || panic "Can not mount ${image_directory} on ${croot}/filesystem" && rofsstring="${croot}/filesystem=${roopt}:${rofsstring}" && rofslist="${croot}/filesystem ${rofslist}"
1291 mount -o bind ${croot}/filesystem $mountpoint
1295 rofsstring=${rofsstring%:}
1299 # Looking for "${root_persistence}" device or file
1300 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1302 if [ -z "${QUICKUSBMODULES}" ]
1305 num_block=$(ls -l /sys/block | wc -l)
1306 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1308 modprobe -q -b ${module}
1314 # For some reason, udevsettle does not block in this scenario,
1315 # so we sleep for a little while.
1317 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1318 for timeout in 5 4 3 2 1
1322 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1329 # search for label and files (this could be hugely optimized)
1330 cowprobe=$(find_cow_device "${root_persistence}")
1331 if [ -b "${cowprobe}" ]
1333 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1334 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1335 # snapshots to be sure to really store some e.g key config files,
1336 # but not on the same media
1337 blacklistdev="${cowprobe}"
1338 PERSISTENCE_IS_ON="1"
1339 export PERSISTENCE_IS_ON
1341 # homecow just mount something on /home, this should be generalized some way
1342 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1343 if [ -b "${homecow}" ]
1345 PERSISTENCE_IS_ON="1"
1346 export PERSISTENCE_IS_ON
1348 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1349 # This second type should be removed when snapshot will get smarter,
1350 # hence when "/etc/live-snapshot*list" will be supported also by
1351 # ext2|ext3|ext4|jffs2 snapshot types.
1352 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1354 if [ -b "${cowprobe}" ]
1356 cowdevice=${cowprobe}
1357 cow_fstype=$(get_fstype "${cowprobe}")
1358 cow_mountopt="rw,noatime"
1360 if [ "${FORCEPERSISTENTFSCK}" = "Yes" ]
1362 fsck -y ${cowdevice}
1365 log_warning_msg "Unable to find the persistent medium"
1368 cow_mountopt="rw,noatime,mode=755"
1370 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1372 # check if there are any nfs options
1373 if echo ${NFS_COW}|grep -q ','
1375 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1376 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1378 nfs_cow_opts="-o nolock"
1384 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1387 panic "unable to determine mac address"
1392 cow_mountopt="rw,noatime,mode=755"
1395 if [ "${cow_fstype}" = "nfs" ]
1398 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1399 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1400 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1402 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1403 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1406 rofscount=$(echo ${rofslist} |wc -w)
1408 if [ -n "${EXPOSED_ROOT}" ]
1410 if [ ${rofscount} -ne 1 ]
1412 panic "only one RO file system supported with exposedroot: ${rofslist}"
1414 exposedrootfs=${rofslist%% }
1416 mount --bind ${exposedrootfs} ${rootmnt} || \
1417 panic "bind mount of ${exposedrootfs} failed"
1419 if [ -z "${SKIP_UNION_MOUNTS}" ]
1421 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1426 for dir in ${cow_dirs}; do
1429 case "${UNIONTYPE}" in
1431 (ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:${exposedrootfs}${dir} "${rootmnt}${dir}" || panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option cow,noinitgroups,default_permissions,allow_other,use_ino,suid=/cow=RW:${exposedrootfs}${dir}")
1432 mkdir -p /dev/.initramfs/varrun
1433 pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
1437 mount -t ${UNIONTYPE} -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro ${UNIONTYPE} "${rootmnt}${dir}" || panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1442 case "${UNIONTYPE}" in
1444 (ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:${rofsstring} "${rootmnt}" || panic "mount ${UNIONTYPE} on ${rootmnt} failed with option cow,noinitgroups,default_permissions,allow_other,use_ino,suid=/cow:RW:${rofsstring}")
1445 mkdir -p /dev/.initramfs/varrun
1446 pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
1450 mount -t ${UNIONTYPE} -o noatime,${noxino_opt}dirs=/cow=rw:${rofsstring} ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on ${rootmnt} failed with option noatime,${noxino_opt}dirs=/cow=rw:${rofsstring}"
1455 # Correct the permissions of /:
1456 chmod 0755 "${rootmnt}"
1458 # tmpfs file systems
1460 mkdir -p "${rootmnt}/live"
1461 mount -t tmpfs tmpfs ${rootmnt}/live
1463 # Adding other custom mounts
1464 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1466 # directly mount /home
1467 # FIXME: add a custom mounts configurable system
1469 if [ -b "${homecow}" ]
1471 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1472 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1474 log_warning_msg "Unable to find the persistent home medium"
1477 # Look for other snapshots to copy in
1478 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1479 # This second type should be removed when snapshot grow smarter
1480 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1483 if [ -n "${SHOWMOUNTS}" ]
1485 for d in ${rofslist}
1487 mkdir -p "${rootmnt}/live/${d##*/}"
1491 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1495 case "${UNIONTYPE}" in
1497 mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1501 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1509 # shows cow fs on /cow for use by live-snapshot
1510 mkdir -p "${rootmnt}/live/cow"
1511 mount -o move /cow "${rootmnt}/live/cow" >/dev/null 2>&1 || mount -o bind /cow "${rootmnt}/live/cow" || log_warning_msg "Unable to move or bind /cow to ${rootmnt}/live/cow"
1518 skip_uuid_check="${3}"
1520 # support for fromiso=.../isofrom=....
1521 if [ -n "$FROMISO" ]
1523 ISO_DEVICE=$(dirname $FROMISO)
1524 if ! [ -b $ISO_DEVICE ]
1526 # to support unusual device names like /dev/cciss/c0d0p1
1527 # as well we have to identify the block device name, let's
1528 # do that for up to 15 levels
1530 while [ -n "$ISO_DEVICE" ] && [ "$i" -gt 0 ]
1532 ISO_DEVICE=$(dirname ${ISO_DEVICE})
1533 [ -b "$ISO_DEVICE" ] && break
1538 if [ "$ISO_DEVICE" = "/" ]
1540 echo "Warning: device for bootoption isofrom= ($FROMISO) not found.">>/live.log
1543 mount "$ISO_DEVICE" /isofrom
1544 ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
1545 loopdevname=$(setup_loop "/isofrom/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
1546 devname="${loopdevname}"
1550 if [ -z "${devname}" ]
1552 devname=$(sys2dev "${sysdev}")
1555 if [ -d "${devname}" ]
1557 mount -o bind "${devname}" $mountpoint || continue
1559 if is_live_path $mountpoint
1567 [ -e "$devname" ] || continue
1569 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1571 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1572 devname="${loopdevname}"
1575 fstype=$(get_fstype "${devname}")
1577 if is_supported_fs ${fstype}
1579 devuid=$(blkid -o value -s UUID "$devname")
1580 [ -n "$devuid" ] && grep -qs "\<$devuid\>" $tried && continue
1581 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1582 [ -n "$devuid" ] && echo "$devuid" >> $tried
1584 if is_live_path ${mountpoint} && \
1585 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1590 umount ${mountpoint}
1594 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1596 losetup -d "${loopdevname}"
1606 # don't start autodetection before timeout has expired
1607 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1609 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1615 # first look at the one specified in the command line
1616 case "${LIVE_MEDIA}" in
1618 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1620 if [ "$(cat ${sysblock}/removable)" = "1" ]
1622 if readlink ${sysblock} | grep -q usb ||
1623 readlink ${sysblock}/device | grep -q usb # linux < 2.6.29
1625 for dev in $(subdevices "${sysblock}")
1627 if check_dev "${dev}"
1639 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1641 if [ "$(cat ${sysblock}/removable)" = "1" ]
1643 for dev in $(subdevices "${sysblock}")
1645 if check_dev "${dev}"
1656 if [ ! -z "${LIVE_MEDIA}" ]
1658 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1666 # or do the scan of block devices
1667 # prefer removable devices over non-removable devices, so scan them first
1668 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1670 if [ "$(cat ${sysblock}/removable)" = "1" ]
1672 removable_devices_to_scan="$removable_devices_to_scan $sysblock"
1674 nonremovable_devices_to_scan="$nonremovable_devices_to_scan $sysblock"
1677 devices_to_scan="$removable_devices_to_scan $nonremovable_devices_to_scan"
1679 for sysblock in $devices_to_scan
1681 devname=$(sys2dev "${sysblock}")
1682 [ -e "$devname" ] || continue
1683 fstype=$(get_fstype "${devname}")
1685 if /lib/udev/cdrom_id ${devname} > /dev/null
1687 if check_dev "null" "${devname}"
1691 elif is_nice_device "${sysblock}"
1693 for dev in $(subdevices "${sysblock}")
1695 if check_dev "${dev}"
1700 elif [ "${fstype}" = "squashfs" -o \
1701 "${fstype}" = "ext2" -o \
1702 "${fstype}" = "ext3" -o \
1703 "${fstype}" = "ext4" -o \
1704 "${fstype}" = "jffs2" ]
1706 # This is an ugly hack situation, the block device has
1707 # an image directly on it. It's hopefully
1708 # live-initramfs, so take it and run with it.
1709 ln -s "${devname}" "${devname}.${fstype}"
1710 echo "${devname}.${fstype}"
1718 set_usplash_timeout ()
1720 if [ -x /sbin/usplash_write ]
1722 /sbin/usplash_write "TIMEOUT 120"
1723 else if [ -x /sbin/splashy_update ] ; then
1724 /sbin/splashy_update "TIMEOUT 120"
1730 media_mountpoint="${1}"
1732 log_begin_msg "Checking media integrity"
1734 cd ${media_mountpoint}
1735 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1740 if [ "${RC}" -eq 0 ]
1742 log_success_msg "Everything ok, will reboot in 10 seconds."
1745 umount ${media_mountpoint}
1747 echo u > /proc/sysrq-trigger
1748 echo b > /proc/sysrq-trigger
1750 panic "Not ok, a media defect is likely, switch to VT8 for details."
1756 if [ -x /scripts/local-top/cryptroot ]; then
1757 /scripts/local-top/cryptroot
1764 tail -f live.log >&7 &
1767 # Ensure 'panic' function is overridden
1768 . /scripts/live-functions
1774 maybe_break live-premount
1775 log_begin_msg "Running /scripts/live-premount"
1776 run_scripts /scripts/live-premount
1779 # Needed here too because some things (*cough* udev *cough*)
1780 # changes the timeout
1784 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1788 livefs_root="${mountpoint}"
1790 panic "Unable to find a live file system on the network"
1793 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1795 # Do a local boot from hd
1798 # Scan local devices for the image
1800 while [ "$i" -lt 60 ]
1802 livefs_root=$(find_livefs ${i})
1804 if [ -n "${livefs_root}" ]
1815 if [ -z "${livefs_root}" ]
1817 panic "Unable to find a medium containing a live file system"
1820 if [ "${INTEGRITY_CHECK}" ]
1822 integrity_check "${livefs_root}"
1828 elif [ "${TODISK}" ]
1830 live_dest="${TODISK}"
1833 if [ "${live_dest}" ]
1835 log_begin_msg "Copying live media to ${live_dest}"
1836 copy_live_to "${livefs_root}" "${live_dest}"
1840 # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
1841 # because the mountpoint is left behind in /proc/mounts, so let's get
1842 # rid of it when running from RAM
1843 if [ -n "$FROMISO" ] && [ "${TORAM}" ]
1845 losetup -d /dev/loop0
1846 grep -q /isofrom /proc/mounts && umount /isofrom
1849 if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
1851 setup_unionfs "${livefs_root}" "${rootmnt}"
1854 mac="$(echo ${mac} | sed 's/-//g')"
1855 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1860 # unionfs-fuse needs /dev to be bind-mounted for the duration of
1861 # live-bottom; udev's init script will take care of things after that
1862 if [ "${UNIONTYPE}" = unionfs-fuse ]
1864 mount -n -o bind /dev "${rootmnt}/dev"
1867 maybe_break live-bottom
1868 log_begin_msg "Running /scripts/live-bottom\n"
1870 run_scripts /scripts/live-bottom
1873 if [ "${UNIONFS}" = unionfs-fuse ]
1875 umount "${rootmnt}/dev"
1881 [ -w "${rootmnt}/var/log/" ] && cp live.log "${rootmnt}/var/log/" 2>/dev/null
1882 if [ -f /etc/live.conf ]
1884 cp /etc/live.conf "${rootmnt}/etc/"