5 export PATH="/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
7 echo "/root/lib" >> /etc/ld.so.conf
8 echo "/root/usr/lib" >> /etc/ld.so.conf
10 mountpoint="/live/image"
11 LIVE_MEDIA_PATH="live"
13 root_persistence="live-rw"
14 home_persistence="home-rw"
15 root_snapshot_label="live-sn"
16 home_snapshot_label="home-sn"
19 USERFULLNAME="Live user"
22 mkdir -p "${mountpoint}"
24 # Create /etc/mtab for debug purpose and future syncs
35 [ -f /etc/live.conf ] && . /etc/live.conf
36 export USERNAME USERFULLNAME HOSTNAME
38 . /scripts/live-helpers
40 if [ ! -f /live.vars ]
49 for ARGUMENT in $(cat /proc/cmdline)
53 ACCESS="${ARGUMENT#access=}"
58 DEFCONSOLE="${ARGUMENT#*=}"
70 FETCH="${ARGUMENT#fetch=}"
75 HOOK="${ARGUMENT#hook=}"
80 FTPFS="${ARGUMENT#ftpfs=}"
85 HTTPFS="${ARGUMENT#httpfs=}"
90 HOSTNAME="${ARGUMENT#hostname=}"
92 export HOSTNAME LIVECONF
96 USERNAME="${ARGUMENT#username=}"
98 export USERNAME LIVECONF
102 USERFULLNAME="${ARGUMENT#userfullname=}"
104 export USERFULLNAME LIVECONF
113 STATICIP="${ARGUMENT#ip=}"
115 if [ -z "${STATICIP}" ]
123 keyb=*|kbd-chooser/method=*)
128 klayout=*|console-setup/layoutcode=*)
129 KLAYOUT="${ARGUMENT#*=}"
133 kvariant=*|console-setup/variantcode=*)
134 KVARIANT="${ARGUMENT#*=}"
138 kmodel=*|console-setup/modelcode=*)
139 KMODEL="${ARGUMENT#*=}"
144 KOPTIONS="${ARGUMENT#koptions=}"
153 live-media=*|bootfrom=*)
154 LIVE_MEDIA="${ARGUMENT#*=}"
158 live-media-encryption=*|encryption=*)
159 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
160 export LIVE_MEDIA_ENCRYPTION
164 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
165 export LIVE_MEDIA_OFFSET
169 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
170 export LIVE_MEDIA_PATH
173 live-media-timeout=*)
174 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
175 export LIVE_MEDIA_TIMEOUT
178 language=*|debian-installer/language=*)
179 language=${x#debian-installer/language=}
180 locale="$(lang2locale "$language")"
184 locale=*|debian-installer/locale=*)
185 LOCALE="${ARGUMENT#*=}"
190 MODULE="${ARGUMENT#module=}"
195 NETBOOT="${ARGUMENT#netboot=}"
200 NFSOPTS="${ARGUMENT#nfsopts=}"
205 NFS_COW="${ARGUMENT#nfscow=}"
210 NOACCESSIBILITY="Yes"
211 export NOACCESSIBILITY
235 NOCONSOLEKEYBOARD="Yes"
236 export NOCONSOLEKEYBOARD
260 NOKPERSONALIZER="Yes"
261 export NOKPERSONALIZER
265 NOLANGUAGESELECTOR="Yes"
266 export NOLANGUAGESELECTOR
280 NOPOWERMANAGEMENT="Yes"
281 export NOPOWERMANAGEMENT
285 NOPROGRAMCRASHES="Yes"
286 export NOPROGRAMCRASHES
290 NORESTRICTEDMANAGER="Yes"
291 export NORESTRICTEDMANAGER
305 NOUPDATENOTIFIER="Yes"
306 export NOUPDATENOTIFIER
321 export NOXSCREENSAVER
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 "${mountpoint}/.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}"
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) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ) )
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
663 mount -r -o move ${copyto} ${copyfrom}
674 modprobe -q af_packet # For DHCP
676 if [ -x /sbin/udevadm ]
687 ipconfig ${DEVICE} | tee /netboot.config
689 # source relevant ipconfig output
690 OLDHOSTNAME=${HOSTNAME}
691 . /tmp/net-${DEVICE}.conf
692 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
695 if [ "${NFSROOT}" = "auto" ]
697 NFSROOT=${ROOTSERVER}:${ROOTPATH}
700 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
706 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
708 NFSROOT=${ROOTSERVER}:${NFSROOT}
711 log_begin_msg "Trying netboot from ${NFSROOT}"
713 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
730 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
731 mount -t ramfs ram "${mountpoint}"
734 for webfile in HTTPFS FTPFS FETCH
736 url="$(eval echo \"\$\{${webfile}\}\")"
737 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
741 case "${extension}" in
743 if [ "${webfile}" = "FETCH" ]
747 ip="$(dirname $url | sed -e 's|tftp://||g')"
748 log_begin_msg "Trying tftp -g -b 10240 -r $(basename ${url}) -l ${dest}/$(basename ${url}) $ip"
749 tftp -g -b 10240 -r $(basename ${url}) -l ${dest}/$(basename ${url}) $ip
753 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
754 wget "${url}" -O "${dest}/$(basename ${url})"
758 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
759 if [ "${webfile}" = "FTPFS" ]
761 FUSE_MOUNT="curlftpfs"
762 url="$(dirname ${url})"
767 $FUSE_MOUNT "${url}" "${dest}"
769 [ ${?} -eq 0 ] && rc=0
770 [ "${extension}" = "tgz" ] && live_dest="ram"
775 log_begin_msg "Unrecognized archive extension for ${url}"
783 umount "${mountpoint}"
795 if [ -z "${NFSOPTS}" ]
800 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
802 # FIXME: This for loop is an ugly HACK round an nfs bug
803 for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13
805 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
816 if [ -x "/sbin/mount.cifs" ]
818 if [ -z "${NFSOPTS}" ]
820 CIFSOPTS="-ouser=root,password="
822 CIFSOPTS="${NFSOPTS}"
825 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
828 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
842 size=$(fs_size "${fromdev}" "" "used")
844 if [ -b "${fromdev}" ]
847 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
849 todev=$(cat /proc/mounts | grep -s " $(base_path ${todir}) " | awk '{print $1}' )
850 freespace=$(df -k | grep -s ${todev} | awk '{print $4}')
852 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ))
855 tomount="/mnt/tmpsnap"
857 if [ ! -d "${tomount}" ]
859 mkdir -p "${tomount}"
862 fstype=$(get_fstype "${fromdev}")
864 if [ -n "${fstype}" ]
867 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
868 cp -a "${tomount}"/* ${todir}
871 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
876 if echo ${fromdev} | grep -qs loop
878 losetup -d "${fromdev}"
885 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
891 # Look for ${snap_label}.* in block devices
894 if [ "${PERSISTENT}" != "nofiles" ]
896 # search for image files
897 snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snap_label}.jffs2")
900 if [ -z "${snapdata}" ]
902 snapdata=$(find_cow_device "${snap_label}")
909 # copy the contents of previously found snapshot to ${snap_mount}
910 # and remember the device and filename for resync on exit in live-initramfs.init
916 if [ ! -z "${snapdata}" ]
918 log_success_msg "found snapshot: ${snapdata}"
919 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
920 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
921 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
924 if ! try_mount "${snapdev}" "${snapback}" "ro"
929 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|jffs2\)'
931 # squashfs, jffs2 or ext2/ext3 snapshot
932 dev=$(get_backing_device "${snapback}/${snapfile}")
934 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
939 zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
941 if [ "${RES}" != "0" ]
943 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
948 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
950 if [ "${RES}" != "0" ]
952 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
956 elif [ -b "${snapdata}" ]
958 # Try to find if it could be a snapshot partition
960 log_success_msg "found snapshot device on ${dev}"
961 if echo "${dev}" | grep -qs loop
963 # strange things happens, user confused?
964 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
965 snapfile=$(basename ${snaploop})
966 snapdev=$(cat /proc/mounts | awk '{print $2,$1}' | grep -es "^$( dirname ${snaploop} )" | cut -f2 -d ' ')
971 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
973 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
976 if [ -n "${snapfile}" ]
978 # it was a loop device, user confused
983 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
987 echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
993 image_directory="${1}"
995 addimage_directory="${3}"
996 modprobe -q -b ${UNIONTYPE}
998 # run-init can't deal with images in a subdir, but we're going to
999 # move all of these away before it runs anyway. No, we're not,
1000 # put them in / since move-mounting them into / breaks mono and
1005 # Let's just mount the read-only file systems first
1008 minor_kernel_version=$(uname -r|cut -c 5-|sed 's/[^0-9].*//')
1010 if [ "${NETBOOT}" = "nfs" ] && [ "${minor_kernel_version}" -lt 22 ]
1012 # go aroung a bug in nfs-unionfs locking for unionfs <= 1.4
1014 elif [ "${UNIONTYPE}" = "aufs" ]
1021 # Read image names from ${MODULE}.module if it exists
1022 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1024 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1026 image_string="${image_string} ${image_directory}/${IMAGE}"
1028 elif [ -e "${image_directory}/${MODULE}.module" ]
1030 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1032 image_string="${image_string} ${image_directory}/${IMAGE}"
1035 # ${MODULE}.module does not exist, create a list of images
1036 for FILESYSTEM in squashfs ext2 ext3 xfs jffs2 dir
1038 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1040 if [ -e "${IMAGE}" ]
1042 image_string="${image_string} ${IMAGE}"
1047 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1049 for FILESYSTEM in squashfs ext2 ext3 xfs jffs2 dir
1051 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1053 if [ -e "${IMAGE}" ]
1055 image_string="${image_string} ${IMAGE}"
1062 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1065 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1069 for image in ${image_string}
1071 imagename=$(basename "${image}")
1073 if [ -d "${image}" ]
1075 # it is a plain directory: do nothing
1076 rofsstring="${image}=${roopt}:${rofsstring}"
1077 rofslist="${image} ${rofslist}"
1078 elif [ -f "${image}" ]
1080 if losetup --help 2>&1 | grep -q -- "-r\b"
1082 backdev=$(get_backing_device "${image}" "-r")
1084 backdev=$(get_backing_device "${image}")
1086 fstype=$(get_fstype "${backdev}")
1088 if [ "${fstype}" = "unknown" ]
1090 panic "Unknown file system type on ${backdev} (${image})"
1093 if [ -z "${fstype}" ]
1095 fstype="${imagename##*.}"
1096 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1099 mkdir -p "${croot}/${imagename}"
1100 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1101 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}"
1106 rofsstring=${rofsstring%:}
1110 # Looking for "${root_persistence}" device or file
1111 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1114 num_block=$(ls -l /sys/block | wc -l)
1115 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1117 modprobe -q -b ${module}
1120 if [ -x /sbin/udevadm ]
1131 # For some reason, udevsettle does not block in this scenario,
1132 # so we sleep for a little while.
1134 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1135 for timeout in 5 4 3 2 1
1139 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1145 # search for label and files (this could be hugely optimized)
1146 cowprobe=$(find_cow_device "${root_persistence}")
1147 if [ -b "${cowprobe}" ]
1149 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1150 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1151 # snapshots to be sure to really store some e.g key config files,
1152 # but not on the same media
1153 blacklistdev="${cowprobe}"
1155 # homecow just mount something on /home, this should be generalized some way
1156 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1157 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1158 # This second type should be removed when snapshot will get smarter,
1159 # hence when "/etc/live-snapshot*list" will be supported also by
1160 # ext2|ext3|jffs2 snapshot types.
1161 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1163 if [ -b "${cowprobe}" ]
1165 cowdevice=${cowprobe}
1166 cow_fstype=$(get_fstype "${cowprobe}")
1167 cow_mountopt="rw,noatime"
1169 log_warning_msg "Unable to find the persistent medium"
1172 cow_mountopt="rw,noatime,mode=755"
1174 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1176 # check if there are any nfs options
1177 if echo ${NFS_COW}|grep -q ','
1179 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1180 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1182 nfs_cow_opts="-o nolock"
1188 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1191 panic "unable to determine mac address"
1196 cow_mountopt="rw,noatime,mode=755"
1199 if [ "${cow_fstype}" = "nfs" ]
1202 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1203 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1204 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1206 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1207 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1210 rofscount=$(echo ${rofslist} |wc -w)
1212 if [ -n "${EXPOSED_ROOT}" ]
1214 if [ ${rofscount} -ne 1 ]
1216 panic "only one RO file system supported with exposedroot: ${rofslist}"
1218 exposedrootfs=${rofslist%% }
1220 mount --bind ${exposedrootfs} ${rootmnt} || \
1221 panic "bind mount of ${exposedrootfs} failed"
1223 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool
1224 /home /var/lib/live'
1226 for dir in ${cow_dirs}; do
1228 mount -t ${UNIONTYPE} \
1229 -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
1230 ${UNIONTYPE} "${rootmnt}${dir}" || \
1231 panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
1232 rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1235 mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
1236 ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
1237 ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
1240 # tmpfs file systems
1242 mkdir -p "${rootmnt}/live"
1243 mount -t tmpfs tmpfs ${rootmnt}/live
1245 # Adding other custom mounts
1246 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1248 # directly mount /home
1249 # FIXME: add a custom mounts configurable system
1251 if [ -b "${homecow}" ]
1253 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1254 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1256 log_warning_msg "Unable to find the persistent home medium"
1259 # Look for other snapshots to copy in
1260 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1261 # This second type should be removed when snapshot grow smarter
1262 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1265 if [ -n "${SHOWMOUNTS}" ]
1267 for d in ${rofslist}
1269 mkdir -p "${rootmnt}/live/${d##*/}"
1273 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1277 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1283 # shows cow fs on /cow for use by live-snapshot
1284 mkdir -p "${rootmnt}/live/cow"
1285 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"
1292 skip_uuid_check="${3}"
1294 if [ -z "${devname}" ]
1296 devname=$(sys2dev "${sysdev}")
1299 if [ -d "${devname}" ]
1301 mount -o bind "${devname}" $mountpoint || continue
1303 if is_live_path $mountpoint
1312 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1314 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1315 devname="${loopdevname}"
1318 fstype=$(get_fstype "${devname}")
1320 if is_supported_fs ${fstype}
1322 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1324 if is_live_path ${mountpoint} && \
1325 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1330 umount ${mountpoint}
1334 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1336 losetup -d "${loopdevname}"
1346 # first look at the one specified in the command line
1347 if [ ! -z "${LIVE_MEDIA}" ]
1349 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1355 # don't start autodetection before timeout has expired
1356 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1358 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1364 # or do the scan of block devices
1365 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram | grep -v 'dm-' | grep -v fd )
1367 devname=$(sys2dev "${sysblock}")
1368 fstype=$(get_fstype "${devname}")
1370 if /lib/udev/cdrom_id ${devname} > /dev/null
1372 if check_dev "null" "${devname}"
1376 elif is_nice_device "${sysblock}"
1378 for dev in $(subdevices "${sysblock}")
1380 if check_dev "${dev}"
1385 elif [ "${fstype}" = "squashfs" -o \
1386 "${fstype}" = "ext2" -o \
1387 "${fstype}" = "ext3" -o \
1388 "${fstype}" = "jffs2" ]
1390 # This is an ugly hack situation, the block device has
1391 # an image directly on it. It's hopefully
1392 # live-initramfs, so take it and run with it.
1393 ln -s "${devname}" "${devname}.${fstype}"
1394 echo "${devname}.${fstype}"
1402 set_usplash_timeout ()
1404 if [ -x /sbin/usplash_write ]
1406 /sbin/usplash_write "TIMEOUT 120"
1407 else if [ -x /sbin/splashy_update ] ; then
1408 /sbin/splashy_update "TIMEOUT 120"
1414 if [ -x /scripts/local-top/cryptroot ]; then
1415 /scripts/local-top/cryptroot
1422 tail -f live.log >&7 &
1425 # Ensure 'panic' function is overridden
1426 . /scripts/live-functions
1432 maybe_break live-premount
1433 log_begin_msg "Running /scripts/live-premount"
1434 run_scripts /scripts/live-premount
1437 # Needed here too because some things (*cough* udev *cough*)
1438 # changes the timeout
1442 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1446 livefs_root="${mountpoint}"
1448 panic "Unable to find a live file system on the network"
1451 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1453 # Do a local boot from hd
1456 # Scan local devices for the image
1457 for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1459 livefs_root=$(find_livefs ${i})
1461 if [ -n "${livefs_root}" ]
1471 if [ -z "${livefs_root}" ]
1473 panic "Unable to find a medium containing a live file system"
1479 elif [ "${TODISK}" ]
1481 live_dest="${TODISK}"
1484 if [ "${live_dest}" ]
1486 log_begin_msg "Copying live media to ${live_dest}"
1487 copy_live_to "${livefs_root}" "${live_dest}"
1491 if [ -n "${MODULETORAMFILE}" ]
1493 setup_unionfs "${livefs_root}" "${rootmnt}"
1496 mac="$(echo ${mac} | sed 's/-//g')"
1497 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1502 maybe_break live-bottom
1503 log_begin_msg "Running /scripts/live-bottom"
1505 run_scripts /scripts/live-bottom
1511 cp live.log "${rootmnt}/var/log/"