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
305 NOUPDATENOTIFIER="Yes"
306 export NOUPDATENOTIFIER
321 export NOXSCREENSAVER
330 PERSISTENT="${ARGUMENT#persistent=}"
331 if [ -z "${PERSISTENT}" ]
343 preseed/file=*|file=*)
344 LOCATION="${ARGUMENT#*=}"
354 location="${ARGUMENT#url=}"
356 mount -o bind /sys /root/sys
357 mount -o bind /proc /root/proc
358 mount -o bind /dev /root/dev
360 mkdir -p /root/var/run/network
361 chroot /root dhclient eth0
362 chroot /root wget -P /tmp "${location}"
363 chroot /root ifconfig eth0 down
369 LOCATION="/tmp/$(basename "${location}")"
373 question="${ARGUMENT%%=*}"
374 value="${ARGUMENT#*=}"
375 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
390 TIMEZONE="${ARGUMENT#timezone=}"
400 TODISK="${ARGUMENT#todisk=}"
411 MODULETORAM="${ARGUMENT#toram=}"
412 export TORAM MODULETORAM
426 ROOT="${ARGUMENT#root=}"
431 UNIONTYPE="${ARGUMENT#union=}"
436 UTC="${ARGUMENT#utc=}"
446 XDRIVER="${ARGUMENT#xdriver=}"
451 XVIDEOMODE="${ARGUMENT#xvideomode=}"
457 # sort of compatibility with netboot.h from linux docs
458 if [ -z "${NETBOOT}" ]
460 if [ "${ROOT}" = "/dev/nfs" ]
464 elif [ "${ROOT}" = "/dev/cifs" ]
471 if [ -z "${MODULE}" ]
477 if [ -z "${UNIONTYPE}" ]
488 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
490 for FILESYSTEM in squashfs ext2 ext3 xfs dir jffs2
492 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
504 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
510 uuid="$(cat /conf/uuid.conf)"
512 for try_uuid_file in "${path}/.disk/live-uuid"*
514 [ -e "${try_uuid_file}" ] || continue
516 try_uuid="$(cat "${try_uuid_file}")"
518 if [ "${uuid}" = "${try_uuid}" ]
527 get_backing_device ()
530 *.squashfs|*.ext2|*.ext3|*.jffs2)
531 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
539 panic "Unrecognized live filesystem: ${1}"
544 match_files_in_dir ()
546 # Does any files match pattern ${1} ?
549 if [ "$(echo ${pattern})" != "${pattern}" ]
557 mount_images_in_directory ()
564 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
565 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
566 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
567 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
568 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
570 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
571 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
573 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
579 sysfs_path="${1#/sys}"
581 if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-(ide|scsi|usb))"
584 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
596 copyto="${copyfrom}_swap"
598 if [ -z "${MODULETORAM}" ]
600 size=$(fs_size "" ${copyfrom} "used")
602 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
604 if [ -f "${MODULETORAMFILE}" ]
606 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
608 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
613 if [ "${copytodev}" = "ram" ]
616 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
617 mount_options="-o size=${size}k"
622 # it should be a writable block device
623 if [ -b "${copytodev}" ]
627 fstype=$(get_fstype "${dev}")
628 freespace=$(fs_size "${dev}")
630 log_warning_msg "${copytodev} is not a block device."
635 if [ "${freespace}" -lt "${size}" ]
637 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
641 # begin copying (or uncompressing)
643 echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
644 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
646 if [ "${extension}" = "tgz" ]
649 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
650 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
651 mount -r -o move "${copyto}" "${rootmnt}"
654 if [ -n "${MODULETORAMFILE}" ]
656 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
658 cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files
662 mount -r -o move ${copyto} ${copyfrom}
673 modprobe -q af_packet # For DHCP
675 if [ -x /sbin/udevadm ]
686 ipconfig ${DEVICE} | tee /netboot.config
688 # source relevant ipconfig output
689 OLDHOSTNAME=${HOSTNAME}
690 . /tmp/net-${DEVICE}.conf
691 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
694 # Check if we have a network device at all
695 if ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
696 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
697 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
698 ! ls /sys/class/net/ra0 > /dev/null 2>&1
700 panic "No supported network device found, maybe a non-mainline driver is required."
703 if [ "${NFSROOT}" = "auto" ]
705 NFSROOT=${ROOTSERVER}:${ROOTPATH}
708 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
714 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
716 NFSROOT=${ROOTSERVER}:${NFSROOT}
719 log_begin_msg "Trying netboot from ${NFSROOT}"
721 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
738 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
739 mount -t ramfs ram "${mountpoint}"
742 for webfile in HTTPFS FTPFS FETCH
744 url="$(eval echo \"\$\{${webfile}\}\")"
745 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
749 case "${extension}" in
751 if [ "${webfile}" = "FETCH" ]
755 ip="$(dirname $url | sed -e 's|tftp://||g')"
756 log_begin_msg "Trying tftp -g -b 10240 -r $(basename ${url}) -l ${dest}/$(basename ${url}) $ip"
757 tftp -g -b 10240 -r $(basename ${url}) -l ${dest}/$(basename ${url}) $ip
761 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
762 wget "${url}" -O "${dest}/$(basename ${url})"
766 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
767 if [ "${webfile}" = "FTPFS" ]
769 FUSE_MOUNT="curlftpfs"
770 url="$(dirname ${url})"
775 $FUSE_MOUNT "${url}" "${dest}"
777 [ ${?} -eq 0 ] && rc=0
778 [ "${extension}" = "tgz" ] && live_dest="ram"
783 log_begin_msg "Unrecognized archive extension for ${url}"
791 umount "${mountpoint}"
803 if [ -z "${NFSOPTS}" ]
808 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
810 # FIXME: This while loop is an ugly HACK round an nfs bug
812 while [ "$i" -lt 60 ]
814 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
826 if [ -x "/sbin/mount.cifs" ]
828 if [ -z "${NFSOPTS}" ]
830 CIFSOPTS="-ouser=root,password="
832 CIFSOPTS="${NFSOPTS}"
835 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
838 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
852 size=$(fs_size "${fromdev}" "" "used")
854 if [ -b "${fromdev}" ]
857 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
859 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
860 freespace=$(df -k | awk '/'${todev}'/{print $4}')
862 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
865 tomount="/mnt/tmpsnap"
867 if [ ! -d "${tomount}" ]
869 mkdir -p "${tomount}"
872 fstype=$(get_fstype "${fromdev}")
874 if [ -n "${fstype}" ]
877 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
878 cp -a "${tomount}"/* ${todir}
881 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
886 if echo ${fromdev} | grep -qs loop
888 losetup -d "${fromdev}"
895 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
901 # Look for ${snap_label}.* in block devices
904 if [ "${PERSISTENT}" != "nofiles" ]
906 # search for image files
907 snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snap_label}.jffs2")
910 if [ -z "${snapdata}" ]
912 snapdata=$(find_cow_device "${snap_label}")
919 # copy the contents of previously found snapshot to ${snap_mount}
920 # and remember the device and filename for resync on exit in live-initramfs.init
926 if [ ! -z "${snapdata}" ]
928 log_success_msg "found snapshot: ${snapdata}"
929 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
930 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
931 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
934 if ! try_mount "${snapdev}" "${snapback}" "ro"
939 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|jffs2\)'
941 # squashfs, jffs2 or ext2/ext3 snapshot
942 dev=$(get_backing_device "${snapback}/${snapfile}")
944 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
949 zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
951 if [ "${RES}" != "0" ]
953 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
958 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
960 if [ "${RES}" != "0" ]
962 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
966 elif [ -b "${snapdata}" ]
968 # Try to find if it could be a snapshot partition
970 log_success_msg "found snapshot device on ${dev}"
971 if echo "${dev}" | grep -qs loop
973 # strange things happens, user confused?
974 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
975 snapfile=$(basename ${snaploop})
976 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
981 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
983 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
986 if [ -n "${snapfile}" ]
988 # it was a loop device, user confused
993 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
997 echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1003 image_directory="${1}"
1005 addimage_directory="${3}"
1006 modprobe -q -b ${UNIONTYPE}
1008 # run-init can't deal with images in a subdir, but we're going to
1009 # move all of these away before it runs anyway. No, we're not,
1010 # put them in / since move-mounting them into / breaks mono and
1015 # Let's just mount the read-only file systems first
1018 minor_kernel_version=$(uname -r|cut -c 5-|sed 's/[^0-9].*//')
1020 if [ "${NETBOOT}" = "nfs" ] && [ "${minor_kernel_version}" -lt 22 ]
1022 # go aroung a bug in nfs-unionfs locking for unionfs <= 1.4
1024 elif [ "${UNIONTYPE}" = "aufs" ]
1031 # Read image names from ${MODULE}.module if it exists
1032 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1034 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1036 image_string="${image_string} ${image_directory}/${IMAGE}"
1038 elif [ -e "${image_directory}/${MODULE}.module" ]
1040 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1042 image_string="${image_string} ${image_directory}/${IMAGE}"
1045 # ${MODULE}.module does not exist, create a list of images
1046 for FILESYSTEM in squashfs ext2 ext3 xfs jffs2 dir
1048 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1050 if [ -e "${IMAGE}" ]
1052 image_string="${image_string} ${IMAGE}"
1057 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1059 for FILESYSTEM in squashfs ext2 ext3 xfs jffs2 dir
1061 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1063 if [ -e "${IMAGE}" ]
1065 image_string="${image_string} ${IMAGE}"
1072 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1075 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1079 for image in ${image_string}
1081 imagename=$(basename "${image}")
1083 if [ -d "${image}" ]
1085 # it is a plain directory: do nothing
1086 rofsstring="${image}=${roopt}:${rofsstring}"
1087 rofslist="${image} ${rofslist}"
1088 elif [ -f "${image}" ]
1090 if losetup --help 2>&1 | grep -q -- "-r\b"
1092 backdev=$(get_backing_device "${image}" "-r")
1094 backdev=$(get_backing_device "${image}")
1096 fstype=$(get_fstype "${backdev}")
1098 if [ "${fstype}" = "unknown" ]
1100 panic "Unknown file system type on ${backdev} (${image})"
1103 if [ -z "${fstype}" ]
1105 fstype="${imagename##*.}"
1106 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1109 mkdir -p "${croot}/${imagename}"
1110 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1111 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}"
1116 rofsstring=${rofsstring%:}
1120 # Looking for "${root_persistence}" device or file
1121 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1124 num_block=$(ls -l /sys/block | wc -l)
1125 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1127 modprobe -q -b ${module}
1130 if [ -x /sbin/udevadm ]
1141 # For some reason, udevsettle does not block in this scenario,
1142 # so we sleep for a little while.
1144 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1145 for timeout in 5 4 3 2 1
1149 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1155 # search for label and files (this could be hugely optimized)
1156 cowprobe=$(find_cow_device "${root_persistence}")
1157 if [ -b "${cowprobe}" ]
1159 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1160 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1161 # snapshots to be sure to really store some e.g key config files,
1162 # but not on the same media
1163 blacklistdev="${cowprobe}"
1164 PERSISTENCE_IS_ON="1"
1165 export PERSISTENCE_IS_ON
1167 # homecow just mount something on /home, this should be generalized some way
1168 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1169 if [ -b "${homecow}" ]
1171 PERSISTENCE_IS_ON="1"
1172 export PERSISTENCE_IS_ON
1174 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1175 # This second type should be removed when snapshot will get smarter,
1176 # hence when "/etc/live-snapshot*list" will be supported also by
1177 # ext2|ext3|jffs2 snapshot types.
1178 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1180 if [ -b "${cowprobe}" ]
1182 cowdevice=${cowprobe}
1183 cow_fstype=$(get_fstype "${cowprobe}")
1184 cow_mountopt="rw,noatime"
1186 log_warning_msg "Unable to find the persistent medium"
1189 cow_mountopt="rw,noatime,mode=755"
1191 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1193 # check if there are any nfs options
1194 if echo ${NFS_COW}|grep -q ','
1196 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1197 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1199 nfs_cow_opts="-o nolock"
1205 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1208 panic "unable to determine mac address"
1213 cow_mountopt="rw,noatime,mode=755"
1216 if [ "${cow_fstype}" = "nfs" ]
1219 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1220 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1221 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1223 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1224 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1227 rofscount=$(echo ${rofslist} |wc -w)
1229 if [ -n "${EXPOSED_ROOT}" ]
1231 if [ ${rofscount} -ne 1 ]
1233 panic "only one RO file system supported with exposedroot: ${rofslist}"
1235 exposedrootfs=${rofslist%% }
1237 mount --bind ${exposedrootfs} ${rootmnt} || \
1238 panic "bind mount of ${exposedrootfs} failed"
1240 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool
1241 /home /var/lib/live'
1243 for dir in ${cow_dirs}; do
1245 mount -t ${UNIONTYPE} \
1246 -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
1247 ${UNIONTYPE} "${rootmnt}${dir}" || \
1248 panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
1249 rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1252 mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
1253 ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
1254 ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
1257 # tmpfs file systems
1259 mkdir -p "${rootmnt}/live"
1260 mount -t tmpfs tmpfs ${rootmnt}/live
1262 # Adding other custom mounts
1263 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1265 # directly mount /home
1266 # FIXME: add a custom mounts configurable system
1268 if [ -b "${homecow}" ]
1270 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1271 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1273 log_warning_msg "Unable to find the persistent home medium"
1276 # Look for other snapshots to copy in
1277 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1278 # This second type should be removed when snapshot grow smarter
1279 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1282 if [ -n "${SHOWMOUNTS}" ]
1284 for d in ${rofslist}
1286 mkdir -p "${rootmnt}/live/${d##*/}"
1290 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1294 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1300 # shows cow fs on /cow for use by live-snapshot
1301 mkdir -p "${rootmnt}/live/cow"
1302 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"
1309 skip_uuid_check="${3}"
1311 if [ -z "${devname}" ]
1313 devname=$(sys2dev "${sysdev}")
1316 if [ -d "${devname}" ]
1318 mount -o bind "${devname}" $mountpoint || continue
1320 if is_live_path $mountpoint
1329 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1331 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1332 devname="${loopdevname}"
1335 fstype=$(get_fstype "${devname}")
1337 if is_supported_fs ${fstype}
1339 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1341 if is_live_path ${mountpoint} && \
1342 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1347 umount ${mountpoint}
1351 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1353 losetup -d "${loopdevname}"
1363 # first look at the one specified in the command line
1364 if [ ! -z "${LIVE_MEDIA}" ]
1366 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1372 # don't start autodetection before timeout has expired
1373 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1375 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1381 # or do the scan of block devices
1382 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1384 devname=$(sys2dev "${sysblock}")
1385 fstype=$(get_fstype "${devname}")
1387 if /lib/udev/cdrom_id ${devname} > /dev/null
1389 if check_dev "null" "${devname}"
1393 elif is_nice_device "${sysblock}"
1395 for dev in $(subdevices "${sysblock}")
1397 if check_dev "${dev}"
1402 elif [ "${fstype}" = "squashfs" -o \
1403 "${fstype}" = "ext2" -o \
1404 "${fstype}" = "ext3" -o \
1405 "${fstype}" = "jffs2" ]
1407 # This is an ugly hack situation, the block device has
1408 # an image directly on it. It's hopefully
1409 # live-initramfs, so take it and run with it.
1410 ln -s "${devname}" "${devname}.${fstype}"
1411 echo "${devname}.${fstype}"
1419 set_usplash_timeout ()
1421 if [ -x /sbin/usplash_write ]
1423 /sbin/usplash_write "TIMEOUT 120"
1424 else if [ -x /sbin/splashy_update ] ; then
1425 /sbin/splashy_update "TIMEOUT 120"
1431 if [ -x /scripts/local-top/cryptroot ]; then
1432 /scripts/local-top/cryptroot
1439 tail -f live.log >&7 &
1442 # Ensure 'panic' function is overridden
1443 . /scripts/live-functions
1449 maybe_break live-premount
1450 log_begin_msg "Running /scripts/live-premount"
1451 run_scripts /scripts/live-premount
1454 # Needed here too because some things (*cough* udev *cough*)
1455 # changes the timeout
1459 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1463 livefs_root="${mountpoint}"
1465 panic "Unable to find a live file system on the network"
1468 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1470 # Do a local boot from hd
1473 # Scan local devices for the image
1475 while [ "$i" -lt 60 ]
1477 livefs_root=$(find_livefs ${i})
1479 if [ -n "${livefs_root}" ]
1490 if [ -z "${livefs_root}" ]
1492 panic "Unable to find a medium containing a live file system"
1498 elif [ "${TODISK}" ]
1500 live_dest="${TODISK}"
1503 if [ "${live_dest}" ]
1505 log_begin_msg "Copying live media to ${live_dest}"
1506 copy_live_to "${livefs_root}" "${live_dest}"
1510 if [ -n "${MODULETORAMFILE}" ]
1512 setup_unionfs "${livefs_root}" "${rootmnt}"
1515 mac="$(echo ${mac} | sed 's/-//g')"
1516 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1521 maybe_break live-bottom
1522 log_begin_msg "Running /scripts/live-bottom"
1524 run_scripts /scripts/live-bottom
1530 cp live.log "${rootmnt}/var/log/"