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}"
24 # Create /etc/mtab for debug purpose and future syncs
35 [ -f /etc/live.conf ] && . /etc/live.conf
36 export USERNAME USERFULLNAME HOSTNAME
38 . /scripts/live-helpers
40 if [ ! -f /live.vars ]
49 for ARGUMENT in $(cat /proc/cmdline)
57 NOCONSOLEKEYBOARD="Yes"
64 NOLANGUAGESELECTOR="Yes"
68 NOPOWERMANAGEMENT="Yes"
69 NOPROGRAMCRASHES="Yes"
72 NOUPDATENOTIFIER="Yes"
78 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
82 ACCESS="${ARGUMENT#access=}"
87 DEFCONSOLE="${ARGUMENT#*=}"
99 DEVICE="${ARGUMENT#ethdevice=}"
104 ETHDEVICE="${ARGUMENT#ethdevice=}"
109 ETHDEV_TIMEOUT="${ARGUMENT#ethdevice-timeout=}"
110 export ETHDEV_TIMEOUT
114 FETCH="${ARGUMENT#fetch=}"
119 FORCEPERSISTENTFSCK="Yes"
120 export FORCEPERSISTENTFSCK
124 HOOK="${ARGUMENT#hook=}"
129 FTPFS="${ARGUMENT#ftpfs=}"
134 HTTPFS="${ARGUMENT#httpfs=}"
139 HOSTNAME="${ARGUMENT#hostname=}"
141 export HOSTNAME LIVECONF
145 FROMISO="${ARGUMENT#*=}"
150 USERNAME="${ARGUMENT#username=}"
152 export USERNAME LIVECONF
156 USERFULLNAME="${ARGUMENT#userfullname=}"
158 export USERFULLNAME LIVECONF
167 INTEGRITY_CHECK="Yes"
168 export INTEGRITY_CHECK
172 STATICIP="${ARGUMENT#ip=}"
174 if [ -z "${STATICIP}" ]
182 keyb=*|kbd-chooser/method=*)
187 klayout=*|console-setup/layoutcode=*)
188 KLAYOUT="${ARGUMENT#*=}"
192 kvariant=*|console-setup/variantcode=*)
193 KVARIANT="${ARGUMENT#*=}"
197 kmodel=*|console-setup/modelcode=*)
198 KMODEL="${ARGUMENT#*=}"
203 KOPTIONS="${ARGUMENT#koptions=}"
212 live-media=*|bootfrom=*)
213 LIVE_MEDIA="${ARGUMENT#*=}"
217 live-media-encryption=*|encryption=*)
218 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
219 export LIVE_MEDIA_ENCRYPTION
223 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
224 export LIVE_MEDIA_OFFSET
228 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
229 export LIVE_MEDIA_PATH
232 live-media-timeout=*)
233 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
234 export LIVE_MEDIA_TIMEOUT
237 language=*|debian-installer/language=*)
238 language=${x#debian-installer/language=}
239 locale="$(lang2locale "$language")"
243 locale=*|debian-installer/locale=*)
244 LOCALE="${ARGUMENT#*=}"
249 MODULE="${ARGUMENT#module=}"
254 NETBOOT="${ARGUMENT#netboot=}"
259 NFSOPTS="${ARGUMENT#nfsopts=}"
264 NFS_COW="${ARGUMENT#nfscow=}"
269 NOACCESSIBILITY="Yes"
270 export NOACCESSIBILITY
294 NOCONSOLEKEYBOARD="Yes"
295 export NOCONSOLEKEYBOARD
319 NOKPERSONALIZER="Yes"
320 export NOKPERSONALIZER
324 NOLANGUAGESELECTOR="Yes"
325 export NOLANGUAGESELECTOR
339 NOPOWERMANAGEMENT="Yes"
340 export NOPOWERMANAGEMENT
344 NOPROGRAMCRASHES="Yes"
345 export NOPROGRAMCRASHES
364 NOUPDATENOTIFIER="Yes"
365 export NOUPDATENOTIFIER
380 export NOXSCREENSAVER
389 PERSISTENT="${ARGUMENT#persistent=}"
390 if [ -z "${PERSISTENT}" ]
398 PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
399 export PERSISTENT_PATH
402 persistent-subtext=*)
403 root_persistence="${root_persistence}-${ARGUMENT#persistent-subtext=}"
404 home_persistence="${home_persistence}-${ARGUMENT#persistent-subtext=}"
405 root_snapshot_label="${root_snapshot_label}-${ARGUMENT#persistent-subtext=}"
406 home_snapshot_label="${home_snapshot_label}-${ARGUMENT#persistent-subtext=}"
415 QUICKUSBMODULES="Yes"
416 export QUICKUSBMODULES
419 preseed/file=*|file=*)
420 LOCATION="${ARGUMENT#*=}"
430 location="${ARGUMENT#url=}"
432 mount -o bind /sys /root/sys
433 mount -o bind /proc /root/proc
434 mount -o bind /dev /root/dev
436 mkdir -p /root/var/run/network
437 [ "${NETBOOT}" ] || chroot /root dhclient eth0
438 chroot /root wget -P /tmp "${location}"
439 [ "${NETBOOT}" ] || chroot /root ifconfig eth0 down
445 LOCATION="/tmp/$(basename "${location}")"
449 question="${ARGUMENT%%=*}"
450 value="${ARGUMENT#*=}"
451 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
471 TIMEZONE="${ARGUMENT#timezone=}"
481 TODISK="${ARGUMENT#todisk=}"
492 MODULETORAM="${ARGUMENT#toram=}"
493 export TORAM MODULETORAM
507 SKIP_UNION_MOUNTS="Yes"
508 export SKIP_UNION_MOUNTS
512 ROOT="${ARGUMENT#root=}"
517 UNIONTYPE="${ARGUMENT#union=}"
522 UTC="${ARGUMENT#utc=}"
532 XDRIVER="${ARGUMENT#xdriver=}"
537 XVIDEOMODE="${ARGUMENT#xvideomode=}"
543 # sort of compatibility with netboot.h from linux docs
544 if [ -z "${NETBOOT}" ]
546 if [ "${ROOT}" = "/dev/nfs" ]
550 elif [ "${ROOT}" = "/dev/cifs" ]
557 if [ -z "${MODULE}" ]
563 if [ -z "${UNIONTYPE}" ]
574 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
576 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
578 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
590 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
596 uuid="$(cat /conf/uuid.conf)"
598 for try_uuid_file in "${path}/.disk/live-uuid"*
600 [ -e "${try_uuid_file}" ] || continue
602 try_uuid="$(cat "${try_uuid_file}")"
604 if [ "${uuid}" = "${try_uuid}" ]
613 get_backing_device ()
616 *.squashfs|*.ext2|*.ext3|*.ext4|*.jffs2)
617 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
625 panic "Unrecognized live filesystem: ${1}"
630 match_files_in_dir ()
632 # Does any files match pattern ${1} ?
635 if [ "$(echo ${pattern})" != "${pattern}" ]
643 mount_images_in_directory ()
650 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
651 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
652 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
653 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
654 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
655 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
657 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
658 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
660 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
666 sysfs_path="${1#/sys}"
668 if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-|platform-orion-ehci|platform-mmc|platform-mxsdhci|)"
671 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
683 copyto="${copyfrom}_swap"
685 if [ -z "${MODULETORAM}" ]
687 size=$(fs_size "" ${copyfrom}/${LIVE_MEDIA_PATH} "used")
689 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
691 if [ -f "${MODULETORAMFILE}" ]
693 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
695 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
700 if [ "${copytodev}" = "ram" ]
703 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
704 mount_options="-o size=${size}k"
709 # it should be a writable block device
710 if [ -b "${copytodev}" ]
714 fstype=$(get_fstype "${dev}")
715 freespace=$(fs_size "${dev}")
717 log_warning_msg "${copytodev} is not a block device."
722 if [ "${freespace}" -lt "${size}" ]
724 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
728 # begin copying (or uncompressing)
730 log_begin_msg "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
731 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
733 if [ "${extension}" = "tgz" ]
736 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
737 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
738 mount -r -o move "${copyto}" "${rootmnt}"
741 if [ -n "${MODULETORAMFILE}" ]
745 echo " * Copying $MODULETORAMFILE to RAM" 1>/dev/console
746 rsync -a --progress ${MODULETORAMFILE} ${copyto} 1>/dev/console # copy only the filesystem module
748 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
753 echo " * Copying whole medium to RAM" 1>/dev/console
754 rsync -a --progress ${copyfrom}/* ${copyto} 1>/dev/console # "cp -a" from busybox also copies hidden files
756 mkdir -p ${copyto}/${LIVE_MEDIA_PATH}
757 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH} # "cp -a" from busybox also copies hidden files
762 mount -r -o move ${copyto} ${copyfrom}
773 modprobe -q af_packet # For DHCP
778 # if ethdevice was not specified on the kernel command line
779 # make sure we try to get a working network configuration
780 # for *every* present network device (except for loopback of course)
781 if [ -z "$ETHDEVICE" ] ; then
782 echo "If you want to boot from a specific device use bootoption ethdevice=..."
783 for device in /sys/class/net/*; do
785 if [ "$dev" != "lo" ] ; then
786 ETHDEVICE="$ETHDEVICE $dev"
791 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
792 for device in $(echo $ETHDEVICE | sed 's/,/ /g') ; do
793 devlist="$devlist $device"
796 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
797 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
799 # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
800 # an endless loop; iff execution fails give it two further tries, that's
801 # why we use '$devlist $devlist $devlist' for the other for loop
802 for dev in $devlist $devlist $devlist ; do
803 echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
804 ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
806 sleep "$ETHDEV_TIMEOUT" ; sleep 1
807 if [ -r /proc/"$jobid"/status ] ; then
808 echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
812 # if configuration of device worked we should have an assigned
813 # IP address, iff so let's use the according as $DEVICE for later usage
814 # simple and primitive approach which seems to work fine
815 if ifconfig $dev | grep -q 'inet.*addr:' ; then
821 # source relevant ipconfig output
822 OLDHOSTNAME=${HOSTNAME}
823 . /tmp/net-${DEVICE}.conf
824 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
827 # Check if we have a network device at all
828 if ! ls /sys/class/net/"$DEVICE" > /dev/null 2>&1 && \
829 ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
830 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
831 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
832 ! ls /sys/class/net/ra0 > /dev/null 2>&1
834 panic "No supported network device found, maybe a non-mainline driver is required."
837 if [ "${NFSROOT}" = "auto" ]
839 NFSROOT=${ROOTSERVER}:${ROOTPATH}
842 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
848 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
850 NFSROOT=${ROOTSERVER}:${NFSROOT}
853 log_begin_msg "Trying netboot from ${NFSROOT}"
855 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
872 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
873 mount -t ramfs ram "${mountpoint}"
876 for webfile in HTTPFS FTPFS FETCH
878 url="$(eval echo \"\$\{${webfile}\}\")"
879 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
883 case "${extension}" in
885 if [ "${webfile}" = "FETCH" ]
889 ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
890 rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
891 lfile="$(basename $url)"
892 log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
893 tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
897 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
898 wget "${url}" -O "${dest}/$(basename ${url})"
902 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
903 if [ "${webfile}" = "FTPFS" ]
905 FUSE_MOUNT="curlftpfs"
906 url="$(dirname ${url})"
911 $FUSE_MOUNT "${url}" "${dest}"
913 [ ${?} -eq 0 ] && rc=0
914 [ "${extension}" = "tgz" ] && live_dest="ram"
919 log_begin_msg "Unrecognized archive extension for ${url}"
927 umount "${mountpoint}"
939 if [ -z "${NFSOPTS}" ]
944 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
946 # FIXME: This while loop is an ugly HACK round an nfs bug
948 while [ "$i" -lt 60 ]
950 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
962 if [ -x "/sbin/mount.cifs" ]
964 if [ -z "${NFSOPTS}" ]
966 CIFSOPTS="-ouser=root,password="
968 CIFSOPTS="${NFSOPTS}"
971 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
974 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
988 size=$(fs_size "${fromdev}" "" "used")
990 if [ -b "${fromdev}" ]
993 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
995 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
996 freespace=$(df -k | awk '/'${todev}'/{print $4}')
998 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
1001 tomount="/mnt/tmpsnap"
1003 if [ ! -d "${tomount}" ]
1005 mkdir -p "${tomount}"
1008 fstype=$(get_fstype "${fromdev}")
1010 if [ -n "${fstype}" ]
1013 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
1014 cp -a "${tomount}"/* ${todir}
1017 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
1022 if echo ${fromdev} | grep -qs loop
1024 losetup -d "${fromdev}"
1031 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
1037 # Look for ${snap_label}.* in block devices
1040 if [ "${PERSISTENT}" != "nofiles" ]
1042 # search for image files
1043 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")
1046 if [ -z "${snapdata}" ]
1048 snapdata=$(find_cow_device "${snap_label}")
1055 # copy the contents of previously found snapshot to ${snap_mount}
1056 # and remember the device and filename for resync on exit in live-initramfs.init
1062 if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
1064 log_success_msg "found snapshot: ${snapdata}"
1065 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
1066 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
1067 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
1070 if ! try_mount "${snapdev}" "${snapback}" "ro"
1075 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
1077 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
1078 dev=$(get_backing_device "${snapback}/${snapfile}")
1080 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1085 # Unfortunately klibc's cpio is incompatible with the
1086 # rest of the world; everything else requires -u -d,
1087 # while klibc doesn't implement them. Try to detect
1088 # whether it's in use.
1089 cpiopath="$(which cpio)" || true
1090 if [ "$cpiopath" ] && grep -aq /lib/klibc "$cpiopath"
1094 cpioargs='--unconditional --make-directories'
1097 if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null)
1099 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | cpio $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse\""
1103 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
1105 if [ "${RES}" != "0" ]
1107 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
1110 elif [ -b "${snapdata}" ]
1112 # Try to find if it could be a snapshot partition
1114 log_success_msg "found snapshot ${snap_type} device on ${dev}"
1115 if echo "${dev}" | grep -qs loop
1117 # strange things happens, user confused?
1118 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
1119 snapfile=$(basename ${snaploop})
1120 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
1125 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1127 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1130 if [ -n "${snapfile}" ]
1132 # it was a loop device, user confused
1137 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1141 echo "export ${snap_type}SNAP="/cow${snap_mount#$rootmnt}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1147 image_directory="${1}"
1149 addimage_directory="${3}"
1151 case ${UNIONTYPE} in
1153 modprobe -q -b ${UNIONTYPE}
1155 if ! cut -f2 /proc/filesystems | grep -q "^${UNIONTYPE}\$" && [ -x /bin/unionfs-fuse ]
1157 echo "${UNIONTYPE} not available, falling back to unionfs-fuse."
1158 echo "This might be really slow."
1160 UNIONTYPE="unionfs-fuse"
1165 if [ "${UNIONTYPE}" = unionfs-fuse ]
1170 # run-init can't deal with images in a subdir, but we're going to
1171 # move all of these away before it runs anyway. No, we're not,
1172 # put them in / since move-mounting them into / breaks mono and
1177 # Let's just mount the read-only file systems first
1181 if [ "${UNIONTYPE}" = "aufs" ]
1184 noxino_opt="noxino,"
1185 elif [ "${UNIONTYPE}" = "unionfs-fuse" ]
1192 if [ -z "${PLAIN_ROOT}" ]
1194 # Read image names from ${MODULE}.module if it exists
1195 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1197 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1199 image_string="${image_string} ${image_directory}/${IMAGE}"
1201 elif [ -e "${image_directory}/${MODULE}.module" ]
1203 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1205 image_string="${image_string} ${image_directory}/${IMAGE}"
1208 # ${MODULE}.module does not exist, create a list of images
1209 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1211 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1213 if [ -e "${IMAGE}" ]
1215 image_string="${image_string} ${IMAGE}"
1220 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1222 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1224 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1226 if [ -e "${IMAGE}" ]
1228 image_string="${image_string} ${IMAGE}"
1235 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1238 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1242 for image in ${image_string}
1244 imagename=$(basename "${image}")
1246 export image devname
1247 maybe_break live-realpremount
1248 log_begin_msg "Running /scripts/live-realpremount"
1249 run_scripts /scripts/live-realpremount
1252 if [ -d "${image}" ]
1254 # it is a plain directory: do nothing
1255 rofsstring="${image}=${roopt}:${rofsstring}"
1256 rofslist="${image} ${rofslist}"
1257 elif [ -f "${image}" ]
1259 if losetup --help 2>&1 | grep -q -- "-r\b"
1261 backdev=$(get_backing_device "${image}" "-r")
1263 backdev=$(get_backing_device "${image}")
1265 fstype=$(get_fstype "${backdev}")
1267 if [ "${fstype}" = "unknown" ]
1269 panic "Unknown file system type on ${backdev} (${image})"
1272 if [ -z "${fstype}" ]
1274 fstype="${imagename##*.}"
1275 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1278 mkdir -p "${croot}/${imagename}"
1279 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1280 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}"
1285 # we have a plain root system
1286 mkdir -p "${croot}/filesystem"
1287 log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
1288 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}"
1290 mount -o bind ${croot}/filesystem $mountpoint
1294 rofsstring=${rofsstring%:}
1298 # Looking for "${root_persistence}" device or file
1299 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1301 if [ -z "${QUICKUSBMODULES}" ]
1304 num_block=$(ls -l /sys/block | wc -l)
1305 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1307 modprobe -q -b ${module}
1313 # For some reason, udevsettle does not block in this scenario,
1314 # so we sleep for a little while.
1316 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1317 for timeout in 5 4 3 2 1
1321 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1328 # search for label and files (this could be hugely optimized)
1329 cowprobe=$(find_cow_device "${root_persistence}")
1330 if [ -b "${cowprobe}" ]
1332 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1333 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1334 # snapshots to be sure to really store some e.g key config files,
1335 # but not on the same media
1336 blacklistdev="${cowprobe}"
1337 PERSISTENCE_IS_ON="1"
1338 export PERSISTENCE_IS_ON
1340 # homecow just mount something on /home, this should be generalized some way
1341 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1342 if [ -b "${homecow}" ]
1344 PERSISTENCE_IS_ON="1"
1345 export PERSISTENCE_IS_ON
1347 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1348 # This second type should be removed when snapshot will get smarter,
1349 # hence when "/etc/live-snapshot*list" will be supported also by
1350 # ext2|ext3|ext4|jffs2 snapshot types.
1351 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1353 if [ -b "${cowprobe}" ]
1355 cowdevice=${cowprobe}
1356 cow_fstype=$(get_fstype "${cowprobe}")
1357 cow_mountopt="rw,noatime"
1359 if [ "${FORCEPERSISTENTFSCK}" = "Yes" ]
1361 fsck -y ${cowdevice}
1364 log_warning_msg "Unable to find the persistent medium"
1367 cow_mountopt="rw,noatime,mode=755"
1369 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1371 # check if there are any nfs options
1372 if echo ${NFS_COW}|grep -q ','
1374 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1375 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1377 nfs_cow_opts="-o nolock"
1383 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1386 panic "unable to determine mac address"
1391 cow_mountopt="rw,noatime,mode=755"
1394 if [ "${cow_fstype}" = "nfs" ]
1397 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1398 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1399 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1401 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1402 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1405 rofscount=$(echo ${rofslist} |wc -w)
1407 if [ -n "${EXPOSED_ROOT}" ]
1409 if [ ${rofscount} -ne 1 ]
1411 panic "only one RO file system supported with exposedroot: ${rofslist}"
1413 exposedrootfs=${rofslist%% }
1415 mount --bind ${exposedrootfs} ${rootmnt} || \
1416 panic "bind mount of ${exposedrootfs} failed"
1418 if [ -z "${SKIP_UNION_MOUNTS}" ]
1420 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1425 for dir in ${cow_dirs}; do
1428 case "${UNIONTYPE}" in
1430 (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}")
1431 mkdir -p /dev/.initramfs/varrun
1432 pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
1436 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"
1441 case "${UNIONTYPE}" in
1443 (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}")
1444 mkdir -p /dev/.initramfs/varrun
1445 pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
1449 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}"
1454 # Correct the permissions of /:
1455 chmod 0755 "${rootmnt}"
1457 # tmpfs file systems
1459 mkdir -p "${rootmnt}/live"
1460 mount -t tmpfs tmpfs ${rootmnt}/live
1462 # Adding other custom mounts
1463 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1465 # directly mount /home
1466 # FIXME: add a custom mounts configurable system
1468 if [ -b "${homecow}" ]
1470 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1471 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1473 log_warning_msg "Unable to find the persistent home medium"
1476 # Look for other snapshots to copy in
1477 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1478 # This second type should be removed when snapshot grow smarter
1479 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1482 if [ -n "${SHOWMOUNTS}" ]
1484 for d in ${rofslist}
1486 mkdir -p "${rootmnt}/live/${d##*/}"
1490 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1494 case "${UNIONTYPE}" in
1496 mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1500 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1508 # shows cow fs on /cow for use by live-snapshot
1509 mkdir -p "${rootmnt}/live/cow"
1510 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"
1517 skip_uuid_check="${3}"
1519 # support for fromiso=.../isofrom=....
1520 if [ -n "$FROMISO" ]
1522 ISO_DEVICE=$(dirname $FROMISO)
1523 if ! [ -b $ISO_DEVICE ]
1525 # to support unusual device names like /dev/cciss/c0d0p1
1526 # as well we have to identify the block device name, let's
1527 # do that for up to 15 levels
1529 while [ -n "$ISO_DEVICE" ] && [ "$i" -gt 0 ]
1531 ISO_DEVICE=$(dirname ${ISO_DEVICE})
1532 [ -b "$ISO_DEVICE" ] && break
1537 if [ "$ISO_DEVICE" = "/" ]
1539 echo "Warning: device for bootoption isofrom= ($FROMISO) not found.">>/live.log
1542 mount "$ISO_DEVICE" /isofrom
1543 ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
1544 loopdevname=$(setup_loop "/isofrom/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
1545 devname="${loopdevname}"
1549 if [ -z "${devname}" ]
1551 devname=$(sys2dev "${sysdev}")
1554 if [ -d "${devname}" ]
1556 mount -o bind "${devname}" $mountpoint || continue
1558 if is_live_path $mountpoint
1567 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1569 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1570 devname="${loopdevname}"
1573 fstype=$(get_fstype "${devname}")
1575 if is_supported_fs ${fstype}
1577 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1579 if is_live_path ${mountpoint} && \
1580 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1585 umount ${mountpoint}
1589 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1591 losetup -d "${loopdevname}"
1601 # don't start autodetection before timeout has expired
1602 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1604 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1610 # first look at the one specified in the command line
1611 case "${LIVE_MEDIA}" in
1613 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1615 if [ "$(cat ${sysblock}/removable)" = "1" ]
1617 if readlink ${sysblock} | grep -q usb ||
1618 readlink ${sysblock}/device | grep -q usb # linux < 2.6.29
1620 for dev in $(subdevices "${sysblock}")
1622 if check_dev "${dev}"
1634 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1636 if [ "$(cat ${sysblock}/removable)" = "1" ]
1638 for dev in $(subdevices "${sysblock}")
1640 if check_dev "${dev}"
1651 if [ ! -z "${LIVE_MEDIA}" ]
1653 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1661 # or do the scan of block devices
1662 # prefer removable devices over non-removable devices, so scan them first
1663 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1665 if [ "$(cat ${sysblock}/removable)" = "1" ]
1667 removable_devices_to_scan="$removable_devices_to_scan $sysblock"
1669 nonremovable_devices_to_scan="$nonremovable_devices_to_scan $sysblock"
1672 devices_to_scan="$removable_devices_to_scan $nonremovable_devices_to_scan"
1674 for sysblock in $devices_to_scan
1676 devname=$(sys2dev "${sysblock}")
1677 fstype=$(get_fstype "${devname}")
1679 if /lib/udev/cdrom_id ${devname} > /dev/null
1681 if check_dev "null" "${devname}"
1685 elif is_nice_device "${sysblock}"
1687 for dev in $(subdevices "${sysblock}")
1689 if check_dev "${dev}"
1694 elif [ "${fstype}" = "squashfs" -o \
1695 "${fstype}" = "ext2" -o \
1696 "${fstype}" = "ext3" -o \
1697 "${fstype}" = "ext4" -o \
1698 "${fstype}" = "jffs2" ]
1700 # This is an ugly hack situation, the block device has
1701 # an image directly on it. It's hopefully
1702 # live-initramfs, so take it and run with it.
1703 ln -s "${devname}" "${devname}.${fstype}"
1704 echo "${devname}.${fstype}"
1712 set_usplash_timeout ()
1714 if [ -x /sbin/usplash_write ]
1716 /sbin/usplash_write "TIMEOUT 120"
1717 else if [ -x /sbin/splashy_update ] ; then
1718 /sbin/splashy_update "TIMEOUT 120"
1724 media_mountpoint="${1}"
1726 log_begin_msg "Checking media integrity"
1728 cd ${media_mountpoint}
1729 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1734 if [ "${RC}" -eq 0 ]
1736 log_success_msg "Everything ok, will reboot in 10 seconds."
1739 umount ${media_mountpoint}
1741 echo u > /proc/sysrq-trigger
1742 echo b > /proc/sysrq-trigger
1744 panic "Not ok, a media defect is likely, switch to VT8 for details."
1750 if [ -x /scripts/local-top/cryptroot ]; then
1751 /scripts/local-top/cryptroot
1758 tail -f live.log >&7 &
1761 # Ensure 'panic' function is overridden
1762 . /scripts/live-functions
1768 maybe_break live-premount
1769 log_begin_msg "Running /scripts/live-premount"
1770 run_scripts /scripts/live-premount
1773 # Needed here too because some things (*cough* udev *cough*)
1774 # changes the timeout
1778 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1782 livefs_root="${mountpoint}"
1784 panic "Unable to find a live file system on the network"
1787 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1789 # Do a local boot from hd
1792 # Scan local devices for the image
1794 while [ "$i" -lt 60 ]
1796 livefs_root=$(find_livefs ${i})
1798 if [ -n "${livefs_root}" ]
1809 if [ -z "${livefs_root}" ]
1811 panic "Unable to find a medium containing a live file system"
1814 if [ "${INTEGRITY_CHECK}" ]
1816 integrity_check "${livefs_root}"
1822 elif [ "${TODISK}" ]
1824 live_dest="${TODISK}"
1827 if [ "${live_dest}" ]
1829 log_begin_msg "Copying live media to ${live_dest}"
1830 copy_live_to "${livefs_root}" "${live_dest}"
1834 # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
1835 # because the mountpoint is left behind in /proc/mounts, so let's get
1836 # rid of it when running from RAM
1837 if [ -n "$FROMISO" ] && [ "${TORAM}" ]
1839 losetup -d /dev/loop0
1840 grep -q /isofrom /proc/mounts && umount /isofrom
1843 if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
1845 setup_unionfs "${livefs_root}" "${rootmnt}"
1848 mac="$(echo ${mac} | sed 's/-//g')"
1849 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1854 # unionfs-fuse needs /dev to be bind-mounted for the duration of
1855 # live-bottom; udev's init script will take care of things after that
1856 if [ "${UNIONTYPE}" = unionfs-fuse ]
1858 mount -n -o bind /dev "${rootmnt}/dev"
1861 maybe_break live-bottom
1862 log_begin_msg "Running /scripts/live-bottom\n"
1864 run_scripts /scripts/live-bottom
1867 if [ "${UNIONFS}" = unionfs-fuse ]
1869 umount "${rootmnt}/dev"
1875 [ -w "${rootmnt}/var/log/" ] && cp live.log "${rootmnt}/var/log/" 2>/dev/null
1876 if [ -f /etc/live.conf ]
1878 cp /etc/live.conf "${rootmnt}/etc/"