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 ROOT="${ARGUMENT#root=}"
436 UNIONTYPE="${ARGUMENT#union=}"
441 UTC="${ARGUMENT#utc=}"
451 XDRIVER="${ARGUMENT#xdriver=}"
456 XVIDEOMODE="${ARGUMENT#xvideomode=}"
462 # sort of compatibility with netboot.h from linux docs
463 if [ -z "${NETBOOT}" ]
465 if [ "${ROOT}" = "/dev/nfs" ]
469 elif [ "${ROOT}" = "/dev/cifs" ]
476 if [ -z "${MODULE}" ]
482 if [ -z "${UNIONTYPE}" ]
493 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
495 for FILESYSTEM in squashfs ext2 ext3 xfs dir jffs2
497 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
509 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
515 uuid="$(cat /conf/uuid.conf)"
517 for try_uuid_file in "${path}/.disk/live-uuid"*
519 [ -e "${try_uuid_file}" ] || continue
521 try_uuid="$(cat "${try_uuid_file}")"
523 if [ "${uuid}" = "${try_uuid}" ]
532 get_backing_device ()
535 *.squashfs|*.ext2|*.ext3|*.jffs2)
536 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
544 panic "Unrecognized live filesystem: ${1}"
549 match_files_in_dir ()
551 # Does any files match pattern ${1} ?
554 if [ "$(echo ${pattern})" != "${pattern}" ]
562 mount_images_in_directory ()
569 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
570 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
571 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
572 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
573 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
575 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
576 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
578 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
584 sysfs_path="${1#/sys}"
586 if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-(ide|scsi|usb))"
589 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
601 copyto="${copyfrom}_swap"
603 if [ -z "${MODULETORAM}" ]
605 size=$(fs_size "" ${copyfrom} "used")
607 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
609 if [ -f "${MODULETORAMFILE}" ]
611 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
613 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
618 if [ "${copytodev}" = "ram" ]
621 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
622 mount_options="-o size=${size}k"
627 # it should be a writable block device
628 if [ -b "${copytodev}" ]
632 fstype=$(get_fstype "${dev}")
633 freespace=$(fs_size "${dev}")
635 log_warning_msg "${copytodev} is not a block device."
640 if [ "${freespace}" -lt "${size}" ]
642 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
646 # begin copying (or uncompressing)
648 echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
649 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
651 if [ "${extension}" = "tgz" ]
654 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
655 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
656 mount -r -o move "${copyto}" "${rootmnt}"
659 if [ -n "${MODULETORAMFILE}" ]
661 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
663 cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files
667 mount -r -o move ${copyto} ${copyfrom}
678 modprobe -q af_packet # For DHCP
680 if [ -x /sbin/udevadm ]
691 ipconfig ${DEVICE} | tee /netboot.config
693 # source relevant ipconfig output
694 OLDHOSTNAME=${HOSTNAME}
695 . /tmp/net-${DEVICE}.conf
696 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
699 # Check if we have a network device at all
700 if ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
701 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
702 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
703 ! ls /sys/class/net/ra0 > /dev/null 2>&1
705 panic "No supported network device found, maybe a non-mainline driver is required."
708 if [ "${NFSROOT}" = "auto" ]
710 NFSROOT=${ROOTSERVER}:${ROOTPATH}
713 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
719 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
721 NFSROOT=${ROOTSERVER}:${NFSROOT}
724 log_begin_msg "Trying netboot from ${NFSROOT}"
726 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
743 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
744 mount -t ramfs ram "${mountpoint}"
747 for webfile in HTTPFS FTPFS FETCH
749 url="$(eval echo \"\$\{${webfile}\}\")"
750 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
754 case "${extension}" in
756 if [ "${webfile}" = "FETCH" ]
760 ip="$(dirname $url | sed -e 's|tftp://||g')"
761 log_begin_msg "Trying tftp -g -b 10240 -r $(basename ${url}) -l ${dest}/$(basename ${url}) $ip"
762 tftp -g -b 10240 -r $(basename ${url}) -l ${dest}/$(basename ${url}) $ip
766 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
767 wget "${url}" -O "${dest}/$(basename ${url})"
771 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
772 if [ "${webfile}" = "FTPFS" ]
774 FUSE_MOUNT="curlftpfs"
775 url="$(dirname ${url})"
780 $FUSE_MOUNT "${url}" "${dest}"
782 [ ${?} -eq 0 ] && rc=0
783 [ "${extension}" = "tgz" ] && live_dest="ram"
788 log_begin_msg "Unrecognized archive extension for ${url}"
796 umount "${mountpoint}"
808 if [ -z "${NFSOPTS}" ]
813 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
815 # FIXME: This while loop is an ugly HACK round an nfs bug
817 while [ "$i" -lt 60 ]
819 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
831 if [ -x "/sbin/mount.cifs" ]
833 if [ -z "${NFSOPTS}" ]
835 CIFSOPTS="-ouser=root,password="
837 CIFSOPTS="${NFSOPTS}"
840 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
843 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
857 size=$(fs_size "${fromdev}" "" "used")
859 if [ -b "${fromdev}" ]
862 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
864 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
865 freespace=$(df -k | awk '/'${todev}'/{print $4}')
867 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
870 tomount="/mnt/tmpsnap"
872 if [ ! -d "${tomount}" ]
874 mkdir -p "${tomount}"
877 fstype=$(get_fstype "${fromdev}")
879 if [ -n "${fstype}" ]
882 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
883 cp -a "${tomount}"/* ${todir}
886 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
891 if echo ${fromdev} | grep -qs loop
893 losetup -d "${fromdev}"
900 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
906 # Look for ${snap_label}.* in block devices
909 if [ "${PERSISTENT}" != "nofiles" ]
911 # search for image files
912 snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snap_label}.jffs2")
915 if [ -z "${snapdata}" ]
917 snapdata=$(find_cow_device "${snap_label}")
924 # copy the contents of previously found snapshot to ${snap_mount}
925 # and remember the device and filename for resync on exit in live-initramfs.init
931 if [ ! -z "${snapdata}" ]
933 log_success_msg "found snapshot: ${snapdata}"
934 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
935 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
936 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
939 if ! try_mount "${snapdev}" "${snapback}" "ro"
944 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|jffs2\)'
946 # squashfs, jffs2 or ext2/ext3 snapshot
947 dev=$(get_backing_device "${snapback}/${snapfile}")
949 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
954 zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
956 if [ "${RES}" != "0" ]
958 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
963 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
965 if [ "${RES}" != "0" ]
967 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
971 elif [ -b "${snapdata}" ]
973 # Try to find if it could be a snapshot partition
975 log_success_msg "found snapshot device on ${dev}"
976 if echo "${dev}" | grep -qs loop
978 # strange things happens, user confused?
979 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
980 snapfile=$(basename ${snaploop})
981 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
986 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
988 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
991 if [ -n "${snapfile}" ]
993 # it was a loop device, user confused
998 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1002 echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1008 image_directory="${1}"
1010 addimage_directory="${3}"
1011 modprobe -q -b ${UNIONTYPE}
1013 # run-init can't deal with images in a subdir, but we're going to
1014 # move all of these away before it runs anyway. No, we're not,
1015 # put them in / since move-mounting them into / breaks mono and
1020 # Let's just mount the read-only file systems first
1023 minor_kernel_version=$(uname -r|cut -c 5-|sed 's/[^0-9].*//')
1025 if [ "${NETBOOT}" = "nfs" ] && [ "${minor_kernel_version}" -lt 22 ]
1027 # go aroung a bug in nfs-unionfs locking for unionfs <= 1.4
1029 elif [ "${UNIONTYPE}" = "aufs" ]
1036 # Read image names from ${MODULE}.module if it exists
1037 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1039 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1041 image_string="${image_string} ${image_directory}/${IMAGE}"
1043 elif [ -e "${image_directory}/${MODULE}.module" ]
1045 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1047 image_string="${image_string} ${image_directory}/${IMAGE}"
1050 # ${MODULE}.module does not exist, create a list of images
1051 for FILESYSTEM in squashfs ext2 ext3 xfs jffs2 dir
1053 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1055 if [ -e "${IMAGE}" ]
1057 image_string="${image_string} ${IMAGE}"
1062 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1064 for FILESYSTEM in squashfs ext2 ext3 xfs jffs2 dir
1066 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1068 if [ -e "${IMAGE}" ]
1070 image_string="${image_string} ${IMAGE}"
1077 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1080 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1084 for image in ${image_string}
1086 imagename=$(basename "${image}")
1088 if [ -d "${image}" ]
1090 # it is a plain directory: do nothing
1091 rofsstring="${image}=${roopt}:${rofsstring}"
1092 rofslist="${image} ${rofslist}"
1093 elif [ -f "${image}" ]
1095 if losetup --help 2>&1 | grep -q -- "-r\b"
1097 backdev=$(get_backing_device "${image}" "-r")
1099 backdev=$(get_backing_device "${image}")
1101 fstype=$(get_fstype "${backdev}")
1103 if [ "${fstype}" = "unknown" ]
1105 panic "Unknown file system type on ${backdev} (${image})"
1108 if [ -z "${fstype}" ]
1110 fstype="${imagename##*.}"
1111 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1114 mkdir -p "${croot}/${imagename}"
1115 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1116 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}"
1121 rofsstring=${rofsstring%:}
1125 # Looking for "${root_persistence}" device or file
1126 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1129 num_block=$(ls -l /sys/block | wc -l)
1130 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1132 modprobe -q -b ${module}
1135 if [ -x /sbin/udevadm ]
1146 # For some reason, udevsettle does not block in this scenario,
1147 # so we sleep for a little while.
1149 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1150 for timeout in 5 4 3 2 1
1154 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1160 # search for label and files (this could be hugely optimized)
1161 cowprobe=$(find_cow_device "${root_persistence}")
1162 if [ -b "${cowprobe}" ]
1164 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1165 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1166 # snapshots to be sure to really store some e.g key config files,
1167 # but not on the same media
1168 blacklistdev="${cowprobe}"
1169 PERSISTENCE_IS_ON="1"
1170 export PERSISTENCE_IS_ON
1172 # homecow just mount something on /home, this should be generalized some way
1173 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1174 if [ -b "${homecow}" ]
1176 PERSISTENCE_IS_ON="1"
1177 export PERSISTENCE_IS_ON
1179 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1180 # This second type should be removed when snapshot will get smarter,
1181 # hence when "/etc/live-snapshot*list" will be supported also by
1182 # ext2|ext3|jffs2 snapshot types.
1183 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1185 if [ -b "${cowprobe}" ]
1187 cowdevice=${cowprobe}
1188 cow_fstype=$(get_fstype "${cowprobe}")
1189 cow_mountopt="rw,noatime"
1191 log_warning_msg "Unable to find the persistent medium"
1194 cow_mountopt="rw,noatime,mode=755"
1196 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1198 # check if there are any nfs options
1199 if echo ${NFS_COW}|grep -q ','
1201 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1202 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1204 nfs_cow_opts="-o nolock"
1210 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1213 panic "unable to determine mac address"
1218 cow_mountopt="rw,noatime,mode=755"
1221 if [ "${cow_fstype}" = "nfs" ]
1224 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1225 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1226 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1228 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1229 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1232 rofscount=$(echo ${rofslist} |wc -w)
1234 if [ -n "${EXPOSED_ROOT}" ]
1236 if [ ${rofscount} -ne 1 ]
1238 panic "only one RO file system supported with exposedroot: ${rofslist}"
1240 exposedrootfs=${rofslist%% }
1242 mount --bind ${exposedrootfs} ${rootmnt} || \
1243 panic "bind mount of ${exposedrootfs} failed"
1245 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool
1246 /home /var/lib/live'
1248 for dir in ${cow_dirs}; do
1250 mount -t ${UNIONTYPE} \
1251 -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
1252 ${UNIONTYPE} "${rootmnt}${dir}" || \
1253 panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
1254 rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1257 mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
1258 ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
1259 ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
1262 # tmpfs file systems
1264 mkdir -p "${rootmnt}/live"
1265 mount -t tmpfs tmpfs ${rootmnt}/live
1267 # Adding other custom mounts
1268 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1270 # directly mount /home
1271 # FIXME: add a custom mounts configurable system
1273 if [ -b "${homecow}" ]
1275 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1276 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1278 log_warning_msg "Unable to find the persistent home medium"
1281 # Look for other snapshots to copy in
1282 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1283 # This second type should be removed when snapshot grow smarter
1284 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1287 if [ -n "${SHOWMOUNTS}" ]
1289 for d in ${rofslist}
1291 mkdir -p "${rootmnt}/live/${d##*/}"
1295 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1299 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1305 # shows cow fs on /cow for use by live-snapshot
1306 mkdir -p "${rootmnt}/live/cow"
1307 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"
1314 skip_uuid_check="${3}"
1316 if [ -z "${devname}" ]
1318 devname=$(sys2dev "${sysdev}")
1321 if [ -d "${devname}" ]
1323 mount -o bind "${devname}" $mountpoint || continue
1325 if is_live_path $mountpoint
1334 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1336 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1337 devname="${loopdevname}"
1340 fstype=$(get_fstype "${devname}")
1342 if is_supported_fs ${fstype}
1344 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1346 if is_live_path ${mountpoint} && \
1347 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1352 umount ${mountpoint}
1356 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1358 losetup -d "${loopdevname}"
1368 # first look at the one specified in the command line
1369 if [ ! -z "${LIVE_MEDIA}" ]
1371 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1377 # don't start autodetection before timeout has expired
1378 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1380 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1386 # or do the scan of block devices
1387 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1389 devname=$(sys2dev "${sysblock}")
1390 fstype=$(get_fstype "${devname}")
1392 if /lib/udev/cdrom_id ${devname} > /dev/null
1394 if check_dev "null" "${devname}"
1398 elif is_nice_device "${sysblock}"
1400 for dev in $(subdevices "${sysblock}")
1402 if check_dev "${dev}"
1407 elif [ "${fstype}" = "squashfs" -o \
1408 "${fstype}" = "ext2" -o \
1409 "${fstype}" = "ext3" -o \
1410 "${fstype}" = "jffs2" ]
1412 # This is an ugly hack situation, the block device has
1413 # an image directly on it. It's hopefully
1414 # live-initramfs, so take it and run with it.
1415 ln -s "${devname}" "${devname}.${fstype}"
1416 echo "${devname}.${fstype}"
1424 set_usplash_timeout ()
1426 if [ -x /sbin/usplash_write ]
1428 /sbin/usplash_write "TIMEOUT 120"
1429 else if [ -x /sbin/splashy_update ] ; then
1430 /sbin/splashy_update "TIMEOUT 120"
1436 media_mountpoint="${1}"
1438 log_begin_msg "Checking media integrity"
1440 cd ${media_mountpoint}
1441 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1446 if [ "${RC}" -eq 0 ]
1448 log_success_msg "Everything ok, will reboot in 10 seconds."
1451 umount ${media_mountpoint}
1453 echo u > /proc/sysrq-trigger
1454 echo b > /proc/sysrq-trigger
1456 panic "Not ok, a media defect is likely, switch to VT8 for details."
1462 if [ -x /scripts/local-top/cryptroot ]; then
1463 /scripts/local-top/cryptroot
1470 tail -f live.log >&7 &
1473 # Ensure 'panic' function is overridden
1474 . /scripts/live-functions
1480 maybe_break live-premount
1481 log_begin_msg "Running /scripts/live-premount"
1482 run_scripts /scripts/live-premount
1485 # Needed here too because some things (*cough* udev *cough*)
1486 # changes the timeout
1490 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1494 livefs_root="${mountpoint}"
1496 panic "Unable to find a live file system on the network"
1499 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1501 # Do a local boot from hd
1504 # Scan local devices for the image
1506 while [ "$i" -lt 60 ]
1508 livefs_root=$(find_livefs ${i})
1510 if [ -n "${livefs_root}" ]
1521 if [ -z "${livefs_root}" ]
1523 panic "Unable to find a medium containing a live file system"
1526 if [ "${INTEGRITY_CHECK}" ]
1528 integrity_check "${livefs_root}"
1534 elif [ "${TODISK}" ]
1536 live_dest="${TODISK}"
1539 if [ "${live_dest}" ]
1541 log_begin_msg "Copying live media to ${live_dest}"
1542 copy_live_to "${livefs_root}" "${live_dest}"
1546 if [ -n "${MODULETORAMFILE}" ]
1548 setup_unionfs "${livefs_root}" "${rootmnt}"
1551 mac="$(echo ${mac} | sed 's/-//g')"
1552 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1557 maybe_break live-bottom
1558 log_begin_msg "Running /scripts/live-bottom"
1560 run_scripts /scripts/live-bottom
1566 cp live.log "${rootmnt}/var/log/"