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 FETCH="${ARGUMENT#fetch=}"
109 FORCEPERSISTENTFSCK="Yes"
110 export FORCEPERSISTENTFSCK
114 HOOK="${ARGUMENT#hook=}"
119 FTPFS="${ARGUMENT#ftpfs=}"
124 HTTPFS="${ARGUMENT#httpfs=}"
129 HOSTNAME="${ARGUMENT#hostname=}"
131 export HOSTNAME LIVECONF
135 FROMISO="${ARGUMENT#*=}"
140 USERNAME="${ARGUMENT#username=}"
142 export USERNAME LIVECONF
146 USERFULLNAME="${ARGUMENT#userfullname=}"
148 export USERFULLNAME LIVECONF
157 INTEGRITY_CHECK="Yes"
158 export INTEGRITY_CHECK
162 STATICIP="${ARGUMENT#ip=}"
164 if [ -z "${STATICIP}" ]
172 keyb=*|kbd-chooser/method=*)
177 klayout=*|console-setup/layoutcode=*)
178 KLAYOUT="${ARGUMENT#*=}"
182 kvariant=*|console-setup/variantcode=*)
183 KVARIANT="${ARGUMENT#*=}"
187 kmodel=*|console-setup/modelcode=*)
188 KMODEL="${ARGUMENT#*=}"
193 KOPTIONS="${ARGUMENT#koptions=}"
202 live-media=*|bootfrom=*)
203 LIVE_MEDIA="${ARGUMENT#*=}"
207 live-media-encryption=*|encryption=*)
208 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
209 export LIVE_MEDIA_ENCRYPTION
213 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
214 export LIVE_MEDIA_OFFSET
218 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
219 export LIVE_MEDIA_PATH
222 live-media-timeout=*)
223 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
224 export LIVE_MEDIA_TIMEOUT
227 language=*|debian-installer/language=*)
228 language=${x#debian-installer/language=}
229 locale="$(lang2locale "$language")"
233 locale=*|debian-installer/locale=*)
234 LOCALE="${ARGUMENT#*=}"
239 MODULE="${ARGUMENT#module=}"
244 NETBOOT="${ARGUMENT#netboot=}"
249 NFSOPTS="${ARGUMENT#nfsopts=}"
254 NFS_COW="${ARGUMENT#nfscow=}"
259 NOACCESSIBILITY="Yes"
260 export NOACCESSIBILITY
284 NOCONSOLEKEYBOARD="Yes"
285 export NOCONSOLEKEYBOARD
309 NOKPERSONALIZER="Yes"
310 export NOKPERSONALIZER
314 NOLANGUAGESELECTOR="Yes"
315 export NOLANGUAGESELECTOR
329 NOPOWERMANAGEMENT="Yes"
330 export NOPOWERMANAGEMENT
334 NOPROGRAMCRASHES="Yes"
335 export NOPROGRAMCRASHES
354 NOUPDATENOTIFIER="Yes"
355 export NOUPDATENOTIFIER
370 export NOXSCREENSAVER
379 PERSISTENT="${ARGUMENT#persistent=}"
380 if [ -z "${PERSISTENT}" ]
388 PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
389 export PERSISTENT_PATH
392 persistent-subtext=*)
393 root_persistence="${root_persistence}-${ARGUMENT#persistent-subtext=}"
394 home_persistence="${home_persistence}-${ARGUMENT#persistent-subtext=}"
395 root_snapshot_label="${root_snapshot_label}-${ARGUMENT#persistent-subtext=}"
396 home_snapshot_label="${home_snapshot_label}-${ARGUMENT#persistent-subtext=}"
404 preseed/file=*|file=*)
405 LOCATION="${ARGUMENT#*=}"
415 location="${ARGUMENT#url=}"
417 mount -o bind /sys /root/sys
418 mount -o bind /proc /root/proc
419 mount -o bind /dev /root/dev
421 mkdir -p /root/var/run/network
422 [ "${NETBOOT}" ] || chroot /root dhclient eth0
423 chroot /root wget -P /tmp "${location}"
424 [ "${NETBOOT}" ] || chroot /root ifconfig eth0 down
430 LOCATION="/tmp/$(basename "${location}")"
434 question="${ARGUMENT%%=*}"
435 value="${ARGUMENT#*=}"
436 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
456 TIMEZONE="${ARGUMENT#timezone=}"
466 TODISK="${ARGUMENT#todisk=}"
477 MODULETORAM="${ARGUMENT#toram=}"
478 export TORAM MODULETORAM
492 SKIP_UNION_MOUNTS="Yes"
493 export SKIP_UNION_MOUNTS
497 ROOT="${ARGUMENT#root=}"
502 UNIONTYPE="${ARGUMENT#union=}"
507 UTC="${ARGUMENT#utc=}"
517 XDRIVER="${ARGUMENT#xdriver=}"
522 XVIDEOMODE="${ARGUMENT#xvideomode=}"
528 # sort of compatibility with netboot.h from linux docs
529 if [ -z "${NETBOOT}" ]
531 if [ "${ROOT}" = "/dev/nfs" ]
535 elif [ "${ROOT}" = "/dev/cifs" ]
542 if [ -z "${MODULE}" ]
548 if [ -z "${UNIONTYPE}" ]
559 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
561 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
563 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
575 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
581 uuid="$(cat /conf/uuid.conf)"
583 for try_uuid_file in "${path}/.disk/live-uuid"*
585 [ -e "${try_uuid_file}" ] || continue
587 try_uuid="$(cat "${try_uuid_file}")"
589 if [ "${uuid}" = "${try_uuid}" ]
598 get_backing_device ()
601 *.squashfs|*.ext2|*.ext3|*.ext4|*.jffs2)
602 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
610 panic "Unrecognized live filesystem: ${1}"
615 match_files_in_dir ()
617 # Does any files match pattern ${1} ?
620 if [ "$(echo ${pattern})" != "${pattern}" ]
628 mount_images_in_directory ()
635 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
636 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
637 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
638 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
639 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
640 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
642 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
643 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
645 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
651 sysfs_path="${1#/sys}"
653 if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-|platform-mmc)"
656 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
668 copyto="${copyfrom}_swap"
670 if [ -z "${MODULETORAM}" ]
672 size=$(fs_size "" ${copyfrom}/${LIVE_MEDIA_PATH} "used")
674 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
676 if [ -f "${MODULETORAMFILE}" ]
678 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
680 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
685 if [ "${copytodev}" = "ram" ]
688 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
689 mount_options="-o size=${size}k"
694 # it should be a writable block device
695 if [ -b "${copytodev}" ]
699 fstype=$(get_fstype "${dev}")
700 freespace=$(fs_size "${dev}")
702 log_warning_msg "${copytodev} is not a block device."
707 if [ "${freespace}" -lt "${size}" ]
709 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
713 # begin copying (or uncompressing)
715 log_begin_msg "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
716 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
718 if [ "${extension}" = "tgz" ]
721 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
722 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
723 mount -r -o move "${copyto}" "${rootmnt}"
726 if [ -n "${MODULETORAMFILE}" ]
730 echo " * Copying $MODULETORAMFILE to RAM" 1>/dev/console
731 rsync -a --progress ${MODULETORAMFILE} ${copyto} 1>/dev/console # copy only the filesystem module
733 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
738 echo " * Copying whole medium to RAM" 1>/dev/console
739 rsync -a --progress ${copyfrom}/* ${copyto} 1>/dev/console # "cp -a" from busybox also copies hidden files
741 mkdir -p ${copyto}/${LIVE_MEDIA_PATH}
742 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH} # "cp -a" from busybox also copies hidden files
747 mount -r -o move ${copyto} ${copyfrom}
758 modprobe -q af_packet # For DHCP
760 if [ -x /sbin/udevadm ]
771 ipconfig ${DEVICE} | tee /netboot.config
773 # source relevant ipconfig output
774 OLDHOSTNAME=${HOSTNAME}
775 . /tmp/net-${DEVICE}.conf
776 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
779 # Check if we have a network device at all
780 if ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
781 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
782 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
783 ! ls /sys/class/net/ra0 > /dev/null 2>&1
785 panic "No supported network device found, maybe a non-mainline driver is required."
788 if [ "${NFSROOT}" = "auto" ]
790 NFSROOT=${ROOTSERVER}:${ROOTPATH}
793 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
799 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
801 NFSROOT=${ROOTSERVER}:${NFSROOT}
804 log_begin_msg "Trying netboot from ${NFSROOT}"
806 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
823 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
824 mount -t ramfs ram "${mountpoint}"
827 for webfile in HTTPFS FTPFS FETCH
829 url="$(eval echo \"\$\{${webfile}\}\")"
830 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
834 case "${extension}" in
836 if [ "${webfile}" = "FETCH" ]
840 ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
841 rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
842 lfile="$(basename $url)"
843 log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
844 tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
848 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
849 wget "${url}" -O "${dest}/$(basename ${url})"
853 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
854 if [ "${webfile}" = "FTPFS" ]
856 FUSE_MOUNT="curlftpfs"
857 url="$(dirname ${url})"
862 $FUSE_MOUNT "${url}" "${dest}"
864 [ ${?} -eq 0 ] && rc=0
865 [ "${extension}" = "tgz" ] && live_dest="ram"
870 log_begin_msg "Unrecognized archive extension for ${url}"
878 umount "${mountpoint}"
890 if [ -z "${NFSOPTS}" ]
895 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
897 # FIXME: This while loop is an ugly HACK round an nfs bug
899 while [ "$i" -lt 60 ]
901 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
913 if [ -x "/sbin/mount.cifs" ]
915 if [ -z "${NFSOPTS}" ]
917 CIFSOPTS="-ouser=root,password="
919 CIFSOPTS="${NFSOPTS}"
922 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
925 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
939 size=$(fs_size "${fromdev}" "" "used")
941 if [ -b "${fromdev}" ]
944 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
946 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
947 freespace=$(df -k | awk '/'${todev}'/{print $4}')
949 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
952 tomount="/mnt/tmpsnap"
954 if [ ! -d "${tomount}" ]
956 mkdir -p "${tomount}"
959 fstype=$(get_fstype "${fromdev}")
961 if [ -n "${fstype}" ]
964 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
965 cp -a "${tomount}"/* ${todir}
968 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
973 if echo ${fromdev} | grep -qs loop
975 losetup -d "${fromdev}"
982 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
988 # Look for ${snap_label}.* in block devices
991 if [ "${PERSISTENT}" != "nofiles" ]
993 # search for image files
994 snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snap_label}.ext4 ${snap_label}.jffs2")
997 if [ -z "${snapdata}" ]
999 snapdata=$(find_cow_device "${snap_label}")
1006 # copy the contents of previously found snapshot to ${snap_mount}
1007 # and remember the device and filename for resync on exit in live-initramfs.init
1013 if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
1015 log_success_msg "found snapshot: ${snapdata}"
1016 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
1017 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
1018 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
1021 if ! try_mount "${snapdev}" "${snapback}" "ro"
1026 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
1028 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
1029 dev=$(get_backing_device "${snapback}/${snapfile}")
1031 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1036 zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
1038 if [ "${RES}" != "0" ]
1040 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
1045 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
1047 if [ "${RES}" != "0" ]
1049 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
1052 elif [ -b "${snapdata}" ]
1054 # Try to find if it could be a snapshot partition
1056 log_success_msg "found snapshot ${snap_type} device on ${dev}"
1057 if echo "${dev}" | grep -qs loop
1059 # strange things happens, user confused?
1060 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
1061 snapfile=$(basename ${snaploop})
1062 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
1067 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1069 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1072 if [ -n "${snapfile}" ]
1074 # it was a loop device, user confused
1079 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1083 echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1089 image_directory="${1}"
1091 addimage_directory="${3}"
1092 modprobe -q -b ${UNIONTYPE}
1094 # run-init can't deal with images in a subdir, but we're going to
1095 # move all of these away before it runs anyway. No, we're not,
1096 # put them in / since move-mounting them into / breaks mono and
1101 # Let's just mount the read-only file systems first
1104 minor_kernel_version=$(uname -r|cut -c 5-|sed 's/[^0-9].*//')
1106 if [ "${NETBOOT}" = "nfs" ] && [ "${minor_kernel_version}" -lt 22 ]
1108 # go aroung a bug in nfs-unionfs locking for unionfs <= 1.4
1110 elif [ "${UNIONTYPE}" = "aufs" ]
1117 if [ -z "${PLAIN_ROOT}" ]
1119 # Read image names from ${MODULE}.module if it exists
1120 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1122 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1124 image_string="${image_string} ${image_directory}/${IMAGE}"
1126 elif [ -e "${image_directory}/${MODULE}.module" ]
1128 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1130 image_string="${image_string} ${image_directory}/${IMAGE}"
1133 # ${MODULE}.module does not exist, create a list of images
1134 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1136 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1138 if [ -e "${IMAGE}" ]
1140 image_string="${image_string} ${IMAGE}"
1145 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1147 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1149 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1151 if [ -e "${IMAGE}" ]
1153 image_string="${image_string} ${IMAGE}"
1160 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1163 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1167 for image in ${image_string}
1169 imagename=$(basename "${image}")
1171 export image devname
1172 maybe_break live-realpremount
1173 log_begin_msg "Running /scripts/live-realpremount"
1174 run_scripts /scripts/live-realpremount
1177 if [ -d "${image}" ]
1179 # it is a plain directory: do nothing
1180 rofsstring="${image}=${roopt}:${rofsstring}"
1181 rofslist="${image} ${rofslist}"
1182 elif [ -f "${image}" ]
1184 if losetup --help 2>&1 | grep -q -- "-r\b"
1186 backdev=$(get_backing_device "${image}" "-r")
1188 backdev=$(get_backing_device "${image}")
1190 fstype=$(get_fstype "${backdev}")
1192 if [ "${fstype}" = "unknown" ]
1194 panic "Unknown file system type on ${backdev} (${image})"
1197 if [ -z "${fstype}" ]
1199 fstype="${imagename##*.}"
1200 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1203 mkdir -p "${croot}/${imagename}"
1204 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1205 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}"
1210 # we have a plain root system
1211 mkdir -p "${croot}/filesystem"
1212 log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
1213 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}"
1215 mount -o bind ${croot}/filesystem $mountpoint
1219 rofsstring=${rofsstring%:}
1223 # Looking for "${root_persistence}" device or file
1224 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1227 num_block=$(ls -l /sys/block | wc -l)
1228 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1230 modprobe -q -b ${module}
1233 if [ -x /sbin/udevadm ]
1244 # For some reason, udevsettle does not block in this scenario,
1245 # so we sleep for a little while.
1247 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1248 for timeout in 5 4 3 2 1
1252 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1258 # search for label and files (this could be hugely optimized)
1259 cowprobe=$(find_cow_device "${root_persistence}")
1260 if [ -b "${cowprobe}" ]
1262 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1263 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1264 # snapshots to be sure to really store some e.g key config files,
1265 # but not on the same media
1266 blacklistdev="${cowprobe}"
1267 PERSISTENCE_IS_ON="1"
1268 export PERSISTENCE_IS_ON
1270 # homecow just mount something on /home, this should be generalized some way
1271 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1272 if [ -b "${homecow}" ]
1274 PERSISTENCE_IS_ON="1"
1275 export PERSISTENCE_IS_ON
1277 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1278 # This second type should be removed when snapshot will get smarter,
1279 # hence when "/etc/live-snapshot*list" will be supported also by
1280 # ext2|ext3|ext4|jffs2 snapshot types.
1281 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1283 if [ -b "${cowprobe}" ]
1285 cowdevice=${cowprobe}
1286 cow_fstype=$(get_fstype "${cowprobe}")
1287 cow_mountopt="rw,noatime"
1289 if [ "${FORCEPERSISTENTFSCK}" = "Yes" ]
1291 fsck -y ${cowdevice}
1294 log_warning_msg "Unable to find the persistent medium"
1297 cow_mountopt="rw,noatime,mode=755"
1299 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1301 # check if there are any nfs options
1302 if echo ${NFS_COW}|grep -q ','
1304 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1305 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1307 nfs_cow_opts="-o nolock"
1313 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1316 panic "unable to determine mac address"
1321 cow_mountopt="rw,noatime,mode=755"
1324 if [ "${cow_fstype}" = "nfs" ]
1327 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1328 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1329 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1331 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1332 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1335 rofscount=$(echo ${rofslist} |wc -w)
1337 if [ -n "${EXPOSED_ROOT}" ]
1339 if [ ${rofscount} -ne 1 ]
1341 panic "only one RO file system supported with exposedroot: ${rofslist}"
1343 exposedrootfs=${rofslist%% }
1345 mount --bind ${exposedrootfs} ${rootmnt} || \
1346 panic "bind mount of ${exposedrootfs} failed"
1348 if [ -z "${SKIP_UNION_MOUNTS}" ]
1350 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1355 for dir in ${cow_dirs}; do
1357 mount -t ${UNIONTYPE} \
1358 -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
1359 ${UNIONTYPE} "${rootmnt}${dir}" || \
1360 panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
1361 rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1364 mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
1365 ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
1366 ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
1369 # Correct the permissions of /:
1370 chmod 0755 "${rootmnt}"
1372 # tmpfs file systems
1374 mkdir -p "${rootmnt}/live"
1375 mount -t tmpfs tmpfs ${rootmnt}/live
1377 # Adding other custom mounts
1378 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1380 # directly mount /home
1381 # FIXME: add a custom mounts configurable system
1383 if [ -b "${homecow}" ]
1385 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1386 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1388 log_warning_msg "Unable to find the persistent home medium"
1391 # Look for other snapshots to copy in
1392 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1393 # This second type should be removed when snapshot grow smarter
1394 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1397 if [ -n "${SHOWMOUNTS}" ]
1399 for d in ${rofslist}
1401 mkdir -p "${rootmnt}/live/${d##*/}"
1405 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1409 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1415 # shows cow fs on /cow for use by live-snapshot
1416 mkdir -p "${rootmnt}/live/cow"
1417 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"
1424 skip_uuid_check="${3}"
1426 # support for fromiso=.../isofrom=....
1427 if [ -n "$FROMISO" ]
1430 ISO_DEVICE="$(echo $FROMISO | sed 's|\(/dev/[a-z]*[0-9]*\).*|\1|')"
1431 mount "$ISO_DEVICE" /isofrom
1432 ISO_NAME="$(echo $FROMISO | sed 's|/dev/[a-z]*[0-9]*/||')"
1433 loopdevname=$(setup_loop "/isofrom/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
1434 devname="${loopdevname}"
1437 if [ -z "${devname}" ]
1439 devname=$(sys2dev "${sysdev}")
1442 if [ -d "${devname}" ]
1444 mount -o bind "${devname}" $mountpoint || continue
1446 if is_live_path $mountpoint
1455 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1457 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1458 devname="${loopdevname}"
1461 fstype=$(get_fstype "${devname}")
1463 if is_supported_fs ${fstype}
1465 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1467 if is_live_path ${mountpoint} && \
1468 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1473 umount ${mountpoint}
1477 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1479 losetup -d "${loopdevname}"
1489 # don't start autodetection before timeout has expired
1490 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1492 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1498 # first look at the one specified in the command line
1499 case "${LIVE_MEDIA}" in
1501 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1503 if [ "$(cat ${sysblock}/removable)" = "1" ]
1505 if readlink ${sysblock} | grep -q usb ||
1506 readlink ${sysblock}/device | grep -q usb # linux < 2.6.29
1508 for dev in $(subdevices "${sysblock}")
1510 if check_dev "${dev}"
1521 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1523 if [ "$(cat ${sysblock}/removable)" = "1" ]
1525 for dev in $(subdevices "${sysblock}")
1527 if check_dev "${dev}"
1537 if [ ! -z "${LIVE_MEDIA}" ]
1539 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1547 # or do the scan of block devices
1548 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1550 devname=$(sys2dev "${sysblock}")
1551 fstype=$(get_fstype "${devname}")
1553 if /lib/udev/cdrom_id ${devname} > /dev/null
1555 if check_dev "null" "${devname}"
1559 elif is_nice_device "${sysblock}"
1561 for dev in $(subdevices "${sysblock}")
1563 if check_dev "${dev}"
1568 elif [ "${fstype}" = "squashfs" -o \
1569 "${fstype}" = "ext2" -o \
1570 "${fstype}" = "ext3" -o \
1571 "${fstype}" = "ext4" -o \
1572 "${fstype}" = "jffs2" ]
1574 # This is an ugly hack situation, the block device has
1575 # an image directly on it. It's hopefully
1576 # live-initramfs, so take it and run with it.
1577 ln -s "${devname}" "${devname}.${fstype}"
1578 echo "${devname}.${fstype}"
1586 set_usplash_timeout ()
1588 if [ -x /sbin/usplash_write ]
1590 /sbin/usplash_write "TIMEOUT 120"
1591 else if [ -x /sbin/splashy_update ] ; then
1592 /sbin/splashy_update "TIMEOUT 120"
1598 media_mountpoint="${1}"
1600 log_begin_msg "Checking media integrity"
1602 cd ${media_mountpoint}
1603 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1608 if [ "${RC}" -eq 0 ]
1610 log_success_msg "Everything ok, will reboot in 10 seconds."
1613 umount ${media_mountpoint}
1615 echo u > /proc/sysrq-trigger
1616 echo b > /proc/sysrq-trigger
1618 panic "Not ok, a media defect is likely, switch to VT8 for details."
1624 if [ -x /scripts/local-top/cryptroot ]; then
1625 /scripts/local-top/cryptroot
1632 tail -f live.log >&7 &
1635 # Ensure 'panic' function is overridden
1636 . /scripts/live-functions
1642 maybe_break live-premount
1643 log_begin_msg "Running /scripts/live-premount"
1644 run_scripts /scripts/live-premount
1647 # Needed here too because some things (*cough* udev *cough*)
1648 # changes the timeout
1652 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1656 livefs_root="${mountpoint}"
1658 panic "Unable to find a live file system on the network"
1661 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1663 # Do a local boot from hd
1666 # Scan local devices for the image
1668 while [ "$i" -lt 60 ]
1670 livefs_root=$(find_livefs ${i})
1672 if [ -n "${livefs_root}" ]
1683 if [ -z "${livefs_root}" ]
1685 panic "Unable to find a medium containing a live file system"
1688 if [ "${INTEGRITY_CHECK}" ]
1690 integrity_check "${livefs_root}"
1696 elif [ "${TODISK}" ]
1698 live_dest="${TODISK}"
1701 if [ "${live_dest}" ]
1703 log_begin_msg "Copying live media to ${live_dest}"
1704 copy_live_to "${livefs_root}" "${live_dest}"
1708 # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
1709 # because the mountpoint is left behind in /proc/mounts, so let's get
1710 # rid of it when running from RAM
1711 if [ -n "$FROMISO" ] && [ "${TORAM}" ]
1713 losetup -d /dev/loop0
1714 grep -q /isofrom /proc/mounts && umount /isofrom
1717 if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
1719 setup_unionfs "${livefs_root}" "${rootmnt}"
1722 mac="$(echo ${mac} | sed 's/-//g')"
1723 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1728 maybe_break live-bottom
1729 log_begin_msg "Running /scripts/live-bottom\n"
1731 run_scripts /scripts/live-bottom
1737 [ -w "${rootmnt}/var/log/" ] && cp live.log "${rootmnt}/var/log/" 2>/dev/null