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 alt_mountpoint="/media"
12 LIVE_MEDIA_PATH="live"
14 root_persistence="live-rw"
15 home_persistence="home-rw"
16 root_snapshot_label="live-sn"
17 home_snapshot_label="home-sn"
20 USERFULLNAME="Live user"
23 mkdir -p "${mountpoint}"
26 # Create /etc/mtab for debug purpose and future syncs
37 . /scripts/live-helpers
39 if [ ! -f /live.vars ]
49 for ARGUMENT in $(cat /proc/cmdline)
55 NOCONSOLEKEYBOARD="Yes"
61 export NOACCESSIBILITY NOAUTOLOGIN NOCONSOLEKEYBOARD NOFASTBOOT NOFSTAB NONETWORKING NOXAUTOCONFIG
65 ACCESS="${ARGUMENT#access=}"
70 DEFCONSOLE="${ARGUMENT#*=}"
82 # Force dhcp even while netbooting
83 # Use for debugging in case somebody works on fixing dhclient
93 DEVICE="${ARGUMENT#ethdevice=}"
98 ETHDEVICE="${ARGUMENT#ethdevice=}"
103 ETHDEV_TIMEOUT="${ARGUMENT#ethdevice-timeout=}"
104 export ETHDEV_TIMEOUT
108 FETCH="${ARGUMENT#fetch=}"
113 FORCEPERSISTENTFSCK="Yes"
114 export FORCEPERSISTENTFSCK
118 FTPFS="${ARGUMENT#ftpfs=}"
123 HTTPFS="${ARGUMENT#httpfs=}"
128 FROMISO="${ARGUMENT#*=}"
138 INTEGRITY_CHECK="Yes"
139 export INTEGRITY_CHECK
143 STATICIP="${ARGUMENT#ip=}"
145 if [ -z "${STATICIP}" ]
153 keyb=*|kbd-chooser/method=*)
158 klayout=*|console-setup/layoutcode=*)
159 KLAYOUT="${ARGUMENT#*=}"
163 kvariant=*|console-setup/variantcode=*)
164 KVARIANT="${ARGUMENT#*=}"
168 kmodel=*|console-setup/modelcode=*)
169 KMODEL="${ARGUMENT#*=}"
174 KOPTIONS="${ARGUMENT#koptions=}"
183 live-media=*|bootfrom=*)
184 LIVE_MEDIA="${ARGUMENT#*=}"
188 live-media-encryption=*|encryption=*)
189 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
190 export LIVE_MEDIA_ENCRYPTION
194 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
195 export LIVE_MEDIA_OFFSET
199 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
200 export LIVE_MEDIA_PATH
203 live-media-timeout=*)
204 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
205 export LIVE_MEDIA_TIMEOUT
209 MODULE="${ARGUMENT#module=}"
214 NETBOOT="${ARGUMENT#netboot=}"
219 NFSOPTS="${ARGUMENT#nfsopts=}"
224 NFS_COW="${ARGUMENT#nfscow=}"
229 NOACCESSIBILITY="Yes"
230 export NOACCESSIBILITY
239 NOCONSOLEKEYBOARD="Yes"
240 export NOCONSOLEKEYBOARD
274 PERSISTENT="${ARGUMENT#persistent=}"
275 if [ -z "${PERSISTENT}" ]
283 PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
284 export PERSISTENT_PATH
287 persistent-subtext=*)
288 root_persistence="${root_persistence}-${ARGUMENT#persistent-subtext=}"
289 home_persistence="${home_persistence}-${ARGUMENT#persistent-subtext=}"
290 root_snapshot_label="${root_snapshot_label}-${ARGUMENT#persistent-subtext=}"
291 home_snapshot_label="${home_snapshot_label}-${ARGUMENT#persistent-subtext=}"
300 QUICKUSBMODULES="Yes"
301 export QUICKUSBMODULES
304 preseed/file=*|file=*)
305 LOCATIONS="${ARGUMENT#*=} ${LOCATIONS}"
315 question="${ARGUMENT%%=*}"
316 value="${ARGUMENT#*=}"
317 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
332 TODISK="${ARGUMENT#todisk=}"
343 MODULETORAM="${ARGUMENT#toram=}"
344 export TORAM MODULETORAM
358 SKIP_UNION_MOUNTS="Yes"
359 export SKIP_UNION_MOUNTS
363 ROOT="${ARGUMENT#root=}"
368 UNIONTYPE="${ARGUMENT#union=}"
378 XDRIVER="${ARGUMENT#xdriver=}"
383 XVIDEOMODE="${ARGUMENT#xvideomode=}"
389 # sort of compatibility with netboot.h from linux docs
390 if [ -z "${NETBOOT}" ]
392 if [ "${ROOT}" = "/dev/nfs" ]
396 elif [ "${ROOT}" = "/dev/cifs" ]
403 if [ -z "${MODULE}" ]
409 if [ -z "${UNIONTYPE}" ]
420 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
422 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
424 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
436 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
442 uuid="$(cat /conf/uuid.conf)"
444 for try_uuid_file in "${path}/.disk/live-uuid"*
446 [ -e "${try_uuid_file}" ] || continue
448 try_uuid="$(cat "${try_uuid_file}")"
450 if [ "${uuid}" = "${try_uuid}" ]
459 get_backing_device ()
462 *.squashfs|*.ext2|*.ext3|*.ext4|*.jffs2)
463 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
471 panic "Unrecognized live filesystem: ${1}"
476 match_files_in_dir ()
478 # Does any files match pattern ${1} ?
481 if [ "$(echo ${pattern})" != "${pattern}" ]
489 mount_images_in_directory ()
496 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
497 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
498 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
499 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
500 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
501 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
503 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
504 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
506 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
512 sysfs_path="${1#/sys}"
514 if /lib/udev/path_id "${sysfs_path}" | egrep -q "ID_PATH=(usb|pci-|platform-orion-ehci|platform-mmc|platform-mxsdhci|)"
517 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
520 elif echo ${sysfs_path} | grep -q "^/block/dm-"
532 copyto="${copyfrom}_swap"
534 if [ -z "${MODULETORAM}" ]
536 size=$(fs_size "" ${copyfrom}/${LIVE_MEDIA_PATH} "used")
538 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
540 if [ -f "${MODULETORAMFILE}" ]
542 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
544 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
549 if [ "${copytodev}" = "ram" ]
552 freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
553 mount_options="-o size=${size}k"
558 # it should be a writable block device
559 if [ -b "${copytodev}" ]
563 fstype=$(get_fstype "${dev}")
564 freespace=$(fs_size "${dev}")
566 log_warning_msg "${copytodev} is not a block device."
571 if [ "${freespace}" -lt "${size}" ]
573 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
577 # begin copying (or uncompressing)
579 log_begin_msg "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
580 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
582 if [ "${extension}" = "tgz" ]
585 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
586 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
587 mount -r -o move "${copyto}" "${rootmnt}"
590 if [ -n "${MODULETORAMFILE}" ]
594 echo " * Copying $MODULETORAMFILE to RAM" 1>/dev/console
595 rsync -a --progress ${MODULETORAMFILE} ${copyto} 1>/dev/console # copy only the filesystem module
597 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
602 echo " * Copying whole medium to RAM" 1>/dev/console
603 rsync -a --progress ${copyfrom}/* ${copyto} 1>/dev/console # "cp -a" from busybox also copies hidden files
605 mkdir -p ${copyto}/${LIVE_MEDIA_PATH}
606 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH}
607 if [ -e ${copyfrom}/${LIVE_MEDIA_PATH}/.disk ]
609 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/.disk ${copyto}
615 mount -r -o move ${copyto} ${copyfrom}
624 modprobe -q af_packet # For DHCP
629 if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
630 [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
633 # if ethdevice was not specified on the kernel command line
634 # make sure we try to get a working network configuration
635 # for *every* present network device (except for loopback of course)
636 if [ -z "$ETHDEVICE" ] ; then
637 echo "If you want to boot from a specific device use bootoption ethdevice=..."
638 for device in /sys/class/net/*; do
640 if [ "$dev" != "lo" ] ; then
641 ETHDEVICE="$ETHDEVICE $dev"
646 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
647 for device in $(echo $ETHDEVICE | sed 's/,/ /g') ; do
648 devlist="$devlist $device"
651 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
652 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
654 # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
655 # an endless loop; iff execution fails give it two further tries, that's
656 # why we use '$devlist $devlist $devlist' for the other for loop
657 for dev in $devlist $devlist $devlist ; do
658 echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
659 ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
661 sleep "$ETHDEV_TIMEOUT" ; sleep 1
662 if [ -r /proc/"$jobid"/status ] ; then
663 echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
667 # if configuration of device worked we should have an assigned
668 # IP address, iff so let's use the according as $DEVICE for later usage
669 # simple and primitive approach which seems to work fine
670 if ifconfig $dev | grep -q 'inet.*addr:' ; then
677 ipconfig ${DEVICE} | tee /netboot.config
680 # source relevant ipconfig output
681 OLDHOSTNAME=${HOSTNAME}
682 . /tmp/net-${DEVICE}.conf
683 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
686 # Check if we have a network device at all
687 if ! ls /sys/class/net/"$DEVICE" > /dev/null 2>&1 && \
688 ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
689 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
690 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
691 ! ls /sys/class/net/ra0 > /dev/null 2>&1
693 panic "No supported network device found, maybe a non-mainline driver is required."
696 if [ "${NFSROOT}" = "auto" ]
698 NFSROOT=${ROOTSERVER}:${ROOTPATH}
703 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] )
709 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
711 NFSROOT=${ROOTSERVER}:${NFSROOT}
714 log_begin_msg "Trying netboot from ${NFSROOT}"
716 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
734 for webfile in HTTPFS FTPFS FETCH
736 local url="$(eval echo \"\$\{${webfile}\}\")"
737 local extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
741 case "${extension}" in
742 iso|squashfs|tgz|tar)
743 if [ "${extension}" = "iso" ]
745 mkdir -p "${alt_mountpoint}"
746 dest="${alt_mountpoint}"
748 local dest="${mountpoint}/${LIVE_MEDIA_PATH}"
749 mount -t ramfs ram "${mountpoint}"
752 if [ "${webfile}" = "FETCH" ]
756 ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
757 rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
758 lfile="$(basename $url)"
759 log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
760 tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
764 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
765 wget "${url}" -O "${dest}/$(basename ${url})"
769 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
770 if [ "${webfile}" = "FTPFS" ]
772 FUSE_MOUNT="curlftpfs"
773 url="$(dirname ${url})"
778 $FUSE_MOUNT "${url}" "${dest}"
780 [ ${?} -eq 0 ] && rc=0
781 [ "${extension}" = "tgz" ] && live_dest="ram"
782 if [ "${extension}" = "iso" ]
784 isoloop=$(setup_loop "${dest}/$(basename "${url}")" "loop" "/sys/block/loop*" "" '')
785 mount -t iso9660 "${isoloop}" "${mountpoint}"
792 log_begin_msg "Unrecognized archive extension for ${url}"
800 if [ -d "${alt_mountpoint}" ]
802 umount "${alt_mountpoint}"
803 rmdir "${alt_mountpoint}"
805 umount "${mountpoint}"
806 elif [ "${webfile}" != "FETCH" ] ; then
820 if [ -z "${NFSOPTS}" ]
825 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
827 # FIXME: This while loop is an ugly HACK round an nfs bug
829 while [ "$i" -lt 60 ]
831 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
843 if [ -x "/sbin/mount.cifs" ]
845 if [ -z "${NFSOPTS}" ]
847 CIFSOPTS="-ouser=root,password="
849 CIFSOPTS="${NFSOPTS}"
852 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
855 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
869 size=$(fs_size "${fromdev}" "" "used")
871 if [ -b "${fromdev}" ]
874 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
876 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
877 freespace=$(df -k | awk '/'${todev}'/{print $4}')
879 freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
882 tomount="/mnt/tmpsnap"
884 if [ ! -d "${tomount}" ]
886 mkdir -p "${tomount}"
889 fstype=$(get_fstype "${fromdev}")
891 if [ -n "${fstype}" ]
894 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
895 cp -a "${tomount}"/* ${todir}
898 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
903 if echo ${fromdev} | grep -qs loop
905 losetup -d "${fromdev}"
912 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
918 # Look for ${snap_label}.* in block devices
921 if [ "${PERSISTENT}" != "nofiles" ]
923 # search for image files
924 snapdata=$(find_files "${PERSISTENT_PATH}${snap_label}.squashfs ${PERSISTENT_PATH}${snap_label}.cpio.gz ${PERSISTENT_PATH}${snap_label}.ext2 ${PERSISTENT_PATH}${snap_label}.ext3 ${PERSISTENT_PATH}${snap_label}.ext4 ${PERSISTENT_PATH}${snap_label}.jffs2")
927 if [ -z "${snapdata}" ]
929 snapdata=$(find_cow_device "${snap_label}")
936 # copy the contents of previously found snapshot to ${snap_mount}
937 # and remember the device and filename for resync on exit in live-boot.init
943 if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
945 log_success_msg "found snapshot: ${snapdata}"
946 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
947 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
948 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
951 if ! try_mount "${snapdev}" "${snapback}" "ro"
956 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
958 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
959 dev=$(get_backing_device "${snapback}/${snapfile}")
961 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
966 # Unfortunately klibc's cpio is incompatible with the
967 # rest of the world; everything else requires -u -d,
968 # while klibc doesn't implement them. Try to detect
969 # whether it's in use.
970 cpiopath="$(which cpio)" || true
971 if [ "$cpiopath" ] && grep -aq /lib/klibc "$cpiopath"
975 cpioargs='--unconditional --make-directories'
978 if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null)
980 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | cpio $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse\""
984 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
986 if [ "${RES}" != "0" ]
988 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
991 elif [ -b "${snapdata}" ]
993 # Try to find if it could be a snapshot partition
995 log_success_msg "found snapshot ${snap_type} device on ${dev}"
996 if echo "${dev}" | grep -qs loop
998 # strange things happens, user confused?
999 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
1000 snapfile=$(basename ${snaploop})
1001 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
1006 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1008 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1011 if [ -n "${snapfile}" ]
1013 # it was a loop device, user confused
1018 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1022 echo "export ${snap_type}SNAP="/cow${snap_mount#$rootmnt}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1028 image_directory="${1}"
1030 addimage_directory="${3}"
1032 case ${UNIONTYPE} in
1034 modprobe -q -b ${UNIONTYPE}
1036 if ! cut -f2 /proc/filesystems | grep -q "^${UNIONTYPE}\$" && [ -x /bin/unionfs-fuse ]
1038 echo "${UNIONTYPE} not available, falling back to unionfs-fuse."
1039 echo "This might be really slow."
1041 UNIONTYPE="unionfs-fuse"
1046 if [ "${UNIONTYPE}" = unionfs-fuse ]
1051 # run-init can't deal with images in a subdir, but we're going to
1052 # move all of these away before it runs anyway. No, we're not,
1053 # put them in / since move-mounting them into / breaks mono and
1058 # Let's just mount the read-only file systems first
1062 if [ "${UNIONTYPE}" = "aufs" ]
1065 noxino_opt="noxino,"
1066 elif [ "${UNIONTYPE}" = "unionfs-fuse" ]
1073 if [ -z "${PLAIN_ROOT}" ]
1075 # Read image names from ${MODULE}.module if it exists
1076 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1078 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1080 image_string="${image_string} ${image_directory}/${IMAGE}"
1082 elif [ -e "${image_directory}/${MODULE}.module" ]
1084 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1086 image_string="${image_string} ${image_directory}/${IMAGE}"
1089 # ${MODULE}.module does not exist, create a list of images
1090 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1092 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1094 if [ -e "${IMAGE}" ]
1096 image_string="${image_string} ${IMAGE}"
1101 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1103 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1105 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1107 if [ -e "${IMAGE}" ]
1109 image_string="${image_string} ${IMAGE}"
1116 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1119 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1123 for image in ${image_string}
1125 imagename=$(basename "${image}")
1127 export image devname
1128 maybe_break live-realpremount
1129 log_begin_msg "Running /scripts/live-realpremount"
1130 run_scripts /scripts/live-realpremount
1133 if [ -d "${image}" ]
1135 # it is a plain directory: do nothing
1136 rofsstring="${image}=${roopt}:${rofsstring}"
1137 rofslist="${image} ${rofslist}"
1138 elif [ -f "${image}" ]
1140 if losetup --help 2>&1 | grep -q -- "-r\b"
1142 backdev=$(get_backing_device "${image}" "-r")
1144 backdev=$(get_backing_device "${image}")
1146 fstype=$(get_fstype "${backdev}")
1148 if [ "${fstype}" = "unknown" ]
1150 panic "Unknown file system type on ${backdev} (${image})"
1153 if [ -z "${fstype}" ]
1155 fstype="${imagename##*.}"
1156 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1159 mkdir -p "${croot}/${imagename}"
1160 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1161 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}"
1166 # we have a plain root system
1167 mkdir -p "${croot}/filesystem"
1168 log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
1169 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}"
1171 mount -o bind ${croot}/filesystem $mountpoint
1175 rofsstring=${rofsstring%:}
1179 # Looking for "${root_persistence}" device or file
1180 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1182 if [ -z "${QUICKUSBMODULES}" ]
1185 num_block=$(ls -l /sys/block | wc -l)
1186 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1188 modprobe -q -b ${module}
1194 # For some reason, udevsettle does not block in this scenario,
1195 # so we sleep for a little while.
1197 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1198 for timeout in 5 4 3 2 1
1202 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1209 # search for label and files (this could be hugely optimized)
1210 cowprobe=$(find_cow_device "${root_persistence}")
1211 if [ -b "${cowprobe}" ]
1213 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1214 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1215 # snapshots to be sure to really store some e.g key config files,
1216 # but not on the same media
1217 blacklistdev="${cowprobe}"
1218 PERSISTENCE_IS_ON="1"
1219 export PERSISTENCE_IS_ON
1221 # homecow just mount something on /home, this should be generalized some way
1222 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1223 if [ -b "${homecow}" ]
1225 PERSISTENCE_IS_ON="1"
1226 export PERSISTENCE_IS_ON
1228 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1229 # This second type should be removed when snapshot will get smarter,
1230 # hence when "/etc/live-snapshot*list" will be supported also by
1231 # ext2|ext3|ext4|jffs2 snapshot types.
1232 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1234 if [ -b "${cowprobe}" ]
1236 cowdevice=${cowprobe}
1237 cow_fstype=$(get_fstype "${cowprobe}")
1238 cow_mountopt="rw,noatime"
1240 if [ "${FORCEPERSISTENTFSCK}" = "Yes" ]
1242 fsck -y ${cowdevice}
1245 log_warning_msg "Unable to find the persistent medium"
1248 cow_mountopt="rw,noatime,mode=755"
1250 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1252 # check if there are any nfs options
1253 if echo ${NFS_COW}|grep -q ','
1255 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1256 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1258 nfs_cow_opts="-o nolock"
1264 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1267 panic "unable to determine mac address"
1272 cow_mountopt="rw,noatime,mode=755"
1275 if [ "${cow_fstype}" = "nfs" ]
1278 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1279 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1280 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1282 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1283 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1286 rofscount=$(echo ${rofslist} |wc -w)
1288 if [ -n "${EXPOSED_ROOT}" ]
1290 if [ ${rofscount} -ne 1 ]
1292 panic "only one RO file system supported with exposedroot: ${rofslist}"
1294 exposedrootfs=${rofslist%% }
1296 mount --bind ${exposedrootfs} ${rootmnt} || \
1297 panic "bind mount of ${exposedrootfs} failed"
1299 if [ -z "${SKIP_UNION_MOUNTS}" ]
1301 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1306 for dir in ${cow_dirs}; do
1309 case "${UNIONTYPE}" in
1311 (ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:${exposedrootfs}${dir} "${rootmnt}${dir}" || panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option cow,noinitgroups,default_permissions,allow_other,use_ino,suid=/cow=RW:${exposedrootfs}${dir}")
1312 mkdir -p /dev/.initramfs/varrun
1313 pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
1317 mount -t ${UNIONTYPE} -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro ${UNIONTYPE} "${rootmnt}${dir}" || panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1322 case "${UNIONTYPE}" in
1324 (ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:${rofsstring} "${rootmnt}" || panic "mount ${UNIONTYPE} on ${rootmnt} failed with option cow,noinitgroups,default_permissions,allow_other,use_ino,suid=/cow:RW:${rofsstring}")
1325 mkdir -p /dev/.initramfs/varrun
1326 pidof unionfs-fuse >> /dev/.initramfs/varrun/sendsigs.omit || true
1330 mount -t ${UNIONTYPE} -o noatime,${noxino_opt}dirs=/cow=rw:${rofsstring} ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on ${rootmnt} failed with option noatime,${noxino_opt}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 case "${UNIONTYPE}" in
1377 mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1381 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1389 # shows cow fs on /cow for use by live-snapshot
1390 mkdir -p "${rootmnt}/live/cow"
1391 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"
1398 skip_uuid_check="${3}"
1400 # support for fromiso=.../isofrom=....
1401 if [ -n "$FROMISO" ]
1403 ISO_DEVICE=$(dirname $FROMISO)
1404 if ! [ -b $ISO_DEVICE ]
1406 # to support unusual device names like /dev/cciss/c0d0p1
1407 # as well we have to identify the block device name, let's
1408 # do that for up to 15 levels
1410 while [ -n "$ISO_DEVICE" ] && [ "$i" -gt 0 ]
1412 ISO_DEVICE=$(dirname ${ISO_DEVICE})
1413 [ -b "$ISO_DEVICE" ] && break
1418 if [ "$ISO_DEVICE" = "/" ]
1420 echo "Warning: device for bootoption isofrom= ($FROMISO) not found.">>/live.log
1423 mount "$ISO_DEVICE" /isofrom
1424 ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
1425 loopdevname=$(setup_loop "/isofrom/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
1426 devname="${loopdevname}"
1430 if [ -z "${devname}" ]
1432 devname=$(sys2dev "${sysdev}")
1435 if [ -d "${devname}" ]
1437 mount -o bind "${devname}" $mountpoint || continue
1439 if is_live_path $mountpoint
1447 [ -e "$devname" ] || continue
1449 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1451 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1452 devname="${loopdevname}"
1455 fstype=$(get_fstype "${devname}")
1457 if is_supported_fs ${fstype}
1459 devuid=$(blkid -o value -s UUID "$devname")
1460 [ -n "$devuid" ] && grep -qs "\<$devuid\>" $tried && continue
1461 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1462 [ -n "$devuid" ] && echo "$devuid" >> $tried
1464 if is_live_path ${mountpoint} && \
1465 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1470 umount ${mountpoint}
1474 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1476 losetup -d "${loopdevname}"
1486 # don't start autodetection before timeout has expired
1487 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1489 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1495 # first look at the one specified in the command line
1496 case "${LIVE_MEDIA}" in
1498 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1500 if [ "$(cat ${sysblock}/removable)" = "1" ]
1502 if readlink ${sysblock} | grep -q usb ||
1503 readlink ${sysblock}/device | grep -q usb # linux < 2.6.29
1505 for dev in $(subdevices "${sysblock}")
1507 if check_dev "${dev}"
1519 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1521 if [ "$(cat ${sysblock}/removable)" = "1" ]
1523 for dev in $(subdevices "${sysblock}")
1525 if check_dev "${dev}"
1536 if [ ! -z "${LIVE_MEDIA}" ]
1538 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1546 # or do the scan of block devices
1547 # prefer removable devices over non-removable devices, so scan them first
1548 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | egrep -v "/(loop|ram|dm-|fd)")
1550 if [ "$(cat ${sysblock}/removable)" = "1" ]
1552 removable_devices_to_scan="$removable_devices_to_scan $sysblock"
1554 nonremovable_devices_to_scan="$nonremovable_devices_to_scan $sysblock"
1557 devices_to_scan="$removable_devices_to_scan $nonremovable_devices_to_scan"
1559 for sysblock in $devices_to_scan
1561 devname=$(sys2dev "${sysblock}")
1562 [ -e "$devname" ] || continue
1563 fstype=$(get_fstype "${devname}")
1565 if /lib/udev/cdrom_id ${devname} > /dev/null
1567 if check_dev "null" "${devname}"
1571 elif is_nice_device "${sysblock}"
1573 for dev in $(subdevices "${sysblock}")
1575 if check_dev "${dev}"
1580 elif [ "${fstype}" = "squashfs" -o \
1581 "${fstype}" = "ext2" -o \
1582 "${fstype}" = "ext3" -o \
1583 "${fstype}" = "ext4" -o \
1584 "${fstype}" = "jffs2" ]
1586 # This is an ugly hack situation, the block device has
1587 # an image directly on it. It's hopefully
1588 # live-boot, so take it and run with it.
1589 ln -s "${devname}" "${devname}.${fstype}"
1590 echo "${devname}.${fstype}"
1598 set_usplash_timeout ()
1600 if [ -x /sbin/usplash_write ]
1602 /sbin/usplash_write "TIMEOUT 120"
1603 else if [ -x /sbin/splashy_update ] ; then
1604 /sbin/splashy_update "TIMEOUT 120"
1610 media_mountpoint="${1}"
1612 log_begin_msg "Checking media integrity"
1614 cd ${media_mountpoint}
1615 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1620 if [ "${RC}" -eq 0 ]
1622 log_success_msg "Everything ok, will reboot in 10 seconds."
1625 umount ${media_mountpoint}
1627 echo u > /proc/sysrq-trigger
1628 echo b > /proc/sysrq-trigger
1630 panic "Not ok, a media defect is likely, switch to VT8 for details."
1634 start_usplash_pulse ()
1636 if [ -x /sbin/usplash_write ]
1638 /sbin/usplash_write "PULSELOGO"
1644 if [ -x /scripts/local-top/cryptroot ]; then
1645 /scripts/local-top/cryptroot
1652 tail -f live.log >&7 &
1655 # Ensure 'panic' function is overridden
1656 . /scripts/live-functions
1663 maybe_break live-premount
1664 log_begin_msg "Running /scripts/live-premount"
1665 run_scripts /scripts/live-premount
1668 # Needed here too because some things (*cough* udev *cough*)
1669 # changes the timeout
1673 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1677 livefs_root="${mountpoint}"
1679 panic "Unable to find a live file system on the network"
1682 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1684 # Do a local boot from hd
1687 # Scan local devices for the image
1689 while [ "$i" -lt 60 ]
1691 livefs_root=$(find_livefs ${i})
1693 if [ -n "${livefs_root}" ]
1704 if [ -z "${livefs_root}" ]
1706 panic "Unable to find a medium containing a live file system"
1709 if [ "${INTEGRITY_CHECK}" ]
1711 integrity_check "${livefs_root}"
1717 elif [ "${TODISK}" ]
1719 live_dest="${TODISK}"
1722 if [ "${live_dest}" ]
1724 log_begin_msg "Copying live media to ${live_dest}"
1725 copy_live_to "${livefs_root}" "${live_dest}"
1729 # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
1730 # because the mountpoint is left behind in /proc/mounts, so let's get
1731 # rid of it when running from RAM
1732 if [ -n "$FROMISO" ] && [ "${TORAM}" ]
1734 losetup -d /dev/loop0
1735 grep -q /isofrom /proc/mounts && umount /isofrom
1738 if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
1740 setup_unionfs "${livefs_root}" "${rootmnt}"
1743 mac="$(echo ${mac} | sed 's/-//g')"
1744 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1749 # unionfs-fuse needs /dev to be bind-mounted for the duration of
1750 # live-bottom; udev's init script will take care of things after that
1751 if [ "${UNIONTYPE}" = unionfs-fuse ]
1753 mount -n -o bind /dev "${rootmnt}/dev"
1756 # Move to the new root filesystem so that programs there can get at it.
1757 if [ ! -d /root/live/image ]
1759 mkdir -p /root/live/image
1760 mount --move /live/image /root/live/image
1763 maybe_break live-bottom
1764 log_begin_msg "Running /scripts/live-bottom\n"
1766 run_scripts /scripts/live-bottom
1769 if [ "${UNIONFS}" = unionfs-fuse ]
1771 umount "${rootmnt}/dev"
1777 [ -w "${rootmnt}/var/log/" ] && cp live.log "${rootmnt}/var/log/" 2>/dev/null