5 export PATH="/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
7 echo "/root/lib" >> /etc/ld.so.conf
8 echo "/root/usr/lib" >> /etc/ld.so.conf
10 mountpoint="/live/image"
11 LIVE_MEDIA_PATH="live"
13 root_persistence="live-rw"
14 home_persistence="home-rw"
15 root_snapshot_label="live-sn"
16 home_snapshot_label="home-sn"
19 USERFULLNAME="Live user"
22 mkdir -p "${mountpoint}"
24 # Create /etc/mtab for debug purpose and future syncs
35 [ -f /etc/live.conf ] && . /etc/live.conf
36 export USERNAME USERFULLNAME HOSTNAME
38 . /scripts/live-helpers
40 if [ ! -f /live.vars ]
49 for ARGUMENT in $(cat /proc/cmdline)
53 ACCESS="${ARGUMENT#access=}"
58 DEFCONSOLE="${ARGUMENT#*=}"
70 FETCH="${ARGUMENT#fetch=}"
75 HOOK="${ARGUMENT#hook=}"
80 FTPFS="${ARGUMENT#ftpfs=}"
85 HTTPFS="${ARGUMENT#httpfs=}"
90 HOSTNAME="${ARGUMENT#hostname=}"
92 export HOSTNAME LIVECONF
96 USERNAME="${ARGUMENT#username=}"
98 export USERNAME LIVECONF
102 USERFULLNAME="${ARGUMENT#userfullname=}"
104 export USERFULLNAME LIVECONF
113 INTEGRITY_CHECK="Yes"
114 export INTEGRITY_CHECK
118 STATICIP="${ARGUMENT#ip=}"
120 if [ -z "${STATICIP}" ]
128 keyb=*|kbd-chooser/method=*)
133 klayout=*|console-setup/layoutcode=*)
134 KLAYOUT="${ARGUMENT#*=}"
138 kvariant=*|console-setup/variantcode=*)
139 KVARIANT="${ARGUMENT#*=}"
143 kmodel=*|console-setup/modelcode=*)
144 KMODEL="${ARGUMENT#*=}"
149 KOPTIONS="${ARGUMENT#koptions=}"
158 live-media=*|bootfrom=*)
159 LIVE_MEDIA="${ARGUMENT#*=}"
163 live-media-encryption=*|encryption=*)
164 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
165 export LIVE_MEDIA_ENCRYPTION
169 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
170 export LIVE_MEDIA_OFFSET
174 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
175 export LIVE_MEDIA_PATH
178 live-media-timeout=*)
179 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
180 export LIVE_MEDIA_TIMEOUT
183 language=*|debian-installer/language=*)
184 language=${x#debian-installer/language=}
185 locale="$(lang2locale "$language")"
189 locale=*|debian-installer/locale=*)
190 LOCALE="${ARGUMENT#*=}"
195 MODULE="${ARGUMENT#module=}"
200 NETBOOT="${ARGUMENT#netboot=}"
205 NFSOPTS="${ARGUMENT#nfsopts=}"
210 NFS_COW="${ARGUMENT#nfscow=}"
215 NOACCESSIBILITY="Yes"
216 export NOACCESSIBILITY
240 NOCONSOLEKEYBOARD="Yes"
241 export NOCONSOLEKEYBOARD
265 NOKPERSONALIZER="Yes"
266 export NOKPERSONALIZER
270 NOLANGUAGESELECTOR="Yes"
271 export NOLANGUAGESELECTOR
285 NOPOWERMANAGEMENT="Yes"
286 export NOPOWERMANAGEMENT
290 NOPROGRAMCRASHES="Yes"
291 export NOPROGRAMCRASHES
310 NOUPDATENOTIFIER="Yes"
311 export NOUPDATENOTIFIER
326 export NOXSCREENSAVER
335 PERSISTENT="${ARGUMENT#persistent=}"
336 if [ -z "${PERSISTENT}" ]
344 PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
345 export PERSISTENT_PATH
353 preseed/file=*|file=*)
354 LOCATION="${ARGUMENT#*=}"
364 location="${ARGUMENT#url=}"
366 mount -o bind /sys /root/sys
367 mount -o bind /proc /root/proc
368 mount -o bind /dev /root/dev
370 mkdir -p /root/var/run/network
371 chroot /root dhclient eth0
372 chroot /root wget -P /tmp "${location}"
373 chroot /root ifconfig eth0 down
379 LOCATION="/tmp/$(basename "${location}")"
383 question="${ARGUMENT%%=*}"
384 value="${ARGUMENT#*=}"
385 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
405 TIMEZONE="${ARGUMENT#timezone=}"
415 TODISK="${ARGUMENT#todisk=}"
426 MODULETORAM="${ARGUMENT#toram=}"
427 export TORAM MODULETORAM
441 SKIP_UNION_MOUNTS="Yes"
442 export SKIP_UNION_MOUNTS
446 ROOT="${ARGUMENT#root=}"
451 UNIONTYPE="${ARGUMENT#union=}"
456 UTC="${ARGUMENT#utc=}"
466 XDRIVER="${ARGUMENT#xdriver=}"
471 XVIDEOMODE="${ARGUMENT#xvideomode=}"
477 # sort of compatibility with netboot.h from linux docs
478 if [ -z "${NETBOOT}" ]
480 if [ "${ROOT}" = "/dev/nfs" ]
484 elif [ "${ROOT}" = "/dev/cifs" ]
491 if [ -z "${MODULE}" ]
497 if [ -z "${UNIONTYPE}" ]
508 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
510 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
512 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
524 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
530 uuid="$(cat /conf/uuid.conf)"
532 for try_uuid_file in "${path}/.disk/live-uuid"*
534 [ -e "${try_uuid_file}" ] || continue
536 try_uuid="$(cat "${try_uuid_file}")"
538 if [ "${uuid}" = "${try_uuid}" ]
547 get_backing_device ()
550 *.squashfs|*.ext2|*.ext3|*.ext4|*.jffs2)
551 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
559 panic "Unrecognized live filesystem: ${1}"
564 match_files_in_dir ()
566 # Does any files match pattern ${1} ?
569 if [ "$(echo ${pattern})" != "${pattern}" ]
577 mount_images_in_directory ()
584 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
585 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
586 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
587 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
588 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
589 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
591 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
592 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
594 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
600 sysfs_path="${1#/sys}"
602 if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-(ide|scsi|usb))"
605 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
617 copyto="${copyfrom}_swap"
619 if [ -z "${MODULETORAM}" ]
621 size=$(fs_size "" ${copyfrom} "used")
623 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
625 if [ -f "${MODULETORAMFILE}" ]
627 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
629 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
634 if [ "${copytodev}" = "ram" ]
637 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
638 mount_options="-o size=${size}k"
643 # it should be a writable block device
644 if [ -b "${copytodev}" ]
648 fstype=$(get_fstype "${dev}")
649 freespace=$(fs_size "${dev}")
651 log_warning_msg "${copytodev} is not a block device."
656 if [ "${freespace}" -lt "${size}" ]
658 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
662 # begin copying (or uncompressing)
664 echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
665 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
667 if [ "${extension}" = "tgz" ]
670 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
671 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
672 mount -r -o move "${copyto}" "${rootmnt}"
675 if [ -n "${MODULETORAMFILE}" ]
677 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
679 cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files
683 mount -r -o move ${copyto} ${copyfrom}
694 modprobe -q af_packet # For DHCP
696 if [ -x /sbin/udevadm ]
707 ipconfig ${DEVICE} | tee /netboot.config
709 # source relevant ipconfig output
710 OLDHOSTNAME=${HOSTNAME}
711 . /tmp/net-${DEVICE}.conf
712 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
715 # Check if we have a network device at all
716 if ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
717 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
718 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
719 ! ls /sys/class/net/ra0 > /dev/null 2>&1
721 panic "No supported network device found, maybe a non-mainline driver is required."
724 if [ "${NFSROOT}" = "auto" ]
726 NFSROOT=${ROOTSERVER}:${ROOTPATH}
729 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
735 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
737 NFSROOT=${ROOTSERVER}:${NFSROOT}
740 log_begin_msg "Trying netboot from ${NFSROOT}"
742 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
759 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
760 mount -t ramfs ram "${mountpoint}"
763 for webfile in HTTPFS FTPFS FETCH
765 url="$(eval echo \"\$\{${webfile}\}\")"
766 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
770 case "${extension}" in
772 if [ "${webfile}" = "FETCH" ]
776 ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
777 rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
778 lfile="$(basename $url)"
779 log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
780 tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
784 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
785 wget "${url}" -O "${dest}/$(basename ${url})"
789 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
790 if [ "${webfile}" = "FTPFS" ]
792 FUSE_MOUNT="curlftpfs"
793 url="$(dirname ${url})"
798 $FUSE_MOUNT "${url}" "${dest}"
800 [ ${?} -eq 0 ] && rc=0
801 [ "${extension}" = "tgz" ] && live_dest="ram"
806 log_begin_msg "Unrecognized archive extension for ${url}"
814 umount "${mountpoint}"
826 if [ -z "${NFSOPTS}" ]
831 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
833 # FIXME: This while loop is an ugly HACK round an nfs bug
835 while [ "$i" -lt 60 ]
837 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
849 if [ -x "/sbin/mount.cifs" ]
851 if [ -z "${NFSOPTS}" ]
853 CIFSOPTS="-ouser=root,password="
855 CIFSOPTS="${NFSOPTS}"
858 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
861 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
875 size=$(fs_size "${fromdev}" "" "used")
877 if [ -b "${fromdev}" ]
880 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
882 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
883 freespace=$(df -k | awk '/'${todev}'/{print $4}')
885 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
888 tomount="/mnt/tmpsnap"
890 if [ ! -d "${tomount}" ]
892 mkdir -p "${tomount}"
895 fstype=$(get_fstype "${fromdev}")
897 if [ -n "${fstype}" ]
900 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
901 cp -a "${tomount}"/* ${todir}
904 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
909 if echo ${fromdev} | grep -qs loop
911 losetup -d "${fromdev}"
918 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
924 # Look for ${snap_label}.* in block devices
927 if [ "${PERSISTENT}" != "nofiles" ]
929 # search for image files
930 snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snal_label}.ext4 ${snap_label}.jffs2")
933 if [ -z "${snapdata}" ]
935 snapdata=$(find_cow_device "${snap_label}")
942 # copy the contents of previously found snapshot to ${snap_mount}
943 # and remember the device and filename for resync on exit in live-initramfs.init
949 if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
951 log_success_msg "found snapshot: ${snapdata}"
952 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
953 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
954 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
957 if ! try_mount "${snapdev}" "${snapback}" "ro"
962 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
964 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
965 dev=$(get_backing_device "${snapback}/${snapfile}")
967 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
972 zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
974 if [ "${RES}" != "0" ]
976 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
981 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
983 if [ "${RES}" != "0" ]
985 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
988 elif [ -b "${snapdata}" ]
990 # Try to find if it could be a snapshot partition
992 log_success_msg "found snapshot ${snap_type} device on ${dev}"
993 if echo "${dev}" | grep -qs loop
995 # strange things happens, user confused?
996 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
997 snapfile=$(basename ${snaploop})
998 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
1003 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1005 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1008 if [ -n "${snapfile}" ]
1010 # it was a loop device, user confused
1015 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1019 echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1025 image_directory="${1}"
1027 addimage_directory="${3}"
1028 modprobe -q -b ${UNIONTYPE}
1030 # run-init can't deal with images in a subdir, but we're going to
1031 # move all of these away before it runs anyway. No, we're not,
1032 # put them in / since move-mounting them into / breaks mono and
1037 # Let's just mount the read-only file systems first
1040 minor_kernel_version=$(uname -r|cut -c 5-|sed 's/[^0-9].*//')
1042 if [ "${NETBOOT}" = "nfs" ] && [ "${minor_kernel_version}" -lt 22 ]
1044 # go aroung a bug in nfs-unionfs locking for unionfs <= 1.4
1046 elif [ "${UNIONTYPE}" = "aufs" ]
1053 # Read image names from ${MODULE}.module if it exists
1054 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1056 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1058 image_string="${image_string} ${image_directory}/${IMAGE}"
1060 elif [ -e "${image_directory}/${MODULE}.module" ]
1062 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1064 image_string="${image_string} ${image_directory}/${IMAGE}"
1067 # ${MODULE}.module does not exist, create a list of images
1068 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1070 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1072 if [ -e "${IMAGE}" ]
1074 image_string="${image_string} ${IMAGE}"
1079 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1081 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1083 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1085 if [ -e "${IMAGE}" ]
1087 image_string="${image_string} ${IMAGE}"
1094 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1097 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1101 for image in ${image_string}
1103 imagename=$(basename "${image}")
1105 export image devname
1106 maybe_break live-realpremount
1107 log_begin_msg "Running /scripts/live-realpremount"
1108 run_scripts /scripts/live-realpremount
1111 if [ -d "${image}" ]
1113 # it is a plain directory: do nothing
1114 rofsstring="${image}=${roopt}:${rofsstring}"
1115 rofslist="${image} ${rofslist}"
1116 elif [ -f "${image}" ]
1118 if losetup --help 2>&1 | grep -q -- "-r\b"
1120 backdev=$(get_backing_device "${image}" "-r")
1122 backdev=$(get_backing_device "${image}")
1124 fstype=$(get_fstype "${backdev}")
1126 if [ "${fstype}" = "unknown" ]
1128 panic "Unknown file system type on ${backdev} (${image})"
1131 if [ -z "${fstype}" ]
1133 fstype="${imagename##*.}"
1134 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1137 mkdir -p "${croot}/${imagename}"
1138 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1139 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}"
1144 rofsstring=${rofsstring%:}
1148 # Looking for "${root_persistence}" device or file
1149 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1152 num_block=$(ls -l /sys/block | wc -l)
1153 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1155 modprobe -q -b ${module}
1158 if [ -x /sbin/udevadm ]
1169 # For some reason, udevsettle does not block in this scenario,
1170 # so we sleep for a little while.
1172 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1173 for timeout in 5 4 3 2 1
1177 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1183 # search for label and files (this could be hugely optimized)
1184 cowprobe=$(find_cow_device "${root_persistence}")
1185 if [ -b "${cowprobe}" ]
1187 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1188 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1189 # snapshots to be sure to really store some e.g key config files,
1190 # but not on the same media
1191 blacklistdev="${cowprobe}"
1192 PERSISTENCE_IS_ON="1"
1193 export PERSISTENCE_IS_ON
1195 # homecow just mount something on /home, this should be generalized some way
1196 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1197 if [ -b "${homecow}" ]
1199 PERSISTENCE_IS_ON="1"
1200 export PERSISTENCE_IS_ON
1202 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1203 # This second type should be removed when snapshot will get smarter,
1204 # hence when "/etc/live-snapshot*list" will be supported also by
1205 # ext2|ext3|ext4|jffs2 snapshot types.
1206 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1208 if [ -b "${cowprobe}" ]
1210 cowdevice=${cowprobe}
1211 cow_fstype=$(get_fstype "${cowprobe}")
1212 cow_mountopt="rw,noatime"
1214 log_warning_msg "Unable to find the persistent medium"
1217 cow_mountopt="rw,noatime,mode=755"
1219 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1221 # check if there are any nfs options
1222 if echo ${NFS_COW}|grep -q ','
1224 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1225 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1227 nfs_cow_opts="-o nolock"
1233 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1236 panic "unable to determine mac address"
1241 cow_mountopt="rw,noatime,mode=755"
1244 if [ "${cow_fstype}" = "nfs" ]
1247 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1248 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1249 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1251 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1252 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1255 rofscount=$(echo ${rofslist} |wc -w)
1257 if [ -n "${EXPOSED_ROOT}" ]
1259 if [ ${rofscount} -ne 1 ]
1261 panic "only one RO file system supported with exposedroot: ${rofslist}"
1263 exposedrootfs=${rofslist%% }
1265 mount --bind ${exposedrootfs} ${rootmnt} || \
1266 panic "bind mount of ${exposedrootfs} failed"
1268 if [ -z "${SKIP_UNION_MOUNTS}" ]
1270 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1275 for dir in ${cow_dirs}; do
1277 mount -t ${UNIONTYPE} \
1278 -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
1279 ${UNIONTYPE} "${rootmnt}${dir}" || \
1280 panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
1281 rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1284 mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
1285 ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
1286 ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
1289 # tmpfs file systems
1291 mkdir -p "${rootmnt}/live"
1292 mount -t tmpfs tmpfs ${rootmnt}/live
1294 # Adding other custom mounts
1295 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1297 # directly mount /home
1298 # FIXME: add a custom mounts configurable system
1300 if [ -b "${homecow}" ]
1302 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1303 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1305 log_warning_msg "Unable to find the persistent home medium"
1308 # Look for other snapshots to copy in
1309 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1310 # This second type should be removed when snapshot grow smarter
1311 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1314 if [ -n "${SHOWMOUNTS}" ]
1316 for d in ${rofslist}
1318 mkdir -p "${rootmnt}/live/${d##*/}"
1322 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1326 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1332 # shows cow fs on /cow for use by live-snapshot
1333 mkdir -p "${rootmnt}/live/cow"
1334 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"
1341 skip_uuid_check="${3}"
1343 if [ -z "${devname}" ]
1345 devname=$(sys2dev "${sysdev}")
1348 if [ -d "${devname}" ]
1350 mount -o bind "${devname}" $mountpoint || continue
1352 if is_live_path $mountpoint
1361 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1363 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1364 devname="${loopdevname}"
1367 fstype=$(get_fstype "${devname}")
1369 if is_supported_fs ${fstype}
1371 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1373 if is_live_path ${mountpoint} && \
1374 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1379 umount ${mountpoint}
1383 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1385 losetup -d "${loopdevname}"
1395 # don't start autodetection before timeout has expired
1396 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1398 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1404 # first look at the one specified in the command line
1405 case "${LIVE_MEDIA}" in
1407 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1409 if [ "$(cat ${sysblock}/removable)" = "1" ]
1411 if readlink ${sysblock}/device | grep -q usb
1413 for dev in $(subdevices "${sysblock}")
1415 if check_dev "${dev}"
1426 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1428 if [ "$(cat ${sysblock}/removable)" = "1" ]
1430 for dev in $(subdevices "${sysblock}")
1432 if check_dev "${dev}"
1442 if [ ! -z "${LIVE_MEDIA}" ]
1444 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1452 # or do the scan of block devices
1453 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1455 devname=$(sys2dev "${sysblock}")
1456 fstype=$(get_fstype "${devname}")
1458 if /lib/udev/cdrom_id ${devname} > /dev/null
1460 if check_dev "null" "${devname}"
1464 elif is_nice_device "${sysblock}"
1466 for dev in $(subdevices "${sysblock}")
1468 if check_dev "${dev}"
1473 elif [ "${fstype}" = "squashfs" -o \
1474 "${fstype}" = "ext2" -o \
1475 "${fstype}" = "ext3" -o \
1476 "${fstype}" = "ext4" -o \
1477 "${fstype}" = "jffs2" ]
1479 # This is an ugly hack situation, the block device has
1480 # an image directly on it. It's hopefully
1481 # live-initramfs, so take it and run with it.
1482 ln -s "${devname}" "${devname}.${fstype}"
1483 echo "${devname}.${fstype}"
1491 set_usplash_timeout ()
1493 if [ -x /sbin/usplash_write ]
1495 /sbin/usplash_write "TIMEOUT 120"
1496 else if [ -x /sbin/splashy_update ] ; then
1497 /sbin/splashy_update "TIMEOUT 120"
1503 media_mountpoint="${1}"
1505 log_begin_msg "Checking media integrity"
1507 cd ${media_mountpoint}
1508 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1513 if [ "${RC}" -eq 0 ]
1515 log_success_msg "Everything ok, will reboot in 10 seconds."
1518 umount ${media_mountpoint}
1520 echo u > /proc/sysrq-trigger
1521 echo b > /proc/sysrq-trigger
1523 panic "Not ok, a media defect is likely, switch to VT8 for details."
1529 if [ -x /scripts/local-top/cryptroot ]; then
1530 /scripts/local-top/cryptroot
1537 tail -f live.log >&7 &
1540 # Ensure 'panic' function is overridden
1541 . /scripts/live-functions
1547 maybe_break live-premount
1548 log_begin_msg "Running /scripts/live-premount"
1549 run_scripts /scripts/live-premount
1552 # Needed here too because some things (*cough* udev *cough*)
1553 # changes the timeout
1557 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1561 livefs_root="${mountpoint}"
1563 panic "Unable to find a live file system on the network"
1566 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1568 # Do a local boot from hd
1571 # Scan local devices for the image
1573 while [ "$i" -lt 60 ]
1575 livefs_root=$(find_livefs ${i})
1577 if [ -n "${livefs_root}" ]
1588 if [ -z "${livefs_root}" ]
1590 panic "Unable to find a medium containing a live file system"
1593 if [ "${INTEGRITY_CHECK}" ]
1595 integrity_check "${livefs_root}"
1601 elif [ "${TODISK}" ]
1603 live_dest="${TODISK}"
1606 if [ "${live_dest}" ]
1608 log_begin_msg "Copying live media to ${live_dest}"
1609 copy_live_to "${livefs_root}" "${live_dest}"
1613 if [ -n "${MODULETORAMFILE}" ]
1615 setup_unionfs "${livefs_root}" "${rootmnt}"
1618 mac="$(echo ${mac} | sed 's/-//g')"
1619 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1624 maybe_break live-bottom
1625 log_begin_msg "Running /scripts/live-bottom\n"
1627 run_scripts /scripts/live-bottom
1633 [ -w "${rootmnt}/var/log/" ] && cp live.log "${rootmnt}/var/log/" 2>/dev/null