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 FORCEPERSISTENTFSCK="Yes"
76 export FORCEPERSISTENTFSCK
80 HOOK="${ARGUMENT#hook=}"
85 FTPFS="${ARGUMENT#ftpfs=}"
90 HTTPFS="${ARGUMENT#httpfs=}"
95 HOSTNAME="${ARGUMENT#hostname=}"
97 export HOSTNAME LIVECONF
101 FROMISO="${ARGUMENT#*=}"
106 USERNAME="${ARGUMENT#username=}"
108 export USERNAME LIVECONF
112 USERFULLNAME="${ARGUMENT#userfullname=}"
114 export USERFULLNAME LIVECONF
123 INTEGRITY_CHECK="Yes"
124 export INTEGRITY_CHECK
128 STATICIP="${ARGUMENT#ip=}"
130 if [ -z "${STATICIP}" ]
138 keyb=*|kbd-chooser/method=*)
143 klayout=*|console-setup/layoutcode=*)
144 KLAYOUT="${ARGUMENT#*=}"
148 kvariant=*|console-setup/variantcode=*)
149 KVARIANT="${ARGUMENT#*=}"
153 kmodel=*|console-setup/modelcode=*)
154 KMODEL="${ARGUMENT#*=}"
159 KOPTIONS="${ARGUMENT#koptions=}"
168 live-media=*|bootfrom=*)
169 LIVE_MEDIA="${ARGUMENT#*=}"
173 live-media-encryption=*|encryption=*)
174 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
175 export LIVE_MEDIA_ENCRYPTION
179 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
180 export LIVE_MEDIA_OFFSET
184 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
185 export LIVE_MEDIA_PATH
188 live-media-timeout=*)
189 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
190 export LIVE_MEDIA_TIMEOUT
193 language=*|debian-installer/language=*)
194 language=${x#debian-installer/language=}
195 locale="$(lang2locale "$language")"
199 locale=*|debian-installer/locale=*)
200 LOCALE="${ARGUMENT#*=}"
205 MODULE="${ARGUMENT#module=}"
210 NETBOOT="${ARGUMENT#netboot=}"
215 NFSOPTS="${ARGUMENT#nfsopts=}"
220 NFS_COW="${ARGUMENT#nfscow=}"
225 NOACCESSIBILITY="Yes"
226 export NOACCESSIBILITY
250 NOCONSOLEKEYBOARD="Yes"
251 export NOCONSOLEKEYBOARD
275 NOKPERSONALIZER="Yes"
276 export NOKPERSONALIZER
280 NOLANGUAGESELECTOR="Yes"
281 export NOLANGUAGESELECTOR
295 NOPOWERMANAGEMENT="Yes"
296 export NOPOWERMANAGEMENT
300 NOPROGRAMCRASHES="Yes"
301 export NOPROGRAMCRASHES
320 NOUPDATENOTIFIER="Yes"
321 export NOUPDATENOTIFIER
336 export NOXSCREENSAVER
345 PERSISTENT="${ARGUMENT#persistent=}"
346 if [ -z "${PERSISTENT}" ]
354 PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
355 export PERSISTENT_PATH
358 persistent-subtext=*)
359 root_persistence="${root_persistence}-${ARGUMENT#persistent-subtext=}"
360 home_persistence="${home_persistence}-${ARGUMENT#persistent-subtext=}"
361 root_snapshot_label="${root_snapshot_label}-${ARGUMENT#persistent-subtext=}"
362 home_snapshot_label="${home_snapshot_label}-${ARGUMENT#persistent-subtext=}"
370 preseed/file=*|file=*)
371 LOCATION="${ARGUMENT#*=}"
381 location="${ARGUMENT#url=}"
383 mount -o bind /sys /root/sys
384 mount -o bind /proc /root/proc
385 mount -o bind /dev /root/dev
387 mkdir -p /root/var/run/network
388 chroot /root dhclient eth0
389 chroot /root wget -P /tmp "${location}"
390 chroot /root ifconfig eth0 down
396 LOCATION="/tmp/$(basename "${location}")"
400 question="${ARGUMENT%%=*}"
401 value="${ARGUMENT#*=}"
402 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
422 TIMEZONE="${ARGUMENT#timezone=}"
432 TODISK="${ARGUMENT#todisk=}"
443 MODULETORAM="${ARGUMENT#toram=}"
444 export TORAM MODULETORAM
458 SKIP_UNION_MOUNTS="Yes"
459 export SKIP_UNION_MOUNTS
463 ROOT="${ARGUMENT#root=}"
468 UNIONTYPE="${ARGUMENT#union=}"
473 UTC="${ARGUMENT#utc=}"
483 XDRIVER="${ARGUMENT#xdriver=}"
488 XVIDEOMODE="${ARGUMENT#xvideomode=}"
494 # sort of compatibility with netboot.h from linux docs
495 if [ -z "${NETBOOT}" ]
497 if [ "${ROOT}" = "/dev/nfs" ]
501 elif [ "${ROOT}" = "/dev/cifs" ]
508 if [ -z "${MODULE}" ]
514 if [ -z "${UNIONTYPE}" ]
525 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
527 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
529 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
541 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
547 uuid="$(cat /conf/uuid.conf)"
549 for try_uuid_file in "${path}/.disk/live-uuid"*
551 [ -e "${try_uuid_file}" ] || continue
553 try_uuid="$(cat "${try_uuid_file}")"
555 if [ "${uuid}" = "${try_uuid}" ]
564 get_backing_device ()
567 *.squashfs|*.ext2|*.ext3|*.ext4|*.jffs2)
568 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
576 panic "Unrecognized live filesystem: ${1}"
581 match_files_in_dir ()
583 # Does any files match pattern ${1} ?
586 if [ "$(echo ${pattern})" != "${pattern}" ]
594 mount_images_in_directory ()
601 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
602 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
603 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
604 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
605 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
606 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
608 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
609 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
611 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
617 sysfs_path="${1#/sys}"
619 if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-)"
622 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
634 copyto="${copyfrom}_swap"
636 if [ -z "${MODULETORAM}" ]
638 size=$(fs_size "" ${copyfrom}/${LIVE_MEDIA_PATH} "used")
640 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
642 if [ -f "${MODULETORAMFILE}" ]
644 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
646 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
651 if [ "${copytodev}" = "ram" ]
654 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
655 mount_options="-o size=${size}k"
660 # it should be a writable block device
661 if [ -b "${copytodev}" ]
665 fstype=$(get_fstype "${dev}")
666 freespace=$(fs_size "${dev}")
668 log_warning_msg "${copytodev} is not a block device."
673 if [ "${freespace}" -lt "${size}" ]
675 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
679 # begin copying (or uncompressing)
681 log_begin_msg "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
682 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
684 if [ "${extension}" = "tgz" ]
687 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
688 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
689 mount -r -o move "${copyto}" "${rootmnt}"
692 if [ -n "${MODULETORAMFILE}" ]
696 echo " * Copying $MODULETORAMFILE to RAM" 1>/dev/console
697 rsync -a --progress ${MODULETORAMFILE} ${copyto} 1>/dev/console # copy only the filesystem module
699 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
704 echo " * Copying whole medium to RAM" 1>/dev/console
705 rsync -a --progress ${copyfrom}/* ${copyto} 1>/dev/console # "cp -a" from busybox also copies hidden files
707 mkdir -p ${copyto}/${LIVE_MEDIA_PATH}
708 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH} # "cp -a" from busybox also copies hidden files
713 mount -r -o move ${copyto} ${copyfrom}
724 modprobe -q af_packet # For DHCP
726 if [ -x /sbin/udevadm ]
737 ipconfig ${DEVICE} | tee /netboot.config
739 # source relevant ipconfig output
740 OLDHOSTNAME=${HOSTNAME}
741 . /tmp/net-${DEVICE}.conf
742 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
745 # Check if we have a network device at all
746 if ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
747 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
748 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
749 ! ls /sys/class/net/ra0 > /dev/null 2>&1
751 panic "No supported network device found, maybe a non-mainline driver is required."
754 if [ "${NFSROOT}" = "auto" ]
756 NFSROOT=${ROOTSERVER}:${ROOTPATH}
759 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
765 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
767 NFSROOT=${ROOTSERVER}:${NFSROOT}
770 log_begin_msg "Trying netboot from ${NFSROOT}"
772 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
789 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
790 mount -t ramfs ram "${mountpoint}"
793 for webfile in HTTPFS FTPFS FETCH
795 url="$(eval echo \"\$\{${webfile}\}\")"
796 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
800 case "${extension}" in
802 if [ "${webfile}" = "FETCH" ]
806 ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
807 rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
808 lfile="$(basename $url)"
809 log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
810 tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
814 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
815 wget "${url}" -O "${dest}/$(basename ${url})"
819 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
820 if [ "${webfile}" = "FTPFS" ]
822 FUSE_MOUNT="curlftpfs"
823 url="$(dirname ${url})"
828 $FUSE_MOUNT "${url}" "${dest}"
830 [ ${?} -eq 0 ] && rc=0
831 [ "${extension}" = "tgz" ] && live_dest="ram"
836 log_begin_msg "Unrecognized archive extension for ${url}"
844 umount "${mountpoint}"
856 if [ -z "${NFSOPTS}" ]
861 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
863 # FIXME: This while loop is an ugly HACK round an nfs bug
865 while [ "$i" -lt 60 ]
867 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
879 if [ -x "/sbin/mount.cifs" ]
881 if [ -z "${NFSOPTS}" ]
883 CIFSOPTS="-ouser=root,password="
885 CIFSOPTS="${NFSOPTS}"
888 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
891 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
905 size=$(fs_size "${fromdev}" "" "used")
907 if [ -b "${fromdev}" ]
910 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
912 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
913 freespace=$(df -k | awk '/'${todev}'/{print $4}')
915 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
918 tomount="/mnt/tmpsnap"
920 if [ ! -d "${tomount}" ]
922 mkdir -p "${tomount}"
925 fstype=$(get_fstype "${fromdev}")
927 if [ -n "${fstype}" ]
930 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
931 cp -a "${tomount}"/* ${todir}
934 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
939 if echo ${fromdev} | grep -qs loop
941 losetup -d "${fromdev}"
948 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
954 # Look for ${snap_label}.* in block devices
957 if [ "${PERSISTENT}" != "nofiles" ]
959 # search for image files
960 snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snap_label}.ext4 ${snap_label}.jffs2")
963 if [ -z "${snapdata}" ]
965 snapdata=$(find_cow_device "${snap_label}")
972 # copy the contents of previously found snapshot to ${snap_mount}
973 # and remember the device and filename for resync on exit in live-initramfs.init
979 if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
981 log_success_msg "found snapshot: ${snapdata}"
982 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
983 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
984 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
987 if ! try_mount "${snapdev}" "${snapback}" "ro"
992 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
994 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
995 dev=$(get_backing_device "${snapback}/${snapfile}")
997 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1002 zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
1004 if [ "${RES}" != "0" ]
1006 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
1011 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
1013 if [ "${RES}" != "0" ]
1015 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
1018 elif [ -b "${snapdata}" ]
1020 # Try to find if it could be a snapshot partition
1022 log_success_msg "found snapshot ${snap_type} device on ${dev}"
1023 if echo "${dev}" | grep -qs loop
1025 # strange things happens, user confused?
1026 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
1027 snapfile=$(basename ${snaploop})
1028 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
1033 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1035 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1038 if [ -n "${snapfile}" ]
1040 # it was a loop device, user confused
1045 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1049 echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1055 image_directory="${1}"
1057 addimage_directory="${3}"
1058 modprobe -q -b ${UNIONTYPE}
1060 # run-init can't deal with images in a subdir, but we're going to
1061 # move all of these away before it runs anyway. No, we're not,
1062 # put them in / since move-mounting them into / breaks mono and
1067 # Let's just mount the read-only file systems first
1070 minor_kernel_version=$(uname -r|cut -c 5-|sed 's/[^0-9].*//')
1072 if [ "${NETBOOT}" = "nfs" ] && [ "${minor_kernel_version}" -lt 22 ]
1074 # go aroung a bug in nfs-unionfs locking for unionfs <= 1.4
1076 elif [ "${UNIONTYPE}" = "aufs" ]
1083 if [ -z "${PLAIN_ROOT}" ]
1085 # Read image names from ${MODULE}.module if it exists
1086 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1088 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1090 image_string="${image_string} ${image_directory}/${IMAGE}"
1092 elif [ -e "${image_directory}/${MODULE}.module" ]
1094 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1096 image_string="${image_string} ${image_directory}/${IMAGE}"
1099 # ${MODULE}.module does not exist, create a list of images
1100 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1102 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1104 if [ -e "${IMAGE}" ]
1106 image_string="${image_string} ${IMAGE}"
1111 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1113 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1115 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1117 if [ -e "${IMAGE}" ]
1119 image_string="${image_string} ${IMAGE}"
1126 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1129 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1133 for image in ${image_string}
1135 imagename=$(basename "${image}")
1137 export image devname
1138 maybe_break live-realpremount
1139 log_begin_msg "Running /scripts/live-realpremount"
1140 run_scripts /scripts/live-realpremount
1143 if [ -d "${image}" ]
1145 # it is a plain directory: do nothing
1146 rofsstring="${image}=${roopt}:${rofsstring}"
1147 rofslist="${image} ${rofslist}"
1148 elif [ -f "${image}" ]
1150 if losetup --help 2>&1 | grep -q -- "-r\b"
1152 backdev=$(get_backing_device "${image}" "-r")
1154 backdev=$(get_backing_device "${image}")
1156 fstype=$(get_fstype "${backdev}")
1158 if [ "${fstype}" = "unknown" ]
1160 panic "Unknown file system type on ${backdev} (${image})"
1163 if [ -z "${fstype}" ]
1165 fstype="${imagename##*.}"
1166 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1169 mkdir -p "${croot}/${imagename}"
1170 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1171 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}"
1176 # we have a plain root system
1177 mkdir -p "${croot}/filesystem"
1178 log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
1179 mount -t $(get_fstype "${image_directory}") -o ro,noatime "${image_directory}" "${croot}/filesystem" || panic "Can not mount ${image_directory} on ${croot}/filesystem" && rofsstring="${croot}/filesystem=${roopt}:${rofsstring}" && rofslist="${croot}/filesystem ${rofslist}"
1181 mount -o bind ${croot}/filesystem $mountpoint
1185 rofsstring=${rofsstring%:}
1189 # Looking for "${root_persistence}" device or file
1190 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1193 num_block=$(ls -l /sys/block | wc -l)
1194 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1196 modprobe -q -b ${module}
1199 if [ -x /sbin/udevadm ]
1210 # For some reason, udevsettle does not block in this scenario,
1211 # so we sleep for a little while.
1213 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1214 for timeout in 5 4 3 2 1
1218 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1224 # search for label and files (this could be hugely optimized)
1225 cowprobe=$(find_cow_device "${root_persistence}")
1226 if [ -b "${cowprobe}" ]
1228 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1229 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1230 # snapshots to be sure to really store some e.g key config files,
1231 # but not on the same media
1232 blacklistdev="${cowprobe}"
1233 PERSISTENCE_IS_ON="1"
1234 export PERSISTENCE_IS_ON
1236 # homecow just mount something on /home, this should be generalized some way
1237 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1238 if [ -b "${homecow}" ]
1240 PERSISTENCE_IS_ON="1"
1241 export PERSISTENCE_IS_ON
1243 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1244 # This second type should be removed when snapshot will get smarter,
1245 # hence when "/etc/live-snapshot*list" will be supported also by
1246 # ext2|ext3|ext4|jffs2 snapshot types.
1247 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1249 if [ -b "${cowprobe}" ]
1251 cowdevice=${cowprobe}
1252 cow_fstype=$(get_fstype "${cowprobe}")
1253 cow_mountopt="rw,noatime"
1255 if [ "${FORCEPERSISTENTFSCK}" = "Yes" ]
1257 fsck -y ${cowdevice}
1260 log_warning_msg "Unable to find the persistent medium"
1263 cow_mountopt="rw,noatime,mode=755"
1265 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1267 # check if there are any nfs options
1268 if echo ${NFS_COW}|grep -q ','
1270 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1271 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1273 nfs_cow_opts="-o nolock"
1279 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1282 panic "unable to determine mac address"
1287 cow_mountopt="rw,noatime,mode=755"
1290 if [ "${cow_fstype}" = "nfs" ]
1293 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1294 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1295 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1297 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1298 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1301 rofscount=$(echo ${rofslist} |wc -w)
1303 if [ -n "${EXPOSED_ROOT}" ]
1305 if [ ${rofscount} -ne 1 ]
1307 panic "only one RO file system supported with exposedroot: ${rofslist}"
1309 exposedrootfs=${rofslist%% }
1311 mount --bind ${exposedrootfs} ${rootmnt} || \
1312 panic "bind mount of ${exposedrootfs} failed"
1314 if [ -z "${SKIP_UNION_MOUNTS}" ]
1316 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1321 for dir in ${cow_dirs}; do
1323 mount -t ${UNIONTYPE} \
1324 -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
1325 ${UNIONTYPE} "${rootmnt}${dir}" || \
1326 panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
1327 rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1330 mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
1331 ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
1332 ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
1335 # Correct the permissions of /:
1336 chmod 0755 "${rootmnt}"
1338 # tmpfs file systems
1340 mkdir -p "${rootmnt}/live"
1341 mount -t tmpfs tmpfs ${rootmnt}/live
1343 # Adding other custom mounts
1344 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1346 # directly mount /home
1347 # FIXME: add a custom mounts configurable system
1349 if [ -b "${homecow}" ]
1351 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1352 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1354 log_warning_msg "Unable to find the persistent home medium"
1357 # Look for other snapshots to copy in
1358 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1359 # This second type should be removed when snapshot grow smarter
1360 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1363 if [ -n "${SHOWMOUNTS}" ]
1365 for d in ${rofslist}
1367 mkdir -p "${rootmnt}/live/${d##*/}"
1371 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1375 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1381 # shows cow fs on /cow for use by live-snapshot
1382 mkdir -p "${rootmnt}/live/cow"
1383 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"
1390 skip_uuid_check="${3}"
1392 # support for fromiso=.../isofrom=....
1393 if [ -n "$FROMISO" ]
1396 ISO_DEVICE="$(echo $FROMISO | sed 's|\(/dev/[a-z]*[0-9]*\).*|\1|')"
1397 mount "$ISO_DEVICE" /isofrom
1398 ISO_NAME="$(echo $FROMISO | sed 's|/dev/[a-z]*[0-9]*/||')"
1399 loopdevname=$(setup_loop "/isofrom/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
1400 devname="${loopdevname}"
1403 if [ -z "${devname}" ]
1405 devname=$(sys2dev "${sysdev}")
1408 if [ -d "${devname}" ]
1410 mount -o bind "${devname}" $mountpoint || continue
1412 if is_live_path $mountpoint
1421 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1423 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1424 devname="${loopdevname}"
1427 fstype=$(get_fstype "${devname}")
1429 if is_supported_fs ${fstype}
1431 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1433 if is_live_path ${mountpoint} && \
1434 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1439 umount ${mountpoint}
1443 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1445 losetup -d "${loopdevname}"
1455 # don't start autodetection before timeout has expired
1456 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1458 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1464 # first look at the one specified in the command line
1465 case "${LIVE_MEDIA}" in
1467 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1469 if [ "$(cat ${sysblock}/removable)" = "1" ]
1471 if readlink ${sysblock} | grep -q usb ||
1472 readlink ${sysblock}/device | grep -q usb # linux < 2.6.29
1474 for dev in $(subdevices "${sysblock}")
1476 if check_dev "${dev}"
1487 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1489 if [ "$(cat ${sysblock}/removable)" = "1" ]
1491 for dev in $(subdevices "${sysblock}")
1493 if check_dev "${dev}"
1503 if [ ! -z "${LIVE_MEDIA}" ]
1505 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1513 # or do the scan of block devices
1514 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1516 devname=$(sys2dev "${sysblock}")
1517 fstype=$(get_fstype "${devname}")
1519 if /lib/udev/cdrom_id ${devname} > /dev/null
1521 if check_dev "null" "${devname}"
1525 elif is_nice_device "${sysblock}"
1527 for dev in $(subdevices "${sysblock}")
1529 if check_dev "${dev}"
1534 elif [ "${fstype}" = "squashfs" -o \
1535 "${fstype}" = "ext2" -o \
1536 "${fstype}" = "ext3" -o \
1537 "${fstype}" = "ext4" -o \
1538 "${fstype}" = "jffs2" ]
1540 # This is an ugly hack situation, the block device has
1541 # an image directly on it. It's hopefully
1542 # live-initramfs, so take it and run with it.
1543 ln -s "${devname}" "${devname}.${fstype}"
1544 echo "${devname}.${fstype}"
1552 set_usplash_timeout ()
1554 if [ -x /sbin/usplash_write ]
1556 /sbin/usplash_write "TIMEOUT 120"
1557 else if [ -x /sbin/splashy_update ] ; then
1558 /sbin/splashy_update "TIMEOUT 120"
1564 media_mountpoint="${1}"
1566 log_begin_msg "Checking media integrity"
1568 cd ${media_mountpoint}
1569 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1574 if [ "${RC}" -eq 0 ]
1576 log_success_msg "Everything ok, will reboot in 10 seconds."
1579 umount ${media_mountpoint}
1581 echo u > /proc/sysrq-trigger
1582 echo b > /proc/sysrq-trigger
1584 panic "Not ok, a media defect is likely, switch to VT8 for details."
1590 if [ -x /scripts/local-top/cryptroot ]; then
1591 /scripts/local-top/cryptroot
1598 tail -f live.log >&7 &
1601 # Ensure 'panic' function is overridden
1602 . /scripts/live-functions
1608 maybe_break live-premount
1609 log_begin_msg "Running /scripts/live-premount"
1610 run_scripts /scripts/live-premount
1613 # Needed here too because some things (*cough* udev *cough*)
1614 # changes the timeout
1618 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1622 livefs_root="${mountpoint}"
1624 panic "Unable to find a live file system on the network"
1627 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1629 # Do a local boot from hd
1632 # Scan local devices for the image
1634 while [ "$i" -lt 60 ]
1636 livefs_root=$(find_livefs ${i})
1638 if [ -n "${livefs_root}" ]
1649 if [ -z "${livefs_root}" ]
1651 panic "Unable to find a medium containing a live file system"
1654 if [ "${INTEGRITY_CHECK}" ]
1656 integrity_check "${livefs_root}"
1662 elif [ "${TODISK}" ]
1664 live_dest="${TODISK}"
1667 if [ "${live_dest}" ]
1669 log_begin_msg "Copying live media to ${live_dest}"
1670 copy_live_to "${livefs_root}" "${live_dest}"
1674 # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
1675 # because the mountpoint is left behind in /proc/mounts, so let's get
1676 # rid of it when running from RAM
1677 if [ -n "$FROMISO" ] && [ "${TORAM}" ]
1679 losetup -d /dev/loop0
1680 grep -q /isofrom /proc/mounts && umount /isofrom
1683 if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
1685 setup_unionfs "${livefs_root}" "${rootmnt}"
1688 mac="$(echo ${mac} | sed 's/-//g')"
1689 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1694 maybe_break live-bottom
1695 log_begin_msg "Running /scripts/live-bottom\n"
1697 run_scripts /scripts/live-bottom
1703 [ -w "${rootmnt}/var/log/" ] && cp live.log "${rootmnt}/var/log/" 2>/dev/null