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}"
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
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 while loop is an ugly HACK round an nfs bug
804 while [ "$i" -lt 60 ]
806 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
818 if [ -x "/sbin/mount.cifs" ]
820 if [ -z "${NFSOPTS}" ]
822 CIFSOPTS="-ouser=root,password="
824 CIFSOPTS="${NFSOPTS}"
827 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
830 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
844 size=$(fs_size "${fromdev}" "" "used")
846 if [ -b "${fromdev}" ]
849 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
851 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
852 freespace=$(df -k | awk '/'${todev}'/{print $4}')
854 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
857 tomount="/mnt/tmpsnap"
859 if [ ! -d "${tomount}" ]
861 mkdir -p "${tomount}"
864 fstype=$(get_fstype "${fromdev}")
866 if [ -n "${fstype}" ]
869 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
870 cp -a "${tomount}"/* ${todir}
873 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
878 if echo ${fromdev} | grep -qs loop
880 losetup -d "${fromdev}"
887 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
893 # Look for ${snap_label}.* in block devices
896 if [ "${PERSISTENT}" != "nofiles" ]
898 # search for image files
899 snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snap_label}.jffs2")
902 if [ -z "${snapdata}" ]
904 snapdata=$(find_cow_device "${snap_label}")
911 # copy the contents of previously found snapshot to ${snap_mount}
912 # and remember the device and filename for resync on exit in live-initramfs.init
918 if [ ! -z "${snapdata}" ]
920 log_success_msg "found snapshot: ${snapdata}"
921 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
922 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
923 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
926 if ! try_mount "${snapdev}" "${snapback}" "ro"
931 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|jffs2\)'
933 # squashfs, jffs2 or ext2/ext3 snapshot
934 dev=$(get_backing_device "${snapback}/${snapfile}")
936 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
941 zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
943 if [ "${RES}" != "0" ]
945 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
950 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
952 if [ "${RES}" != "0" ]
954 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
958 elif [ -b "${snapdata}" ]
960 # Try to find if it could be a snapshot partition
962 log_success_msg "found snapshot device on ${dev}"
963 if echo "${dev}" | grep -qs loop
965 # strange things happens, user confused?
966 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
967 snapfile=$(basename ${snaploop})
968 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
973 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
975 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
978 if [ -n "${snapfile}" ]
980 # it was a loop device, user confused
985 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
989 echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
995 image_directory="${1}"
997 addimage_directory="${3}"
998 modprobe -q -b ${UNIONTYPE}
1000 # run-init can't deal with images in a subdir, but we're going to
1001 # move all of these away before it runs anyway. No, we're not,
1002 # put them in / since move-mounting them into / breaks mono and
1007 # Let's just mount the read-only file systems first
1010 minor_kernel_version=$(uname -r|cut -c 5-|sed 's/[^0-9].*//')
1012 if [ "${NETBOOT}" = "nfs" ] && [ "${minor_kernel_version}" -lt 22 ]
1014 # go aroung a bug in nfs-unionfs locking for unionfs <= 1.4
1016 elif [ "${UNIONTYPE}" = "aufs" ]
1023 # Read image names from ${MODULE}.module if it exists
1024 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1026 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1028 image_string="${image_string} ${image_directory}/${IMAGE}"
1030 elif [ -e "${image_directory}/${MODULE}.module" ]
1032 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1034 image_string="${image_string} ${image_directory}/${IMAGE}"
1037 # ${MODULE}.module does not exist, create a list of images
1038 for FILESYSTEM in squashfs ext2 ext3 xfs jffs2 dir
1040 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1042 if [ -e "${IMAGE}" ]
1044 image_string="${image_string} ${IMAGE}"
1049 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1051 for FILESYSTEM in squashfs ext2 ext3 xfs jffs2 dir
1053 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1055 if [ -e "${IMAGE}" ]
1057 image_string="${image_string} ${IMAGE}"
1064 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1067 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1071 for image in ${image_string}
1073 imagename=$(basename "${image}")
1075 if [ -d "${image}" ]
1077 # it is a plain directory: do nothing
1078 rofsstring="${image}=${roopt}:${rofsstring}"
1079 rofslist="${image} ${rofslist}"
1080 elif [ -f "${image}" ]
1082 if losetup --help 2>&1 | grep -q -- "-r\b"
1084 backdev=$(get_backing_device "${image}" "-r")
1086 backdev=$(get_backing_device "${image}")
1088 fstype=$(get_fstype "${backdev}")
1090 if [ "${fstype}" = "unknown" ]
1092 panic "Unknown file system type on ${backdev} (${image})"
1095 if [ -z "${fstype}" ]
1097 fstype="${imagename##*.}"
1098 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1101 mkdir -p "${croot}/${imagename}"
1102 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1103 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}"
1108 rofsstring=${rofsstring%:}
1112 # Looking for "${root_persistence}" device or file
1113 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1116 num_block=$(ls -l /sys/block | wc -l)
1117 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1119 modprobe -q -b ${module}
1122 if [ -x /sbin/udevadm ]
1133 # For some reason, udevsettle does not block in this scenario,
1134 # so we sleep for a little while.
1136 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1137 for timeout in 5 4 3 2 1
1141 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1147 # search for label and files (this could be hugely optimized)
1148 cowprobe=$(find_cow_device "${root_persistence}")
1149 if [ -b "${cowprobe}" ]
1151 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1152 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1153 # snapshots to be sure to really store some e.g key config files,
1154 # but not on the same media
1155 blacklistdev="${cowprobe}"
1156 PERSISTENCE_IS_ON="1"
1157 export PERSISTENCE_IS_ON
1159 # homecow just mount something on /home, this should be generalized some way
1160 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1161 if [ -b "${homecow}" ]
1163 PERSISTENCE_IS_ON="1"
1164 export PERSISTENCE_IS_ON
1166 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1167 # This second type should be removed when snapshot will get smarter,
1168 # hence when "/etc/live-snapshot*list" will be supported also by
1169 # ext2|ext3|jffs2 snapshot types.
1170 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1172 if [ -b "${cowprobe}" ]
1174 cowdevice=${cowprobe}
1175 cow_fstype=$(get_fstype "${cowprobe}")
1176 cow_mountopt="rw,noatime"
1178 log_warning_msg "Unable to find the persistent medium"
1181 cow_mountopt="rw,noatime,mode=755"
1183 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1185 # check if there are any nfs options
1186 if echo ${NFS_COW}|grep -q ','
1188 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1189 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1191 nfs_cow_opts="-o nolock"
1197 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1200 panic "unable to determine mac address"
1205 cow_mountopt="rw,noatime,mode=755"
1208 if [ "${cow_fstype}" = "nfs" ]
1211 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1212 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1213 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1215 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1216 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1219 rofscount=$(echo ${rofslist} |wc -w)
1221 if [ -n "${EXPOSED_ROOT}" ]
1223 if [ ${rofscount} -ne 1 ]
1225 panic "only one RO file system supported with exposedroot: ${rofslist}"
1227 exposedrootfs=${rofslist%% }
1229 mount --bind ${exposedrootfs} ${rootmnt} || \
1230 panic "bind mount of ${exposedrootfs} failed"
1232 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool
1233 /home /var/lib/live'
1235 for dir in ${cow_dirs}; do
1237 mount -t ${UNIONTYPE} \
1238 -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
1239 ${UNIONTYPE} "${rootmnt}${dir}" || \
1240 panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
1241 rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1244 mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
1245 ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
1246 ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
1249 # tmpfs file systems
1251 mkdir -p "${rootmnt}/live"
1252 mount -t tmpfs tmpfs ${rootmnt}/live
1254 # Adding other custom mounts
1255 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1257 # directly mount /home
1258 # FIXME: add a custom mounts configurable system
1260 if [ -b "${homecow}" ]
1262 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1263 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1265 log_warning_msg "Unable to find the persistent home medium"
1268 # Look for other snapshots to copy in
1269 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1270 # This second type should be removed when snapshot grow smarter
1271 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1274 if [ -n "${SHOWMOUNTS}" ]
1276 for d in ${rofslist}
1278 mkdir -p "${rootmnt}/live/${d##*/}"
1282 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1286 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1292 # shows cow fs on /cow for use by live-snapshot
1293 mkdir -p "${rootmnt}/live/cow"
1294 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"
1301 skip_uuid_check="${3}"
1303 if [ -z "${devname}" ]
1305 devname=$(sys2dev "${sysdev}")
1308 if [ -d "${devname}" ]
1310 mount -o bind "${devname}" $mountpoint || continue
1312 if is_live_path $mountpoint
1321 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1323 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1324 devname="${loopdevname}"
1327 fstype=$(get_fstype "${devname}")
1329 if is_supported_fs ${fstype}
1331 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1333 if is_live_path ${mountpoint} && \
1334 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1339 umount ${mountpoint}
1343 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1345 losetup -d "${loopdevname}"
1355 # first look at the one specified in the command line
1356 if [ ! -z "${LIVE_MEDIA}" ]
1358 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1364 # don't start autodetection before timeout has expired
1365 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1367 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1373 # or do the scan of block devices
1374 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1376 devname=$(sys2dev "${sysblock}")
1377 fstype=$(get_fstype "${devname}")
1379 if /lib/udev/cdrom_id ${devname} > /dev/null
1381 if check_dev "null" "${devname}"
1385 elif is_nice_device "${sysblock}"
1387 for dev in $(subdevices "${sysblock}")
1389 if check_dev "${dev}"
1394 elif [ "${fstype}" = "squashfs" -o \
1395 "${fstype}" = "ext2" -o \
1396 "${fstype}" = "ext3" -o \
1397 "${fstype}" = "jffs2" ]
1399 # This is an ugly hack situation, the block device has
1400 # an image directly on it. It's hopefully
1401 # live-initramfs, so take it and run with it.
1402 ln -s "${devname}" "${devname}.${fstype}"
1403 echo "${devname}.${fstype}"
1411 set_usplash_timeout ()
1413 if [ -x /sbin/usplash_write ]
1415 /sbin/usplash_write "TIMEOUT 120"
1416 else if [ -x /sbin/splashy_update ] ; then
1417 /sbin/splashy_update "TIMEOUT 120"
1423 if [ -x /scripts/local-top/cryptroot ]; then
1424 /scripts/local-top/cryptroot
1431 tail -f live.log >&7 &
1434 # Ensure 'panic' function is overridden
1435 . /scripts/live-functions
1441 maybe_break live-premount
1442 log_begin_msg "Running /scripts/live-premount"
1443 run_scripts /scripts/live-premount
1446 # Needed here too because some things (*cough* udev *cough*)
1447 # changes the timeout
1451 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1455 livefs_root="${mountpoint}"
1457 panic "Unable to find a live file system on the network"
1460 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1462 # Do a local boot from hd
1465 # Scan local devices for the image
1467 while [ "$i" -lt 60 ]
1469 livefs_root=$(find_livefs ${i})
1471 if [ -n "${livefs_root}" ]
1482 if [ -z "${livefs_root}" ]
1484 panic "Unable to find a medium containing a live file system"
1490 elif [ "${TODISK}" ]
1492 live_dest="${TODISK}"
1495 if [ "${live_dest}" ]
1497 log_begin_msg "Copying live media to ${live_dest}"
1498 copy_live_to "${livefs_root}" "${live_dest}"
1502 if [ -n "${MODULETORAMFILE}" ]
1504 setup_unionfs "${livefs_root}" "${rootmnt}"
1507 mac="$(echo ${mac} | sed 's/-//g')"
1508 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1513 maybe_break live-bottom
1514 log_begin_msg "Running /scripts/live-bottom"
1516 run_scripts /scripts/live-bottom
1522 cp live.log "${rootmnt}/var/log/"