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]$'
675 elif echo ${sysfs_path} | grep -q "^/block/dm-"
687 copyto="${copyfrom}_swap"
689 if [ -z "${MODULETORAM}" ]
691 size=$(fs_size "" ${copyfrom}/${LIVE_MEDIA_PATH} "used")
693 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
695 if [ -f "${MODULETORAMFILE}" ]
697 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
699 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
704 if [ "${copytodev}" = "ram" ]
707 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
708 mount_options="-o size=${size}k"
713 # it should be a writable block device
714 if [ -b "${copytodev}" ]
718 fstype=$(get_fstype "${dev}")
719 freespace=$(fs_size "${dev}")
721 log_warning_msg "${copytodev} is not a block device."
726 if [ "${freespace}" -lt "${size}" ]
728 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
732 # begin copying (or uncompressing)
734 log_begin_msg "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
735 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
737 if [ "${extension}" = "tgz" ]
740 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
741 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
742 mount -r -o move "${copyto}" "${rootmnt}"
745 if [ -n "${MODULETORAMFILE}" ]
749 echo " * Copying $MODULETORAMFILE to RAM" 1>/dev/console
750 rsync -a --progress ${MODULETORAMFILE} ${copyto} 1>/dev/console # copy only the filesystem module
752 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
757 echo " * Copying whole medium to RAM" 1>/dev/console
758 rsync -a --progress ${copyfrom}/* ${copyto} 1>/dev/console # "cp -a" from busybox also copies hidden files
760 mkdir -p ${copyto}/${LIVE_MEDIA_PATH}
761 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH} # "cp -a" from busybox also copies hidden files
766 mount -r -o move ${copyto} ${copyfrom}
777 modprobe -q af_packet # For DHCP
782 # if ethdevice was not specified on the kernel command line
783 # make sure we try to get a working network configuration
784 # for *every* present network device (except for loopback of course)
785 if [ -z "$ETHDEVICE" ] ; then
786 echo "If you want to boot from a specific device use bootoption ethdevice=..."
787 for device in /sys/class/net/*; do
789 if [ "$dev" != "lo" ] ; then
790 ETHDEVICE="$ETHDEVICE $dev"
795 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
796 for device in $(echo $ETHDEVICE | sed 's/,/ /g') ; do
797 devlist="$devlist $device"
800 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
801 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
803 # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
804 # an endless loop; iff execution fails give it two further tries, that's
805 # why we use '$devlist $devlist $devlist' for the other for loop
806 for dev in $devlist $devlist $devlist ; do
807 echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
808 ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
810 sleep "$ETHDEV_TIMEOUT" ; sleep 1
811 if [ -r /proc/"$jobid"/status ] ; then
812 echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
816 # if configuration of device worked we should have an assigned
817 # IP address, iff so let's use the according as $DEVICE for later usage
818 # simple and primitive approach which seems to work fine
819 if ifconfig $dev | grep -q 'inet.*addr:' ; then
825 # source relevant ipconfig output
826 OLDHOSTNAME=${HOSTNAME}
827 . /tmp/net-${DEVICE}.conf
828 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
831 # Check if we have a network device at all
832 if ! ls /sys/class/net/"$DEVICE" > /dev/null 2>&1 && \
833 ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
834 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
835 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
836 ! ls /sys/class/net/ra0 > /dev/null 2>&1
838 panic "No supported network device found, maybe a non-mainline driver is required."
841 if [ "${NFSROOT}" = "auto" ]
843 NFSROOT=${ROOTSERVER}:${ROOTPATH}
846 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
852 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
854 NFSROOT=${ROOTSERVER}:${NFSROOT}
857 log_begin_msg "Trying netboot from ${NFSROOT}"
859 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
876 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
877 mount -t ramfs ram "${mountpoint}"
880 for webfile in HTTPFS FTPFS FETCH
882 url="$(eval echo \"\$\{${webfile}\}\")"
883 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
887 case "${extension}" in
889 if [ "${webfile}" = "FETCH" ]
893 ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
894 rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
895 lfile="$(basename $url)"
896 log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
897 tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
901 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
902 wget "${url}" -O "${dest}/$(basename ${url})"
906 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
907 if [ "${webfile}" = "FTPFS" ]
909 FUSE_MOUNT="curlftpfs"
910 url="$(dirname ${url})"
915 $FUSE_MOUNT "${url}" "${dest}"
917 [ ${?} -eq 0 ] && rc=0
918 [ "${extension}" = "tgz" ] && live_dest="ram"
923 log_begin_msg "Unrecognized archive extension for ${url}"
931 umount "${mountpoint}"
943 if [ -z "${NFSOPTS}" ]
948 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
950 # FIXME: This while loop is an ugly HACK round an nfs bug
952 while [ "$i" -lt 60 ]
954 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
966 if [ -x "/sbin/mount.cifs" ]
968 if [ -z "${NFSOPTS}" ]
970 CIFSOPTS="-ouser=root,password="
972 CIFSOPTS="${NFSOPTS}"
975 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
978 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
992 size=$(fs_size "${fromdev}" "" "used")
994 if [ -b "${fromdev}" ]
997 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
999 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
1000 freespace=$(df -k | awk '/'${todev}'/{print $4}')
1002 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
1005 tomount="/mnt/tmpsnap"
1007 if [ ! -d "${tomount}" ]
1009 mkdir -p "${tomount}"
1012 fstype=$(get_fstype "${fromdev}")
1014 if [ -n "${fstype}" ]
1017 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
1018 cp -a "${tomount}"/* ${todir}
1021 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
1026 if echo ${fromdev} | grep -qs loop
1028 losetup -d "${fromdev}"
1035 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
1041 # Look for ${snap_label}.* in block devices
1044 if [ "${PERSISTENT}" != "nofiles" ]
1046 # search for image files
1047 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")
1050 if [ -z "${snapdata}" ]
1052 snapdata=$(find_cow_device "${snap_label}")
1059 # copy the contents of previously found snapshot to ${snap_mount}
1060 # and remember the device and filename for resync on exit in live-initramfs.init
1066 if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
1068 log_success_msg "found snapshot: ${snapdata}"
1069 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
1070 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
1071 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
1074 if ! try_mount "${snapdev}" "${snapback}" "ro"
1079 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
1081 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
1082 dev=$(get_backing_device "${snapback}/${snapfile}")
1084 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1089 # Unfortunately klibc's cpio is incompatible with the
1090 # rest of the world; everything else requires -u -d,
1091 # while klibc doesn't implement them. Try to detect
1092 # whether it's in use.
1093 cpiopath="$(which cpio)" || true
1094 if [ "$cpiopath" ] && grep -aq /lib/klibc "$cpiopath"
1098 cpioargs='--unconditional --make-directories'
1101 if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null)
1103 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | cpio $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse\""
1107 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
1109 if [ "${RES}" != "0" ]
1111 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
1114 elif [ -b "${snapdata}" ]
1116 # Try to find if it could be a snapshot partition
1118 log_success_msg "found snapshot ${snap_type} device on ${dev}"
1119 if echo "${dev}" | grep -qs loop
1121 # strange things happens, user confused?
1122 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
1123 snapfile=$(basename ${snaploop})
1124 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
1129 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1131 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1134 if [ -n "${snapfile}" ]
1136 # it was a loop device, user confused
1141 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1145 echo "export ${snap_type}SNAP="/cow${snap_mount#$rootmnt}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1151 image_directory="${1}"
1153 addimage_directory="${3}"
1155 case ${UNIONTYPE} in
1157 modprobe -q -b ${UNIONTYPE}
1159 if ! cut -f2 /proc/filesystems | grep -q "^${UNIONTYPE}\$" && [ -x /bin/unionfs-fuse ]
1161 echo "${UNIONTYPE} not available, falling back to unionfs-fuse."
1162 echo "This might be really slow."
1164 UNIONTYPE="unionfs-fuse"
1169 if [ "${UNIONTYPE}" = unionfs-fuse ]
1174 # run-init can't deal with images in a subdir, but we're going to
1175 # move all of these away before it runs anyway. No, we're not,
1176 # put them in / since move-mounting them into / breaks mono and
1181 # Let's just mount the read-only file systems first
1185 if [ "${UNIONTYPE}" = "aufs" ]
1188 noxino_opt="noxino,"
1189 elif [ "${UNIONTYPE}" = "unionfs-fuse" ]
1196 if [ -z "${PLAIN_ROOT}" ]
1198 # Read image names from ${MODULE}.module if it exists
1199 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1201 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1203 image_string="${image_string} ${image_directory}/${IMAGE}"
1205 elif [ -e "${image_directory}/${MODULE}.module" ]
1207 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1209 image_string="${image_string} ${image_directory}/${IMAGE}"
1212 # ${MODULE}.module does not exist, create a list of images
1213 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1215 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1217 if [ -e "${IMAGE}" ]
1219 image_string="${image_string} ${IMAGE}"
1224 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1226 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1228 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1230 if [ -e "${IMAGE}" ]
1232 image_string="${image_string} ${IMAGE}"
1239 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1242 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1246 for image in ${image_string}
1248 imagename=$(basename "${image}")
1250 export image devname
1251 maybe_break live-realpremount
1252 log_begin_msg "Running /scripts/live-realpremount"
1253 run_scripts /scripts/live-realpremount
1256 if [ -d "${image}" ]
1258 # it is a plain directory: do nothing
1259 rofsstring="${image}=${roopt}:${rofsstring}"
1260 rofslist="${image} ${rofslist}"
1261 elif [ -f "${image}" ]
1263 if losetup --help 2>&1 | grep -q -- "-r\b"
1265 backdev=$(get_backing_device "${image}" "-r")
1267 backdev=$(get_backing_device "${image}")
1269 fstype=$(get_fstype "${backdev}")
1271 if [ "${fstype}" = "unknown" ]
1273 panic "Unknown file system type on ${backdev} (${image})"
1276 if [ -z "${fstype}" ]
1278 fstype="${imagename##*.}"
1279 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1282 mkdir -p "${croot}/${imagename}"
1283 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1284 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}"
1289 # we have a plain root system
1290 mkdir -p "${croot}/filesystem"
1291 log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
1292 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}"
1294 mount -o bind ${croot}/filesystem $mountpoint
1298 rofsstring=${rofsstring%:}
1302 # Looking for "${root_persistence}" device or file
1303 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1305 if [ -z "${QUICKUSBMODULES}" ]
1308 num_block=$(ls -l /sys/block | wc -l)
1309 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1311 modprobe -q -b ${module}
1317 # For some reason, udevsettle does not block in this scenario,
1318 # so we sleep for a little while.
1320 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1321 for timeout in 5 4 3 2 1
1325 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1332 # search for label and files (this could be hugely optimized)
1333 cowprobe=$(find_cow_device "${root_persistence}")
1334 if [ -b "${cowprobe}" ]
1336 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1337 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1338 # snapshots to be sure to really store some e.g key config files,
1339 # but not on the same media
1340 blacklistdev="${cowprobe}"
1341 PERSISTENCE_IS_ON="1"
1342 export PERSISTENCE_IS_ON
1344 # homecow just mount something on /home, this should be generalized some way
1345 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1346 if [ -b "${homecow}" ]
1348 PERSISTENCE_IS_ON="1"
1349 export PERSISTENCE_IS_ON
1351 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1352 # This second type should be removed when snapshot will get smarter,
1353 # hence when "/etc/live-snapshot*list" will be supported also by
1354 # ext2|ext3|ext4|jffs2 snapshot types.
1355 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1357 if [ -b "${cowprobe}" ]
1359 cowdevice=${cowprobe}
1360 cow_fstype=$(get_fstype "${cowprobe}")
1361 cow_mountopt="rw,noatime"
1363 if [ "${FORCEPERSISTENTFSCK}" = "Yes" ]
1365 fsck -y ${cowdevice}
1368 log_warning_msg "Unable to find the persistent medium"
1371 cow_mountopt="rw,noatime,mode=755"
1373 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1375 # check if there are any nfs options
1376 if echo ${NFS_COW}|grep -q ','
1378 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1379 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1381 nfs_cow_opts="-o nolock"
1387 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1390 panic "unable to determine mac address"
1395 cow_mountopt="rw,noatime,mode=755"
1398 if [ "${cow_fstype}" = "nfs" ]
1401 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1402 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1403 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1405 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1406 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1409 rofscount=$(echo ${rofslist} |wc -w)
1411 if [ -n "${EXPOSED_ROOT}" ]
1413 if [ ${rofscount} -ne 1 ]
1415 panic "only one RO file system supported with exposedroot: ${rofslist}"
1417 exposedrootfs=${rofslist%% }
1419 mount --bind ${exposedrootfs} ${rootmnt} || \
1420 panic "bind mount of ${exposedrootfs} failed"
1422 if [ -z "${SKIP_UNION_MOUNTS}" ]
1424 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1429 for dir in ${cow_dirs}; do
1432 case "${UNIONTYPE}" in
1434 (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}")
1435 mkdir -p /dev/.initramfs/varrun
1436 pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
1440 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"
1445 case "${UNIONTYPE}" in
1447 (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}")
1448 mkdir -p /dev/.initramfs/varrun
1449 pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
1453 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}"
1458 # Correct the permissions of /:
1459 chmod 0755 "${rootmnt}"
1461 # tmpfs file systems
1463 mkdir -p "${rootmnt}/live"
1464 mount -t tmpfs tmpfs ${rootmnt}/live
1466 # Adding other custom mounts
1467 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1469 # directly mount /home
1470 # FIXME: add a custom mounts configurable system
1472 if [ -b "${homecow}" ]
1474 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1475 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1477 log_warning_msg "Unable to find the persistent home medium"
1480 # Look for other snapshots to copy in
1481 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1482 # This second type should be removed when snapshot grow smarter
1483 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1486 if [ -n "${SHOWMOUNTS}" ]
1488 for d in ${rofslist}
1490 mkdir -p "${rootmnt}/live/${d##*/}"
1494 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1498 case "${UNIONTYPE}" in
1500 mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1504 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1512 # shows cow fs on /cow for use by live-snapshot
1513 mkdir -p "${rootmnt}/live/cow"
1514 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"
1521 skip_uuid_check="${3}"
1523 # support for fromiso=.../isofrom=....
1524 if [ -n "$FROMISO" ]
1526 ISO_DEVICE=$(dirname $FROMISO)
1527 if ! [ -b $ISO_DEVICE ]
1529 # to support unusual device names like /dev/cciss/c0d0p1
1530 # as well we have to identify the block device name, let's
1531 # do that for up to 15 levels
1533 while [ -n "$ISO_DEVICE" ] && [ "$i" -gt 0 ]
1535 ISO_DEVICE=$(dirname ${ISO_DEVICE})
1536 [ -b "$ISO_DEVICE" ] && break
1541 if [ "$ISO_DEVICE" = "/" ]
1543 echo "Warning: device for bootoption isofrom= ($FROMISO) not found.">>/live.log
1546 mount "$ISO_DEVICE" /isofrom
1547 ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
1548 loopdevname=$(setup_loop "/isofrom/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
1549 devname="${loopdevname}"
1553 if [ -z "${devname}" ]
1555 devname=$(sys2dev "${sysdev}")
1558 if [ -d "${devname}" ]
1560 mount -o bind "${devname}" $mountpoint || continue
1562 if is_live_path $mountpoint
1570 [ -e "$devname" ] || continue
1572 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1574 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1575 devname="${loopdevname}"
1578 fstype=$(get_fstype "${devname}")
1580 if is_supported_fs ${fstype}
1582 devuid=$(blkid -o value -s UUID "$devname")
1583 [ -n "$devuid" ] && grep -qs "\<$devuid\>" $tried && continue
1584 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1585 [ -n "$devuid" ] && echo "$devuid" >> $tried
1587 if is_live_path ${mountpoint} && \
1588 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1593 umount ${mountpoint}
1597 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1599 losetup -d "${loopdevname}"
1609 # don't start autodetection before timeout has expired
1610 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1612 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1618 # first look at the one specified in the command line
1619 case "${LIVE_MEDIA}" in
1621 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1623 if [ "$(cat ${sysblock}/removable)" = "1" ]
1625 if readlink ${sysblock} | grep -q usb ||
1626 readlink ${sysblock}/device | grep -q usb # linux < 2.6.29
1628 for dev in $(subdevices "${sysblock}")
1630 if check_dev "${dev}"
1642 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1644 if [ "$(cat ${sysblock}/removable)" = "1" ]
1646 for dev in $(subdevices "${sysblock}")
1648 if check_dev "${dev}"
1659 if [ ! -z "${LIVE_MEDIA}" ]
1661 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1669 # or do the scan of block devices
1670 # prefer removable devices over non-removable devices, so scan them first
1671 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1673 if [ "$(cat ${sysblock}/removable)" = "1" ]
1675 removable_devices_to_scan="$removable_devices_to_scan $sysblock"
1677 nonremovable_devices_to_scan="$nonremovable_devices_to_scan $sysblock"
1680 devices_to_scan="$removable_devices_to_scan $nonremovable_devices_to_scan"
1682 for sysblock in $devices_to_scan
1684 devname=$(sys2dev "${sysblock}")
1685 [ -e "$devname" ] || continue
1686 fstype=$(get_fstype "${devname}")
1688 if /lib/udev/cdrom_id ${devname} > /dev/null
1690 if check_dev "null" "${devname}"
1694 elif is_nice_device "${sysblock}"
1696 for dev in $(subdevices "${sysblock}")
1698 if check_dev "${dev}"
1703 elif [ "${fstype}" = "squashfs" -o \
1704 "${fstype}" = "ext2" -o \
1705 "${fstype}" = "ext3" -o \
1706 "${fstype}" = "ext4" -o \
1707 "${fstype}" = "jffs2" ]
1709 # This is an ugly hack situation, the block device has
1710 # an image directly on it. It's hopefully
1711 # live-initramfs, so take it and run with it.
1712 ln -s "${devname}" "${devname}.${fstype}"
1713 echo "${devname}.${fstype}"
1721 set_usplash_timeout ()
1723 if [ -x /sbin/usplash_write ]
1725 /sbin/usplash_write "TIMEOUT 120"
1726 else if [ -x /sbin/splashy_update ] ; then
1727 /sbin/splashy_update "TIMEOUT 120"
1733 media_mountpoint="${1}"
1735 log_begin_msg "Checking media integrity"
1737 cd ${media_mountpoint}
1738 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1743 if [ "${RC}" -eq 0 ]
1745 log_success_msg "Everything ok, will reboot in 10 seconds."
1748 umount ${media_mountpoint}
1750 echo u > /proc/sysrq-trigger
1751 echo b > /proc/sysrq-trigger
1753 panic "Not ok, a media defect is likely, switch to VT8 for details."
1757 start_usplash_pulse ()
1759 if [ -x /sbin/usplash_write ]
1761 /sbin/usplash_write "PULSELOGO"
1767 if [ -x /scripts/local-top/cryptroot ]; then
1768 /scripts/local-top/cryptroot
1775 tail -f live.log >&7 &
1778 # Ensure 'panic' function is overridden
1779 . /scripts/live-functions
1786 maybe_break live-premount
1787 log_begin_msg "Running /scripts/live-premount"
1788 run_scripts /scripts/live-premount
1791 # Needed here too because some things (*cough* udev *cough*)
1792 # changes the timeout
1796 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1800 livefs_root="${mountpoint}"
1802 panic "Unable to find a live file system on the network"
1805 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1807 # Do a local boot from hd
1810 # Scan local devices for the image
1812 while [ "$i" -lt 60 ]
1814 livefs_root=$(find_livefs ${i})
1816 if [ -n "${livefs_root}" ]
1827 if [ -z "${livefs_root}" ]
1829 panic "Unable to find a medium containing a live file system"
1832 if [ "${INTEGRITY_CHECK}" ]
1834 integrity_check "${livefs_root}"
1840 elif [ "${TODISK}" ]
1842 live_dest="${TODISK}"
1845 if [ "${live_dest}" ]
1847 log_begin_msg "Copying live media to ${live_dest}"
1848 copy_live_to "${livefs_root}" "${live_dest}"
1852 # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
1853 # because the mountpoint is left behind in /proc/mounts, so let's get
1854 # rid of it when running from RAM
1855 if [ -n "$FROMISO" ] && [ "${TORAM}" ]
1857 losetup -d /dev/loop0
1858 grep -q /isofrom /proc/mounts && umount /isofrom
1861 if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
1863 setup_unionfs "${livefs_root}" "${rootmnt}"
1866 mac="$(echo ${mac} | sed 's/-//g')"
1867 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1872 # unionfs-fuse needs /dev to be bind-mounted for the duration of
1873 # live-bottom; udev's init script will take care of things after that
1874 if [ "${UNIONTYPE}" = unionfs-fuse ]
1876 mount -n -o bind /dev "${rootmnt}/dev"
1879 maybe_break live-bottom
1880 log_begin_msg "Running /scripts/live-bottom\n"
1882 run_scripts /scripts/live-bottom
1885 if [ "${UNIONFS}" = unionfs-fuse ]
1887 umount "${rootmnt}/dev"
1893 [ -w "${rootmnt}/var/log/" ] && cp live.log "${rootmnt}/var/log/" 2>/dev/null
1894 if [ -f /etc/live.conf ]
1896 cp /etc/live.conf "${rootmnt}/etc/"