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)
53 ACCESS="${ARGUMENT#access=}"
58 DEFCONSOLE="${ARGUMENT#*=}"
70 FETCH="${ARGUMENT#fetch=}"
75 HOOK="${ARGUMENT#hook=}"
80 FTPFS="${ARGUMENT#ftpfs=}"
85 HTTPFS="${ARGUMENT#httpfs=}"
90 HOSTNAME="${ARGUMENT#hostname=}"
92 export HOSTNAME LIVECONF
96 USERNAME="${ARGUMENT#username=}"
98 export USERNAME LIVECONF
102 USERFULLNAME="${ARGUMENT#userfullname=}"
104 export USERFULLNAME LIVECONF
113 STATICIP="${ARGUMENT#ip=}"
115 if [ -z "${STATICIP}" ]
123 keyb=*|kbd-chooser/method=*)
128 klayout=*|console-setup/layoutcode=*)
129 KLAYOUT="${ARGUMENT#*=}"
133 kvariant=*|console-setup/variantcode=*)
134 KVARIANT="${ARGUMENT#*=}"
138 kmodel=*|console-setup/modelcode=*)
139 KMODEL="${ARGUMENT#*=}"
144 KOPTIONS="${ARGUMENT#koptions=}"
153 live-media=*|bootfrom=*)
154 LIVE_MEDIA="${ARGUMENT#*=}"
158 live-media-encryption=*|encryption=*)
159 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
160 export LIVE_MEDIA_ENCRYPTION
164 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
165 export LIVE_MEDIA_OFFSET
169 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
170 export LIVE_MEDIA_PATH
173 live-media-timeout=*)
174 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
175 export LIVE_MEDIA_TIMEOUT
178 language=*|debian-installer/language=*)
179 language=${x#debian-installer/language=}
180 locale="$(lang2locale "$language")"
184 locale=*|debian-installer/locale=*)
185 LOCALE="${ARGUMENT#*=}"
190 MODULE="${ARGUMENT#module=}"
195 NETBOOT="${ARGUMENT#netboot=}"
200 NFSOPTS="${ARGUMENT#nfsopts=}"
205 NFS_COW="${ARGUMENT#nfscow=}"
210 NOACCESSIBILITY="Yes"
211 export NOACCESSIBILITY
235 NOCONSOLEKEYBOARD="Yes"
236 export NOCONSOLEKEYBOARD
260 NOKPERSONALIZER="Yes"
261 export NOKPERSONALIZER
265 NOLANGUAGESELECTOR="Yes"
266 export NOLANGUAGESELECTOR
280 NOPOWERMANAGEMENT="Yes"
281 export NOPOWERMANAGEMENT
285 NOPROGRAMCRASHES="Yes"
286 export NOPROGRAMCRASHES
290 NORESTRICTEDMANAGER="Yes"
291 export NORESTRICTEDMANAGER
305 NOUPDATENOTIFIER="Yes"
306 export NOUPDATENOTIFIER
321 export NOXSCREENSAVER
334 preseed/file=*|file=*)
335 LOCATION="${ARGUMENT#*=}"
345 location="${ARGUMENT#url=}"
347 mount -o bind /sys /root/sys
348 mount -o bind /proc /root/proc
349 mount -o bind /dev /root/dev
351 mkdir -p /root/var/run/network
352 chroot /root dhclient eth0
353 chroot /root wget -P /tmp "${location}"
354 chroot /root ifconfig eth0 down
360 LOCATION="/tmp/$(basename "${location}")"
364 question="${ARGUMENT%%=*}"
365 value="${ARGUMENT#*=}"
366 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
381 TIMEZONE="${ARGUMENT#timezone=}"
391 TODISK="${ARGUMENT#todisk=}"
402 MODULETORAM="${ARGUMENT#toram=}"
403 export TORAM MODULETORAM
417 ROOT="${ARGUMENT#root=}"
422 UNIONTYPE="${ARGUMENT#union=}"
427 UTC="${ARGUMENT#utc=}"
437 XDRIVER="${ARGUMENT#xdriver=}"
442 XVIDEOMODE="${ARGUMENT#xvideomode=}"
448 # sort of compatibility with netboot.h from linux docs
449 if [ -z "${NETBOOT}" ]
451 if [ "${ROOT}" = "/dev/nfs" ]
455 elif [ "${ROOT}" = "/dev/cifs" ]
462 if [ -z "${MODULE}" ]
468 if [ -z "${UNIONTYPE}" ]
479 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
481 for FILESYSTEM in squashfs ext2 ext3 xfs dir jffs2
483 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
495 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
501 uuid="$(cat /conf/uuid.conf)"
503 for try_uuid_file in "${mountpoint}/.disk/live-uuid"*
505 [ -e "${try_uuid_file}" ] || continue
507 try_uuid="$(cat "${try_uuid_file}")"
509 if [ "${uuid}" = "${try_uuid}" ]
518 get_backing_device ()
521 *.squashfs|*.ext2|*.ext3|*.jffs2)
522 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
530 panic "Unrecognized live filesystem: ${1}"
535 match_files_in_dir ()
537 # Does any files match pattern ${1} ?
540 if [ "$(echo ${pattern})" != "${pattern}" ]
548 mount_images_in_directory ()
555 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
556 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
557 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
558 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
559 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
561 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
562 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
570 sysfs_path="${1#/sys}"
572 if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-[ide|scsi|usb])"
575 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
587 copyto="${copyfrom}_swap"
589 if [ -z "${MODULETORAM}" ]
591 size=$(fs_size "" ${copyfrom} "used")
593 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
595 if [ -f "${MODULETORAMFILE}" ]
597 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
599 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
604 if [ "${copytodev}" = "ram" ]
607 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ) )
608 mount_options="-o size=${size}k"
613 # it should be a writable block device
614 if [ -b "${copytodev}" ]
618 fstype=$(get_fstype "${dev}")
619 freespace=$(fs_size "${dev}")
621 log_warning_msg "${copytodev} is not a block device."
626 if [ "${freespace}" -lt "${size}" ]
628 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
632 # begin copying (or uncompressing)
634 echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
635 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
637 if [ "${extension}" = "tgz" ]
640 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
641 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
642 mount -r -o move "${copyto}" "${rootmnt}"
645 if [ -n "${MODULETORAMFILE}" ]
647 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
649 cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files
654 mount -r -o move ${copyto} ${copyfrom}
665 modprobe -q af_packet # For DHCP
667 if [ -x /sbin/udevadm ]
678 ipconfig ${DEVICE} | tee /netboot.config
680 # source relevant ipconfig output
681 OLDHOSTNAME=${HOSTNAME}
682 . /tmp/net-${DEVICE}.conf
683 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
686 if [ "${NFSROOT}" = "auto" ]
688 NFSROOT=${ROOTSERVER}:${ROOTPATH}
691 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
697 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
699 NFSROOT=${ROOTSERVER}:${NFSROOT}
702 log_begin_msg "Trying netboot from ${NFSROOT}"
704 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
721 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
722 mount -t ramfs ram "${mountpoint}"
725 for webfile in HTTPFS FTPFS FETCH
727 url="$(eval echo \"\$\{${webfile}\}\")"
728 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
732 case "${extension}" in
734 if [ "${webfile}" = "FETCH" ]
738 ip="$(dirname $url | sed -e 's|tftp://||g')"
739 log_begin_msg "Trying tftp -g -b 10240 -r $(basename ${url}) -l ${dest}/$(basename ${url}) $ip"
740 tftp -g -b 10240 -r $(basename ${url}) -l ${dest}/$(basename ${url}) $ip
744 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
745 wget "${url}" -O "${dest}/$(basename ${url})"
749 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
750 if [ "${webfile}" = "FTPFS" ]
752 FUSE_MOUNT="curlftpfs"
753 url="$(dirname ${url})"
758 $FUSE_MOUNT "${url}" "${dest}"
760 [ ${?} -eq 0 ] && rc=0
761 [ "${extension}" = "tgz" ] && live_dest="ram"
766 log_begin_msg "Unrecognized archive extension for ${url}"
774 umount "${mountpoint}"
786 if [ -z "${NFSOPTS}" ]
791 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
793 # FIXME: This for loop is an ugly HACK round an nfs bug
794 for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13
796 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
807 if [ -x "/sbin/mount.cifs" ]
809 if [ -z "${NFSOPTS}" ]
811 CIFSOPTS="-ouser=root,password="
813 CIFSOPTS="${NFSOPTS}"
816 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
819 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
833 size=$(fs_size "${fromdev}" "" "used")
835 if [ -b "${fromdev}" ]
838 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
840 todev=$(cat /proc/mounts | grep -s " $(base_path ${todir}) " | awk '{print $1}' )
841 freespace=$(df -k | grep -s ${todev} | awk '{print $4}')
843 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ))
846 tomount="/mnt/tmpsnap"
848 if [ ! -d "${tomount}" ]
850 mkdir -p "${tomount}"
853 fstype=$(get_fstype "${fromdev}")
855 if [ -n "${fstype}" ]
858 mount -t "${fstype}" -o ro,noatime "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro,noatime ${fromdev} ${tomount}"
859 cp -a "${tomount}"/* ${todir}
862 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
867 if echo ${fromdev} | grep -qs loop
869 losetup -d "${fromdev}"
876 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
882 # Look for ${snap_label}.* in block devices and copy the contents to ${snap_mount}
883 # and remember the device and filename for resync on exit in live-initramfs.init
888 snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snap_label}.jffs2")
890 if [ ! -z "${snapdata}" ]
892 log_success_msg "found snapshot: ${snapdata}"
893 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
894 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
895 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
899 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|jffs2\)'
901 # squashfs, jffs2 or ext2/ext3 snapshot
902 dev=$(get_backing_device "${snapback}/${snapfile}")
904 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
909 zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
911 if [ "${RES}" != "0" ]
913 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
918 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
920 if [ "${RES}" != "0" ]
922 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
926 # Try to find if it could be a snapshot partition
927 dev=$(find_cow_device "${snap_label}")
931 log_success_msg "found snapshot device on ${dev}"
932 if echo "${dev}" | grep -qs loop
934 # strange things happens, user confused?
935 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
936 snapfile=$(basename ${snaploop})
937 snapdev=$(cat /proc/mounts | awk '{print $2,$1}' | grep -es "^$( dirname ${snaploop} )" | cut -f2 -d ' ')
942 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
944 log_warning_msg "Impossible to include the ${snap_label} Snapshot"
947 if [ -n "${snapfile}" ]
949 # it was a loop device, user confused
954 log_warning_msg "Impossible to include the ${snap_label} Snapshot"
959 echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
965 image_directory="${1}"
967 addimage_directory="${3}"
968 modprobe -q -b ${UNIONTYPE}
970 # run-init can't deal with images in a subdir, but we're going to
971 # move all of these away before it runs anyway. No, we're not,
972 # put them in / since move-mounting them into / breaks mono and
977 # Let's just mount the read-only file systems first
980 minor_kernel_version=$(uname -r|cut -c 5-|sed 's/[^0-9].*//')
982 if [ "${NETBOOT}" = "nfs" ] && [ "${minor_kernel_version}" -lt 22 ]
984 # go aroung a bug in nfs-unionfs locking for unionfs <= 1.4
986 elif [ "${UNIONTYPE}" = "aufs" ]
993 # Read image names from ${MODULE}.module if it exists
994 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
996 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
998 image_string="${image_string} ${image_directory}/${IMAGE}"
1000 elif [ -e "${image_directory}/${MODULE}.module" ]
1002 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1004 image_string="${image_string} ${image_directory}/${IMAGE}"
1007 # ${MODULE}.module does not exist, create a list of images
1008 for FILESYSTEM in squashfs ext2 ext3 xfs jffs2 dir
1010 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1012 if [ -e "${IMAGE}" ]
1014 image_string="${image_string} ${IMAGE}"
1019 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1021 for FILESYSTEM in squashfs ext2 ext3 xfs jffs2 dir
1023 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1025 if [ -e "${IMAGE}" ]
1027 image_string="${image_string} ${IMAGE}"
1034 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1037 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1041 for image in ${image_string}
1043 imagename=$(basename "${image}")
1045 if [ -d "${image}" ]
1047 # it is a plain directory: do nothing
1048 rofsstring="${image}=${roopt}:${rofsstring}"
1049 rofslist="${image} ${rofslist}"
1050 elif [ -f "${image}" ]
1052 if losetup --help 2>&1 | grep -q -- "-r\b"
1054 backdev=$(get_backing_device "${image}" "-r")
1056 backdev=$(get_backing_device "${image}")
1058 fstype=$(get_fstype "${backdev}")
1060 if [ "${fstype}" = "unknown" ]
1062 panic "Unknown file system type on ${backdev} (${image})"
1065 if [ -z "${fstype}" ]
1067 fstype="${imagename##*.}"
1068 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1071 mkdir -p "${croot}/${imagename}"
1072 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1073 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}"
1078 rofsstring=${rofsstring%:}
1082 # Looking for "${root_persistence}" device or file
1083 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1086 num_block=$(ls -l /sys/block | wc -l)
1087 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1089 modprobe -q -b ${module}
1092 if [ -x /sbin/udevadm ]
1103 # For some reason, udevsettle does not block in this scenario,
1104 # so we sleep for a little while.
1106 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1107 for timeout in 5 4 3 2 1
1111 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1117 cowprobe=$(find_cow_device "${root_persistence}")
1119 if [ -b "${cowprobe}" ]
1121 cowdevice=${cowprobe}
1122 cow_fstype=$(get_fstype "${cowprobe}")
1123 cow_mountopt="rw,noatime"
1125 log_warning_msg "Unable to find the persistent medium"
1128 cow_mountopt="rw,noatime,mode=755"
1130 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1132 # check if there are any nfs options
1133 if echo ${NFS_COW}|grep -q ','
1135 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1136 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1138 nfs_cow_opts="-o nolock"
1144 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1147 panic "unable to determine mac address"
1152 cow_mountopt="rw,noatime,mode=755"
1155 if [ "${cow_fstype}" = "nfs" ]
1158 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1159 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1160 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1162 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1163 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1166 rofscount=$(echo ${rofslist} |wc -w)
1168 if [ -n "${EXPOSED_ROOT}" ]
1170 if [ ${rofscount} -ne 1 ]
1172 panic "only one RO file system supported with exposedroot: ${rofslist}"
1174 exposedrootfs=${rofslist%% }
1176 mount --bind ${exposedrootfs} ${rootmnt} || \
1177 panic "bind mount of ${exposedrootfs} failed"
1179 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool
1180 /home /var/lib/live'
1182 for dir in ${cow_dirs}; do
1184 mount -t ${UNIONTYPE} \
1185 -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
1186 ${UNIONTYPE} "${rootmnt}${dir}" || \
1187 panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
1188 rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1191 mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
1192 ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
1193 ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
1196 # tmpfs file systems
1198 mkdir -p "${rootmnt}/live"
1199 mount -t tmpfs tmpfs ${rootmnt}/live
1201 # Adding other custom mounts
1202 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1204 # directly mount /home
1205 # FIXME: add a custom mounts configurable system
1206 homecow=$(find_cow_device "${home_persistence}" )
1208 if [ -b "${homecow}" ]
1210 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1211 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1213 log_warning_msg "Unable to find the persistent home medium"
1216 # Look for other snapshots to copy in
1217 try_snap "${root_snapshot_label}" "${rootmnt}" "ROOT"
1218 try_snap "${home_snapshot_label}" "${rootmnt}/home" "HOME"
1221 if [ -n "${SHOWMOUNTS}" ]
1223 for d in ${rofslist}
1225 mkdir -p "${rootmnt}/live/${d##*/}"
1229 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1233 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1239 # shows cow fs on /cow for use by live-snapshot
1240 mkdir -p "${rootmnt}/live/cow"
1241 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"
1248 skip_uuid_check="${3}"
1250 if [ -z "${devname}" ]
1252 devname=$(sys2dev "${sysdev}")
1255 if [ -d "${devname}" ]
1257 mount -o bind "${devname}" $mountpoint || continue
1259 if is_live_path $mountpoint
1268 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1270 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1271 devname="${loopdevname}"
1274 fstype=$(get_fstype "${devname}")
1276 if is_supported_fs ${fstype}
1278 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1280 if is_live_path ${mountpoint} && \
1281 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1286 umount ${mountpoint}
1290 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1292 losetup -d "${loopdevname}"
1302 # first look at the one specified in the command line
1303 if [ ! -z "${LIVE_MEDIA}" ]
1305 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1311 # don't start autodetection before timeout has expired
1312 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1314 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1320 # or do the scan of block devices
1321 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram | grep -v 'dm-' | grep -v fd )
1323 devname=$(sys2dev "${sysblock}")
1324 fstype=$(get_fstype "${devname}")
1326 if /lib/udev/cdrom_id ${devname} > /dev/null
1328 if check_dev "null" "${devname}"
1332 elif is_nice_device "${sysblock}"
1334 for dev in $(subdevices "${sysblock}")
1336 if check_dev "${dev}"
1341 elif [ "${fstype}" = "squashfs" -o \
1342 "${fstype}" = "ext2" -o \
1343 "${fstype}" = "ext3" -o \
1344 "${fstype}" = "jffs2" ]
1346 # This is an ugly hack situation, the block device has
1347 # an image directly on it. It's hopefully
1348 # live-initramfs, so take it and run with it.
1349 ln -s "${devname}" "${devname}.${fstype}"
1350 echo "${devname}.${fstype}"
1358 set_usplash_timeout ()
1360 if [ -x /sbin/usplash_write ]
1362 /sbin/usplash_write "TIMEOUT 120"
1363 else if [ -x /sbin/splashy_update ] ; then
1364 /sbin/splashy_update "TIMEOUT 120"
1370 if [ -x /scripts/local-top/cryptroot ]; then
1371 /scripts/local-top/cryptroot
1378 tail -f live.log >&7 &
1381 # Ensure 'panic' function is overridden
1382 . /scripts/live-functions
1388 maybe_break live-premount
1389 log_begin_msg "Running /scripts/live-premount"
1390 run_scripts /scripts/live-premount
1393 # Needed here too because some things (*cough* udev *cough*)
1394 # changes the timeout
1398 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1402 livefs_root="${mountpoint}"
1404 panic "Unable to find a live file system on the network"
1407 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1409 # Do a local boot from hd
1412 # Scan local devices for the image
1413 for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1415 livefs_root=$(find_livefs ${i})
1417 if [ -n "${livefs_root}" ]
1427 if [ -z "${livefs_root}" ]
1429 panic "Unable to find a medium containing a live file system"
1435 elif [ "${TODISK}" ]
1437 live_dest="${TODISK}"
1440 if [ "${live_dest}" ]
1442 log_begin_msg "Copying live media to ${live_dest}"
1443 copy_live_to "${livefs_root}" "${live_dest}"
1447 if [ -n "${MODULETORAMFILE}" ]
1449 setup_unionfs "${livefs_root}" "${rootmnt}"
1452 mac="$(echo ${mac} | sed 's/-//g')"
1453 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1458 maybe_break live-bottom
1459 log_begin_msg "Running /scripts/live-bottom"
1461 run_scripts /scripts/live-bottom
1467 cp live.log "${rootmnt}/var/log/"