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}" ]
344 PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
345 export PERSISTENT_PATH
353 preseed/file=*|file=*)
354 LOCATION="${ARGUMENT#*=}"
364 location="${ARGUMENT#url=}"
366 mount -o bind /sys /root/sys
367 mount -o bind /proc /root/proc
368 mount -o bind /dev /root/dev
370 mkdir -p /root/var/run/network
371 chroot /root dhclient eth0
372 chroot /root wget -P /tmp "${location}"
373 chroot /root ifconfig eth0 down
379 LOCATION="/tmp/$(basename "${location}")"
383 question="${ARGUMENT%%=*}"
384 value="${ARGUMENT#*=}"
385 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
400 TIMEZONE="${ARGUMENT#timezone=}"
410 TODISK="${ARGUMENT#todisk=}"
421 MODULETORAM="${ARGUMENT#toram=}"
422 export TORAM MODULETORAM
436 SKIP_UNION_MOUNTS="Yes"
437 export SKIP_UNION_MOUNTS
441 ROOT="${ARGUMENT#root=}"
446 UNIONTYPE="${ARGUMENT#union=}"
451 UTC="${ARGUMENT#utc=}"
461 XDRIVER="${ARGUMENT#xdriver=}"
466 XVIDEOMODE="${ARGUMENT#xvideomode=}"
472 # sort of compatibility with netboot.h from linux docs
473 if [ -z "${NETBOOT}" ]
475 if [ "${ROOT}" = "/dev/nfs" ]
479 elif [ "${ROOT}" = "/dev/cifs" ]
486 if [ -z "${MODULE}" ]
492 if [ -z "${UNIONTYPE}" ]
503 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
505 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
507 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
519 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
525 uuid="$(cat /conf/uuid.conf)"
527 for try_uuid_file in "${path}/.disk/live-uuid"*
529 [ -e "${try_uuid_file}" ] || continue
531 try_uuid="$(cat "${try_uuid_file}")"
533 if [ "${uuid}" = "${try_uuid}" ]
542 get_backing_device ()
545 *.squashfs|*.ext2|*.ext3|*.ext4|*.jffs2)
546 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
554 panic "Unrecognized live filesystem: ${1}"
559 match_files_in_dir ()
561 # Does any files match pattern ${1} ?
564 if [ "$(echo ${pattern})" != "${pattern}" ]
572 mount_images_in_directory ()
579 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
580 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
581 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
582 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
583 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
584 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
586 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
587 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
589 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
595 sysfs_path="${1#/sys}"
597 if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-(ide|scsi|usb))"
600 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
612 copyto="${copyfrom}_swap"
614 if [ -z "${MODULETORAM}" ]
616 size=$(fs_size "" ${copyfrom} "used")
618 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
620 if [ -f "${MODULETORAMFILE}" ]
622 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
624 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
629 if [ "${copytodev}" = "ram" ]
632 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
633 mount_options="-o size=${size}k"
638 # it should be a writable block device
639 if [ -b "${copytodev}" ]
643 fstype=$(get_fstype "${dev}")
644 freespace=$(fs_size "${dev}")
646 log_warning_msg "${copytodev} is not a block device."
651 if [ "${freespace}" -lt "${size}" ]
653 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
657 # begin copying (or uncompressing)
659 echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
660 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
662 if [ "${extension}" = "tgz" ]
665 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
666 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
667 mount -r -o move "${copyto}" "${rootmnt}"
670 if [ -n "${MODULETORAMFILE}" ]
672 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
674 cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files
678 mount -r -o move ${copyto} ${copyfrom}
689 modprobe -q af_packet # For DHCP
691 if [ -x /sbin/udevadm ]
702 ipconfig ${DEVICE} | tee /netboot.config
704 # source relevant ipconfig output
705 OLDHOSTNAME=${HOSTNAME}
706 . /tmp/net-${DEVICE}.conf
707 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
710 # Check if we have a network device at all
711 if ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
712 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
713 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
714 ! ls /sys/class/net/ra0 > /dev/null 2>&1
716 panic "No supported network device found, maybe a non-mainline driver is required."
719 if [ "${NFSROOT}" = "auto" ]
721 NFSROOT=${ROOTSERVER}:${ROOTPATH}
724 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
730 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
732 NFSROOT=${ROOTSERVER}:${NFSROOT}
735 log_begin_msg "Trying netboot from ${NFSROOT}"
737 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
754 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
755 mount -t ramfs ram "${mountpoint}"
758 for webfile in HTTPFS FTPFS FETCH
760 url="$(eval echo \"\$\{${webfile}\}\")"
761 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
765 case "${extension}" in
767 if [ "${webfile}" = "FETCH" ]
771 ip="$(dirname $url | sed -e 's|tftp://||g')"
772 log_begin_msg "Trying tftp -g -b 10240 -r $(basename ${url}) -l ${dest}/$(basename ${url}) $ip"
773 tftp -g -b 10240 -r $(basename ${url}) -l ${dest}/$(basename ${url}) $ip
777 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
778 wget "${url}" -O "${dest}/$(basename ${url})"
782 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
783 if [ "${webfile}" = "FTPFS" ]
785 FUSE_MOUNT="curlftpfs"
786 url="$(dirname ${url})"
791 $FUSE_MOUNT "${url}" "${dest}"
793 [ ${?} -eq 0 ] && rc=0
794 [ "${extension}" = "tgz" ] && live_dest="ram"
799 log_begin_msg "Unrecognized archive extension for ${url}"
807 umount "${mountpoint}"
819 if [ -z "${NFSOPTS}" ]
824 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
826 # FIXME: This while loop is an ugly HACK round an nfs bug
828 while [ "$i" -lt 60 ]
830 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
842 if [ -x "/sbin/mount.cifs" ]
844 if [ -z "${NFSOPTS}" ]
846 CIFSOPTS="-ouser=root,password="
848 CIFSOPTS="${NFSOPTS}"
851 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
854 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
868 size=$(fs_size "${fromdev}" "" "used")
870 if [ -b "${fromdev}" ]
873 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
875 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
876 freespace=$(df -k | awk '/'${todev}'/{print $4}')
878 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
881 tomount="/mnt/tmpsnap"
883 if [ ! -d "${tomount}" ]
885 mkdir -p "${tomount}"
888 fstype=$(get_fstype "${fromdev}")
890 if [ -n "${fstype}" ]
893 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
894 cp -a "${tomount}"/* ${todir}
897 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
902 if echo ${fromdev} | grep -qs loop
904 losetup -d "${fromdev}"
911 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
917 # Look for ${snap_label}.* in block devices
920 if [ "${PERSISTENT}" != "nofiles" ]
922 # search for image files
923 snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snal_label}.ext4 ${snap_label}.jffs2")
926 if [ -z "${snapdata}" ]
928 snapdata=$(find_cow_device "${snap_label}")
935 # copy the contents of previously found snapshot to ${snap_mount}
936 # and remember the device and filename for resync on exit in live-initramfs.init
942 if [ ! -z "${snapdata}" ]
944 log_success_msg "found snapshot: ${snapdata}"
945 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
946 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
947 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
950 if ! try_mount "${snapdev}" "${snapback}" "ro"
955 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
957 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
958 dev=$(get_backing_device "${snapback}/${snapfile}")
960 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
965 zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
967 if [ "${RES}" != "0" ]
969 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
974 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
976 if [ "${RES}" != "0" ]
978 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
982 elif [ -b "${snapdata}" ]
984 # Try to find if it could be a snapshot partition
986 log_success_msg "found snapshot device on ${dev}"
987 if echo "${dev}" | grep -qs loop
989 # strange things happens, user confused?
990 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
991 snapfile=$(basename ${snaploop})
992 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
997 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
999 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1002 if [ -n "${snapfile}" ]
1004 # it was a loop device, user confused
1009 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1013 echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1019 image_directory="${1}"
1021 addimage_directory="${3}"
1022 modprobe -q -b ${UNIONTYPE}
1024 # run-init can't deal with images in a subdir, but we're going to
1025 # move all of these away before it runs anyway. No, we're not,
1026 # put them in / since move-mounting them into / breaks mono and
1031 # Let's just mount the read-only file systems first
1034 minor_kernel_version=$(uname -r|cut -c 5-|sed 's/[^0-9].*//')
1036 if [ "${NETBOOT}" = "nfs" ] && [ "${minor_kernel_version}" -lt 22 ]
1038 # go aroung a bug in nfs-unionfs locking for unionfs <= 1.4
1040 elif [ "${UNIONTYPE}" = "aufs" ]
1047 # Read image names from ${MODULE}.module if it exists
1048 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1050 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1052 image_string="${image_string} ${image_directory}/${IMAGE}"
1054 elif [ -e "${image_directory}/${MODULE}.module" ]
1056 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1058 image_string="${image_string} ${image_directory}/${IMAGE}"
1061 # ${MODULE}.module does not exist, create a list of images
1062 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1064 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1066 if [ -e "${IMAGE}" ]
1068 image_string="${image_string} ${IMAGE}"
1073 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1075 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1077 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1079 if [ -e "${IMAGE}" ]
1081 image_string="${image_string} ${IMAGE}"
1088 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1091 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1095 for image in ${image_string}
1097 imagename=$(basename "${image}")
1099 export image devname
1100 maybe_break live-realpremount
1101 log_begin_msg "Running /scripts/live-realpremount"
1102 run_scripts /scripts/live-realpremount
1105 if [ -d "${image}" ]
1107 # it is a plain directory: do nothing
1108 rofsstring="${image}=${roopt}:${rofsstring}"
1109 rofslist="${image} ${rofslist}"
1110 elif [ -f "${image}" ]
1112 if losetup --help 2>&1 | grep -q -- "-r\b"
1114 backdev=$(get_backing_device "${image}" "-r")
1116 backdev=$(get_backing_device "${image}")
1118 fstype=$(get_fstype "${backdev}")
1120 if [ "${fstype}" = "unknown" ]
1122 panic "Unknown file system type on ${backdev} (${image})"
1125 if [ -z "${fstype}" ]
1127 fstype="${imagename##*.}"
1128 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1131 mkdir -p "${croot}/${imagename}"
1132 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1133 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}"
1138 rofsstring=${rofsstring%:}
1142 # Looking for "${root_persistence}" device or file
1143 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1146 num_block=$(ls -l /sys/block | wc -l)
1147 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1149 modprobe -q -b ${module}
1152 if [ -x /sbin/udevadm ]
1163 # For some reason, udevsettle does not block in this scenario,
1164 # so we sleep for a little while.
1166 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1167 for timeout in 5 4 3 2 1
1171 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1177 # search for label and files (this could be hugely optimized)
1178 cowprobe=$(find_cow_device "${root_persistence}")
1179 if [ -b "${cowprobe}" ]
1181 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1182 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1183 # snapshots to be sure to really store some e.g key config files,
1184 # but not on the same media
1185 blacklistdev="${cowprobe}"
1186 PERSISTENCE_IS_ON="1"
1187 export PERSISTENCE_IS_ON
1189 # homecow just mount something on /home, this should be generalized some way
1190 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1191 if [ -b "${homecow}" ]
1193 PERSISTENCE_IS_ON="1"
1194 export PERSISTENCE_IS_ON
1196 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1197 # This second type should be removed when snapshot will get smarter,
1198 # hence when "/etc/live-snapshot*list" will be supported also by
1199 # ext2|ext3|ext4|jffs2 snapshot types.
1200 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1202 if [ -b "${cowprobe}" ]
1204 cowdevice=${cowprobe}
1205 cow_fstype=$(get_fstype "${cowprobe}")
1206 cow_mountopt="rw,noatime"
1208 log_warning_msg "Unable to find the persistent medium"
1211 cow_mountopt="rw,noatime,mode=755"
1213 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1215 # check if there are any nfs options
1216 if echo ${NFS_COW}|grep -q ','
1218 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1219 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1221 nfs_cow_opts="-o nolock"
1227 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1230 panic "unable to determine mac address"
1235 cow_mountopt="rw,noatime,mode=755"
1238 if [ "${cow_fstype}" = "nfs" ]
1241 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1242 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1243 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1245 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1246 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1249 rofscount=$(echo ${rofslist} |wc -w)
1251 if [ -n "${EXPOSED_ROOT}" ]
1253 if [ ${rofscount} -ne 1 ]
1255 panic "only one RO file system supported with exposedroot: ${rofslist}"
1257 exposedrootfs=${rofslist%% }
1259 mount --bind ${exposedrootfs} ${rootmnt} || \
1260 panic "bind mount of ${exposedrootfs} failed"
1262 if [ -z "${SKIP_UNION_MOUNTS}" ]
1264 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1269 for dir in ${cow_dirs}; do
1271 mount -t ${UNIONTYPE} \
1272 -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
1273 ${UNIONTYPE} "${rootmnt}${dir}" || \
1274 panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
1275 rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1278 mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
1279 ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
1280 ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
1283 # tmpfs file systems
1285 mkdir -p "${rootmnt}/live"
1286 mount -t tmpfs tmpfs ${rootmnt}/live
1288 # Adding other custom mounts
1289 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1291 # directly mount /home
1292 # FIXME: add a custom mounts configurable system
1294 if [ -b "${homecow}" ]
1296 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1297 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1299 log_warning_msg "Unable to find the persistent home medium"
1302 # Look for other snapshots to copy in
1303 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1304 # This second type should be removed when snapshot grow smarter
1305 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1308 if [ -n "${SHOWMOUNTS}" ]
1310 for d in ${rofslist}
1312 mkdir -p "${rootmnt}/live/${d##*/}"
1316 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1320 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1326 # shows cow fs on /cow for use by live-snapshot
1327 mkdir -p "${rootmnt}/live/cow"
1328 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"
1335 skip_uuid_check="${3}"
1337 if [ -z "${devname}" ]
1339 devname=$(sys2dev "${sysdev}")
1342 if [ -d "${devname}" ]
1344 mount -o bind "${devname}" $mountpoint || continue
1346 if is_live_path $mountpoint
1355 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1357 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1358 devname="${loopdevname}"
1361 fstype=$(get_fstype "${devname}")
1363 if is_supported_fs ${fstype}
1365 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1367 if is_live_path ${mountpoint} && \
1368 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1373 umount ${mountpoint}
1377 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1379 losetup -d "${loopdevname}"
1389 # first look at the one specified in the command line
1390 if [ ! -z "${LIVE_MEDIA}" ]
1392 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1398 # don't start autodetection before timeout has expired
1399 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1401 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1407 # or do the scan of block devices
1408 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1410 devname=$(sys2dev "${sysblock}")
1411 fstype=$(get_fstype "${devname}")
1413 if /lib/udev/cdrom_id ${devname} > /dev/null
1415 if check_dev "null" "${devname}"
1419 elif is_nice_device "${sysblock}"
1421 for dev in $(subdevices "${sysblock}")
1423 if check_dev "${dev}"
1428 elif [ "${fstype}" = "squashfs" -o \
1429 "${fstype}" = "ext2" -o \
1430 "${fstype}" = "ext3" -o \
1431 "${fstype}" = "ext4" -o \
1432 "${fstype}" = "jffs2" ]
1434 # This is an ugly hack situation, the block device has
1435 # an image directly on it. It's hopefully
1436 # live-initramfs, so take it and run with it.
1437 ln -s "${devname}" "${devname}.${fstype}"
1438 echo "${devname}.${fstype}"
1446 set_usplash_timeout ()
1448 if [ -x /sbin/usplash_write ]
1450 /sbin/usplash_write "TIMEOUT 120"
1451 else if [ -x /sbin/splashy_update ] ; then
1452 /sbin/splashy_update "TIMEOUT 120"
1458 media_mountpoint="${1}"
1460 log_begin_msg "Checking media integrity"
1462 cd ${media_mountpoint}
1463 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1468 if [ "${RC}" -eq 0 ]
1470 log_success_msg "Everything ok, will reboot in 10 seconds."
1473 umount ${media_mountpoint}
1475 echo u > /proc/sysrq-trigger
1476 echo b > /proc/sysrq-trigger
1478 panic "Not ok, a media defect is likely, switch to VT8 for details."
1484 if [ -x /scripts/local-top/cryptroot ]; then
1485 /scripts/local-top/cryptroot
1492 tail -f live.log >&7 &
1495 # Ensure 'panic' function is overridden
1496 . /scripts/live-functions
1502 maybe_break live-premount
1503 log_begin_msg "Running /scripts/live-premount"
1504 run_scripts /scripts/live-premount
1507 # Needed here too because some things (*cough* udev *cough*)
1508 # changes the timeout
1512 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1516 livefs_root="${mountpoint}"
1518 panic "Unable to find a live file system on the network"
1521 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1523 # Do a local boot from hd
1526 # Scan local devices for the image
1528 while [ "$i" -lt 60 ]
1530 livefs_root=$(find_livefs ${i})
1532 if [ -n "${livefs_root}" ]
1543 if [ -z "${livefs_root}" ]
1545 panic "Unable to find a medium containing a live file system"
1548 if [ "${INTEGRITY_CHECK}" ]
1550 integrity_check "${livefs_root}"
1556 elif [ "${TODISK}" ]
1558 live_dest="${TODISK}"
1561 if [ "${live_dest}" ]
1563 log_begin_msg "Copying live media to ${live_dest}"
1564 copy_live_to "${livefs_root}" "${live_dest}"
1568 if [ -n "${MODULETORAMFILE}" ]
1570 setup_unionfs "${livefs_root}" "${rootmnt}"
1573 mac="$(echo ${mac} | sed 's/-//g')"
1574 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1579 maybe_break live-bottom
1580 log_begin_msg "Running /scripts/live-bottom\n"
1582 run_scripts /scripts/live-bottom
1588 cp live.log "${rootmnt}/var/log/"