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 INTEGRITY_CHECK="Yes"
114 export INTEGRITY_CHECK
118 STATICIP="${ARGUMENT#ip=}"
120 if [ -z "${STATICIP}" ]
128 keyb=*|kbd-chooser/method=*)
133 klayout=*|console-setup/layoutcode=*)
134 KLAYOUT="${ARGUMENT#*=}"
138 kvariant=*|console-setup/variantcode=*)
139 KVARIANT="${ARGUMENT#*=}"
143 kmodel=*|console-setup/modelcode=*)
144 KMODEL="${ARGUMENT#*=}"
149 KOPTIONS="${ARGUMENT#koptions=}"
158 live-media=*|bootfrom=*)
159 LIVE_MEDIA="${ARGUMENT#*=}"
163 live-media-encryption=*|encryption=*)
164 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
165 export LIVE_MEDIA_ENCRYPTION
169 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
170 export LIVE_MEDIA_OFFSET
174 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
175 export LIVE_MEDIA_PATH
178 live-media-timeout=*)
179 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
180 export LIVE_MEDIA_TIMEOUT
183 language=*|debian-installer/language=*)
184 language=${x#debian-installer/language=}
185 locale="$(lang2locale "$language")"
189 locale=*|debian-installer/locale=*)
190 LOCALE="${ARGUMENT#*=}"
195 MODULE="${ARGUMENT#module=}"
200 NETBOOT="${ARGUMENT#netboot=}"
205 NFSOPTS="${ARGUMENT#nfsopts=}"
210 NFS_COW="${ARGUMENT#nfscow=}"
215 NOACCESSIBILITY="Yes"
216 export NOACCESSIBILITY
240 NOCONSOLEKEYBOARD="Yes"
241 export NOCONSOLEKEYBOARD
265 NOKPERSONALIZER="Yes"
266 export NOKPERSONALIZER
270 NOLANGUAGESELECTOR="Yes"
271 export NOLANGUAGESELECTOR
285 NOPOWERMANAGEMENT="Yes"
286 export NOPOWERMANAGEMENT
290 NOPROGRAMCRASHES="Yes"
291 export NOPROGRAMCRASHES
310 NOUPDATENOTIFIER="Yes"
311 export NOUPDATENOTIFIER
326 export NOXSCREENSAVER
335 PERSISTENT="${ARGUMENT#persistent=}"
336 if [ -z "${PERSISTENT}" ]
348 preseed/file=*|file=*)
349 LOCATION="${ARGUMENT#*=}"
359 location="${ARGUMENT#url=}"
361 mount -o bind /sys /root/sys
362 mount -o bind /proc /root/proc
363 mount -o bind /dev /root/dev
365 mkdir -p /root/var/run/network
366 chroot /root dhclient eth0
367 chroot /root wget -P /tmp "${location}"
368 chroot /root ifconfig eth0 down
374 LOCATION="/tmp/$(basename "${location}")"
378 question="${ARGUMENT%%=*}"
379 value="${ARGUMENT#*=}"
380 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
395 TIMEZONE="${ARGUMENT#timezone=}"
405 TODISK="${ARGUMENT#todisk=}"
416 MODULETORAM="${ARGUMENT#toram=}"
417 export TORAM MODULETORAM
431 SKIP_UNION_MOUNTS="Yes"
432 export SKIP_UNION_MOUNTS
436 ROOT="${ARGUMENT#root=}"
441 UNIONTYPE="${ARGUMENT#union=}"
446 UTC="${ARGUMENT#utc=}"
456 XDRIVER="${ARGUMENT#xdriver=}"
461 XVIDEOMODE="${ARGUMENT#xvideomode=}"
467 # sort of compatibility with netboot.h from linux docs
468 if [ -z "${NETBOOT}" ]
470 if [ "${ROOT}" = "/dev/nfs" ]
474 elif [ "${ROOT}" = "/dev/cifs" ]
481 if [ -z "${MODULE}" ]
487 if [ -z "${UNIONTYPE}" ]
498 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
500 for FILESYSTEM in squashfs ext2 ext3 xfs dir jffs2
502 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
514 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
520 uuid="$(cat /conf/uuid.conf)"
522 for try_uuid_file in "${path}/.disk/live-uuid"*
524 [ -e "${try_uuid_file}" ] || continue
526 try_uuid="$(cat "${try_uuid_file}")"
528 if [ "${uuid}" = "${try_uuid}" ]
537 get_backing_device ()
540 *.squashfs|*.ext2|*.ext3|*.jffs2)
541 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
549 panic "Unrecognized live filesystem: ${1}"
554 match_files_in_dir ()
556 # Does any files match pattern ${1} ?
559 if [ "$(echo ${pattern})" != "${pattern}" ]
567 mount_images_in_directory ()
574 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
575 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
576 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
577 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
578 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
580 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
581 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
583 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
589 sysfs_path="${1#/sys}"
591 if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-(ide|scsi|usb))"
594 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
606 copyto="${copyfrom}_swap"
608 if [ -z "${MODULETORAM}" ]
610 size=$(fs_size "" ${copyfrom} "used")
612 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
614 if [ -f "${MODULETORAMFILE}" ]
616 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
618 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
623 if [ "${copytodev}" = "ram" ]
626 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
627 mount_options="-o size=${size}k"
632 # it should be a writable block device
633 if [ -b "${copytodev}" ]
637 fstype=$(get_fstype "${dev}")
638 freespace=$(fs_size "${dev}")
640 log_warning_msg "${copytodev} is not a block device."
645 if [ "${freespace}" -lt "${size}" ]
647 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
651 # begin copying (or uncompressing)
653 echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
654 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
656 if [ "${extension}" = "tgz" ]
659 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
660 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
661 mount -r -o move "${copyto}" "${rootmnt}"
664 if [ -n "${MODULETORAMFILE}" ]
666 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
668 cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files
672 mount -r -o move ${copyto} ${copyfrom}
683 modprobe -q af_packet # For DHCP
685 if [ -x /sbin/udevadm ]
696 ipconfig ${DEVICE} | tee /netboot.config
698 # source relevant ipconfig output
699 OLDHOSTNAME=${HOSTNAME}
700 . /tmp/net-${DEVICE}.conf
701 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
704 # Check if we have a network device at all
705 if ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
706 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
707 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
708 ! ls /sys/class/net/ra0 > /dev/null 2>&1
710 panic "No supported network device found, maybe a non-mainline driver is required."
713 if [ "${NFSROOT}" = "auto" ]
715 NFSROOT=${ROOTSERVER}:${ROOTPATH}
718 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
724 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
726 NFSROOT=${ROOTSERVER}:${NFSROOT}
729 log_begin_msg "Trying netboot from ${NFSROOT}"
731 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
748 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
749 mount -t ramfs ram "${mountpoint}"
752 for webfile in HTTPFS FTPFS FETCH
754 url="$(eval echo \"\$\{${webfile}\}\")"
755 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
759 case "${extension}" in
761 if [ "${webfile}" = "FETCH" ]
765 ip="$(dirname $url | sed -e 's|tftp://||g')"
766 log_begin_msg "Trying tftp -g -b 10240 -r $(basename ${url}) -l ${dest}/$(basename ${url}) $ip"
767 tftp -g -b 10240 -r $(basename ${url}) -l ${dest}/$(basename ${url}) $ip
771 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
772 wget "${url}" -O "${dest}/$(basename ${url})"
776 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
777 if [ "${webfile}" = "FTPFS" ]
779 FUSE_MOUNT="curlftpfs"
780 url="$(dirname ${url})"
785 $FUSE_MOUNT "${url}" "${dest}"
787 [ ${?} -eq 0 ] && rc=0
788 [ "${extension}" = "tgz" ] && live_dest="ram"
793 log_begin_msg "Unrecognized archive extension for ${url}"
801 umount "${mountpoint}"
813 if [ -z "${NFSOPTS}" ]
818 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
820 # FIXME: This while loop is an ugly HACK round an nfs bug
822 while [ "$i" -lt 60 ]
824 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
836 if [ -x "/sbin/mount.cifs" ]
838 if [ -z "${NFSOPTS}" ]
840 CIFSOPTS="-ouser=root,password="
842 CIFSOPTS="${NFSOPTS}"
845 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
848 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
862 size=$(fs_size "${fromdev}" "" "used")
864 if [ -b "${fromdev}" ]
867 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
869 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
870 freespace=$(df -k | awk '/'${todev}'/{print $4}')
872 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
875 tomount="/mnt/tmpsnap"
877 if [ ! -d "${tomount}" ]
879 mkdir -p "${tomount}"
882 fstype=$(get_fstype "${fromdev}")
884 if [ -n "${fstype}" ]
887 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
888 cp -a "${tomount}"/* ${todir}
891 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
896 if echo ${fromdev} | grep -qs loop
898 losetup -d "${fromdev}"
905 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
911 # Look for ${snap_label}.* in block devices
914 if [ "${PERSISTENT}" != "nofiles" ]
916 # search for image files
917 snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snap_label}.jffs2")
920 if [ -z "${snapdata}" ]
922 snapdata=$(find_cow_device "${snap_label}")
929 # copy the contents of previously found snapshot to ${snap_mount}
930 # and remember the device and filename for resync on exit in live-initramfs.init
936 if [ ! -z "${snapdata}" ]
938 log_success_msg "found snapshot: ${snapdata}"
939 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
940 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
941 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
944 if ! try_mount "${snapdev}" "${snapback}" "ro"
949 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|jffs2\)'
951 # squashfs, jffs2 or ext2/ext3 snapshot
952 dev=$(get_backing_device "${snapback}/${snapfile}")
954 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
959 zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
961 if [ "${RES}" != "0" ]
963 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
968 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
970 if [ "${RES}" != "0" ]
972 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
976 elif [ -b "${snapdata}" ]
978 # Try to find if it could be a snapshot partition
980 log_success_msg "found snapshot device on ${dev}"
981 if echo "${dev}" | grep -qs loop
983 # strange things happens, user confused?
984 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
985 snapfile=$(basename ${snaploop})
986 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
991 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
993 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
996 if [ -n "${snapfile}" ]
998 # it was a loop device, user confused
1003 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1007 echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1013 image_directory="${1}"
1015 addimage_directory="${3}"
1016 modprobe -q -b ${UNIONTYPE}
1018 # run-init can't deal with images in a subdir, but we're going to
1019 # move all of these away before it runs anyway. No, we're not,
1020 # put them in / since move-mounting them into / breaks mono and
1025 # Let's just mount the read-only file systems first
1028 minor_kernel_version=$(uname -r|cut -c 5-|sed 's/[^0-9].*//')
1030 if [ "${NETBOOT}" = "nfs" ] && [ "${minor_kernel_version}" -lt 22 ]
1032 # go aroung a bug in nfs-unionfs locking for unionfs <= 1.4
1034 elif [ "${UNIONTYPE}" = "aufs" ]
1041 # Read image names from ${MODULE}.module if it exists
1042 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1044 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1046 image_string="${image_string} ${image_directory}/${IMAGE}"
1048 elif [ -e "${image_directory}/${MODULE}.module" ]
1050 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1052 image_string="${image_string} ${image_directory}/${IMAGE}"
1055 # ${MODULE}.module does not exist, create a list of images
1056 for FILESYSTEM in squashfs ext2 ext3 xfs jffs2 dir
1058 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1060 if [ -e "${IMAGE}" ]
1062 image_string="${image_string} ${IMAGE}"
1067 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1069 for FILESYSTEM in squashfs ext2 ext3 xfs jffs2 dir
1071 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1073 if [ -e "${IMAGE}" ]
1075 image_string="${image_string} ${IMAGE}"
1082 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1085 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1089 for image in ${image_string}
1091 imagename=$(basename "${image}")
1093 export image devname
1094 maybe_break live-realpremount
1095 log_begin_msg "Running /scripts/live-realpremount"
1096 run_scripts /scripts/live-realpremount
1099 if [ -d "${image}" ]
1101 # it is a plain directory: do nothing
1102 rofsstring="${image}=${roopt}:${rofsstring}"
1103 rofslist="${image} ${rofslist}"
1104 elif [ -f "${image}" ]
1106 if losetup --help 2>&1 | grep -q -- "-r\b"
1108 backdev=$(get_backing_device "${image}" "-r")
1110 backdev=$(get_backing_device "${image}")
1112 fstype=$(get_fstype "${backdev}")
1114 if [ "${fstype}" = "unknown" ]
1116 panic "Unknown file system type on ${backdev} (${image})"
1119 if [ -z "${fstype}" ]
1121 fstype="${imagename##*.}"
1122 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1125 mkdir -p "${croot}/${imagename}"
1126 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1127 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}"
1132 rofsstring=${rofsstring%:}
1136 # Looking for "${root_persistence}" device or file
1137 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1140 num_block=$(ls -l /sys/block | wc -l)
1141 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1143 modprobe -q -b ${module}
1146 if [ -x /sbin/udevadm ]
1157 # For some reason, udevsettle does not block in this scenario,
1158 # so we sleep for a little while.
1160 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1161 for timeout in 5 4 3 2 1
1165 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1171 # search for label and files (this could be hugely optimized)
1172 cowprobe=$(find_cow_device "${root_persistence}")
1173 if [ -b "${cowprobe}" ]
1175 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1176 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1177 # snapshots to be sure to really store some e.g key config files,
1178 # but not on the same media
1179 blacklistdev="${cowprobe}"
1180 PERSISTENCE_IS_ON="1"
1181 export PERSISTENCE_IS_ON
1183 # homecow just mount something on /home, this should be generalized some way
1184 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1185 if [ -b "${homecow}" ]
1187 PERSISTENCE_IS_ON="1"
1188 export PERSISTENCE_IS_ON
1190 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1191 # This second type should be removed when snapshot will get smarter,
1192 # hence when "/etc/live-snapshot*list" will be supported also by
1193 # ext2|ext3|jffs2 snapshot types.
1194 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1196 if [ -b "${cowprobe}" ]
1198 cowdevice=${cowprobe}
1199 cow_fstype=$(get_fstype "${cowprobe}")
1200 cow_mountopt="rw,noatime"
1202 log_warning_msg "Unable to find the persistent medium"
1205 cow_mountopt="rw,noatime,mode=755"
1207 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1209 # check if there are any nfs options
1210 if echo ${NFS_COW}|grep -q ','
1212 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1213 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1215 nfs_cow_opts="-o nolock"
1221 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1224 panic "unable to determine mac address"
1229 cow_mountopt="rw,noatime,mode=755"
1232 if [ "${cow_fstype}" = "nfs" ]
1235 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1236 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1237 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1239 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1240 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1243 rofscount=$(echo ${rofslist} |wc -w)
1245 if [ -n "${EXPOSED_ROOT}" ]
1247 if [ ${rofscount} -ne 1 ]
1249 panic "only one RO file system supported with exposedroot: ${rofslist}"
1251 exposedrootfs=${rofslist%% }
1253 mount --bind ${exposedrootfs} ${rootmnt} || \
1254 panic "bind mount of ${exposedrootfs} failed"
1256 if [ -z "${SKIP_UNION_MOUNTS}" ]
1258 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1263 for dir in ${cow_dirs}; do
1265 mount -t ${UNIONTYPE} \
1266 -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
1267 ${UNIONTYPE} "${rootmnt}${dir}" || \
1268 panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
1269 rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1272 mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
1273 ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
1274 ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
1277 # tmpfs file systems
1279 mkdir -p "${rootmnt}/live"
1280 mount -t tmpfs tmpfs ${rootmnt}/live
1282 # Adding other custom mounts
1283 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1285 # directly mount /home
1286 # FIXME: add a custom mounts configurable system
1288 if [ -b "${homecow}" ]
1290 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1291 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1293 log_warning_msg "Unable to find the persistent home medium"
1296 # Look for other snapshots to copy in
1297 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1298 # This second type should be removed when snapshot grow smarter
1299 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1302 if [ -n "${SHOWMOUNTS}" ]
1304 for d in ${rofslist}
1306 mkdir -p "${rootmnt}/live/${d##*/}"
1310 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1314 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1320 # shows cow fs on /cow for use by live-snapshot
1321 mkdir -p "${rootmnt}/live/cow"
1322 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"
1329 skip_uuid_check="${3}"
1331 if [ -z "${devname}" ]
1333 devname=$(sys2dev "${sysdev}")
1336 if [ -d "${devname}" ]
1338 mount -o bind "${devname}" $mountpoint || continue
1340 if is_live_path $mountpoint
1349 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1351 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1352 devname="${loopdevname}"
1355 fstype=$(get_fstype "${devname}")
1357 if is_supported_fs ${fstype}
1359 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1361 if is_live_path ${mountpoint} && \
1362 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1367 umount ${mountpoint}
1371 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1373 losetup -d "${loopdevname}"
1383 # first look at the one specified in the command line
1384 if [ ! -z "${LIVE_MEDIA}" ]
1386 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1392 # don't start autodetection before timeout has expired
1393 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1395 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1401 # or do the scan of block devices
1402 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1404 devname=$(sys2dev "${sysblock}")
1405 fstype=$(get_fstype "${devname}")
1407 if /lib/udev/cdrom_id ${devname} > /dev/null
1409 if check_dev "null" "${devname}"
1413 elif is_nice_device "${sysblock}"
1415 for dev in $(subdevices "${sysblock}")
1417 if check_dev "${dev}"
1422 elif [ "${fstype}" = "squashfs" -o \
1423 "${fstype}" = "ext2" -o \
1424 "${fstype}" = "ext3" -o \
1425 "${fstype}" = "jffs2" ]
1427 # This is an ugly hack situation, the block device has
1428 # an image directly on it. It's hopefully
1429 # live-initramfs, so take it and run with it.
1430 ln -s "${devname}" "${devname}.${fstype}"
1431 echo "${devname}.${fstype}"
1439 set_usplash_timeout ()
1441 if [ -x /sbin/usplash_write ]
1443 /sbin/usplash_write "TIMEOUT 120"
1444 else if [ -x /sbin/splashy_update ] ; then
1445 /sbin/splashy_update "TIMEOUT 120"
1451 media_mountpoint="${1}"
1453 log_begin_msg "Checking media integrity"
1455 cd ${media_mountpoint}
1456 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1461 if [ "${RC}" -eq 0 ]
1463 log_success_msg "Everything ok, will reboot in 10 seconds."
1466 umount ${media_mountpoint}
1468 echo u > /proc/sysrq-trigger
1469 echo b > /proc/sysrq-trigger
1471 panic "Not ok, a media defect is likely, switch to VT8 for details."
1477 if [ -x /scripts/local-top/cryptroot ]; then
1478 /scripts/local-top/cryptroot
1485 tail -f live.log >&7 &
1488 # Ensure 'panic' function is overridden
1489 . /scripts/live-functions
1495 maybe_break live-premount
1496 log_begin_msg "Running /scripts/live-premount"
1497 run_scripts /scripts/live-premount
1500 # Needed here too because some things (*cough* udev *cough*)
1501 # changes the timeout
1505 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1509 livefs_root="${mountpoint}"
1511 panic "Unable to find a live file system on the network"
1514 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1516 # Do a local boot from hd
1519 # Scan local devices for the image
1521 while [ "$i" -lt 60 ]
1523 livefs_root=$(find_livefs ${i})
1525 if [ -n "${livefs_root}" ]
1536 if [ -z "${livefs_root}" ]
1538 panic "Unable to find a medium containing a live file system"
1541 if [ "${INTEGRITY_CHECK}" ]
1543 integrity_check "${livefs_root}"
1549 elif [ "${TODISK}" ]
1551 live_dest="${TODISK}"
1554 if [ "${live_dest}" ]
1556 log_begin_msg "Copying live media to ${live_dest}"
1557 copy_live_to "${livefs_root}" "${live_dest}"
1561 if [ -n "${MODULETORAMFILE}" ]
1563 setup_unionfs "${livefs_root}" "${rootmnt}"
1566 mac="$(echo ${mac} | sed 's/-//g')"
1567 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1572 maybe_break live-bottom
1573 log_begin_msg "Running /scripts/live-bottom\n"
1575 run_scripts /scripts/live-bottom
1581 cp live.log "${rootmnt}/var/log/"