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 USERNAME="${ARGUMENT#username=}"
103 export USERNAME LIVECONF
107 USERFULLNAME="${ARGUMENT#userfullname=}"
109 export USERFULLNAME LIVECONF
118 INTEGRITY_CHECK="Yes"
119 export INTEGRITY_CHECK
123 STATICIP="${ARGUMENT#ip=}"
125 if [ -z "${STATICIP}" ]
133 keyb=*|kbd-chooser/method=*)
138 klayout=*|console-setup/layoutcode=*)
139 KLAYOUT="${ARGUMENT#*=}"
143 kvariant=*|console-setup/variantcode=*)
144 KVARIANT="${ARGUMENT#*=}"
148 kmodel=*|console-setup/modelcode=*)
149 KMODEL="${ARGUMENT#*=}"
154 KOPTIONS="${ARGUMENT#koptions=}"
163 live-media=*|bootfrom=*)
164 LIVE_MEDIA="${ARGUMENT#*=}"
168 live-media-encryption=*|encryption=*)
169 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
170 export LIVE_MEDIA_ENCRYPTION
174 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
175 export LIVE_MEDIA_OFFSET
179 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
180 export LIVE_MEDIA_PATH
183 live-media-timeout=*)
184 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
185 export LIVE_MEDIA_TIMEOUT
188 language=*|debian-installer/language=*)
189 language=${x#debian-installer/language=}
190 locale="$(lang2locale "$language")"
194 locale=*|debian-installer/locale=*)
195 LOCALE="${ARGUMENT#*=}"
200 MODULE="${ARGUMENT#module=}"
205 NETBOOT="${ARGUMENT#netboot=}"
210 NFSOPTS="${ARGUMENT#nfsopts=}"
215 NFS_COW="${ARGUMENT#nfscow=}"
220 NOACCESSIBILITY="Yes"
221 export NOACCESSIBILITY
245 NOCONSOLEKEYBOARD="Yes"
246 export NOCONSOLEKEYBOARD
270 NOKPERSONALIZER="Yes"
271 export NOKPERSONALIZER
275 NOLANGUAGESELECTOR="Yes"
276 export NOLANGUAGESELECTOR
290 NOPOWERMANAGEMENT="Yes"
291 export NOPOWERMANAGEMENT
295 NOPROGRAMCRASHES="Yes"
296 export NOPROGRAMCRASHES
315 NOUPDATENOTIFIER="Yes"
316 export NOUPDATENOTIFIER
331 export NOXSCREENSAVER
340 PERSISTENT="${ARGUMENT#persistent=}"
341 if [ -z "${PERSISTENT}" ]
349 PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
350 export PERSISTENT_PATH
353 persistent-subtext=*)
354 root_persistence="${root_persistence}-${ARGUMENT#persistent-subtext=}"
355 home_persistence="${home_persistence}-${ARGUMENT#persistent-subtext=}"
356 root_snapshot_label="${root_snapshot_label}-${ARGUMENT#persistent-subtext=}"
357 home_snapshot_label="${home_snapshot_label}-${ARGUMENT#persistent-subtext=}"
365 preseed/file=*|file=*)
366 LOCATION="${ARGUMENT#*=}"
376 location="${ARGUMENT#url=}"
378 mount -o bind /sys /root/sys
379 mount -o bind /proc /root/proc
380 mount -o bind /dev /root/dev
382 mkdir -p /root/var/run/network
383 chroot /root dhclient eth0
384 chroot /root wget -P /tmp "${location}"
385 chroot /root ifconfig eth0 down
391 LOCATION="/tmp/$(basename "${location}")"
395 question="${ARGUMENT%%=*}"
396 value="${ARGUMENT#*=}"
397 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
417 TIMEZONE="${ARGUMENT#timezone=}"
427 TODISK="${ARGUMENT#todisk=}"
438 MODULETORAM="${ARGUMENT#toram=}"
439 export TORAM MODULETORAM
453 SKIP_UNION_MOUNTS="Yes"
454 export SKIP_UNION_MOUNTS
458 ROOT="${ARGUMENT#root=}"
463 UNIONTYPE="${ARGUMENT#union=}"
468 UTC="${ARGUMENT#utc=}"
478 XDRIVER="${ARGUMENT#xdriver=}"
483 XVIDEOMODE="${ARGUMENT#xvideomode=}"
489 # sort of compatibility with netboot.h from linux docs
490 if [ -z "${NETBOOT}" ]
492 if [ "${ROOT}" = "/dev/nfs" ]
496 elif [ "${ROOT}" = "/dev/cifs" ]
503 if [ -z "${MODULE}" ]
509 if [ -z "${UNIONTYPE}" ]
520 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
522 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
524 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
536 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
542 uuid="$(cat /conf/uuid.conf)"
544 for try_uuid_file in "${path}/.disk/live-uuid"*
546 [ -e "${try_uuid_file}" ] || continue
548 try_uuid="$(cat "${try_uuid_file}")"
550 if [ "${uuid}" = "${try_uuid}" ]
559 get_backing_device ()
562 *.squashfs|*.ext2|*.ext3|*.ext4|*.jffs2)
563 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
571 panic "Unrecognized live filesystem: ${1}"
576 match_files_in_dir ()
578 # Does any files match pattern ${1} ?
581 if [ "$(echo ${pattern})" != "${pattern}" ]
589 mount_images_in_directory ()
596 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
597 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
598 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
599 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
600 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
601 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
603 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
604 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
606 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
612 sysfs_path="${1#/sys}"
614 if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-)"
617 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
629 copyto="${copyfrom}_swap"
631 if [ -z "${MODULETORAM}" ]
633 size=$(fs_size "" ${copyfrom}/${LIVE_MEDIA_PATH} "used")
635 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
637 if [ -f "${MODULETORAMFILE}" ]
639 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
641 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
646 if [ "${copytodev}" = "ram" ]
649 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
650 mount_options="-o size=${size}k"
655 # it should be a writable block device
656 if [ -b "${copytodev}" ]
660 fstype=$(get_fstype "${dev}")
661 freespace=$(fs_size "${dev}")
663 log_warning_msg "${copytodev} is not a block device."
668 if [ "${freespace}" -lt "${size}" ]
670 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
674 # begin copying (or uncompressing)
676 echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
677 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
679 if [ "${extension}" = "tgz" ]
682 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
683 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
684 mount -r -o move "${copyto}" "${rootmnt}"
687 if [ -n "${MODULETORAMFILE}" ]
689 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
691 mkdir -p ${copyto}/${LIVE_MEDIA_PATH}
692 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH} # "cp -a" from busybox also copies hidden files
696 mount -r -o move ${copyto} ${copyfrom}
707 modprobe -q af_packet # For DHCP
709 if [ -x /sbin/udevadm ]
720 ipconfig ${DEVICE} | tee /netboot.config
722 # source relevant ipconfig output
723 OLDHOSTNAME=${HOSTNAME}
724 . /tmp/net-${DEVICE}.conf
725 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
728 # Check if we have a network device at all
729 if ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
730 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
731 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
732 ! ls /sys/class/net/ra0 > /dev/null 2>&1
734 panic "No supported network device found, maybe a non-mainline driver is required."
737 if [ "${NFSROOT}" = "auto" ]
739 NFSROOT=${ROOTSERVER}:${ROOTPATH}
742 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
748 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
750 NFSROOT=${ROOTSERVER}:${NFSROOT}
753 log_begin_msg "Trying netboot from ${NFSROOT}"
755 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
772 dest="${mountpoint}/${LIVE_MEDIA_PATH}"
773 mount -t ramfs ram "${mountpoint}"
776 for webfile in HTTPFS FTPFS FETCH
778 url="$(eval echo \"\$\{${webfile}\}\")"
779 extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
783 case "${extension}" in
785 if [ "${webfile}" = "FETCH" ]
789 ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
790 rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
791 lfile="$(basename $url)"
792 log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
793 tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
797 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
798 wget "${url}" -O "${dest}/$(basename ${url})"
802 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
803 if [ "${webfile}" = "FTPFS" ]
805 FUSE_MOUNT="curlftpfs"
806 url="$(dirname ${url})"
811 $FUSE_MOUNT "${url}" "${dest}"
813 [ ${?} -eq 0 ] && rc=0
814 [ "${extension}" = "tgz" ] && live_dest="ram"
819 log_begin_msg "Unrecognized archive extension for ${url}"
827 umount "${mountpoint}"
839 if [ -z "${NFSOPTS}" ]
844 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
846 # FIXME: This while loop is an ugly HACK round an nfs bug
848 while [ "$i" -lt 60 ]
850 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
862 if [ -x "/sbin/mount.cifs" ]
864 if [ -z "${NFSOPTS}" ]
866 CIFSOPTS="-ouser=root,password="
868 CIFSOPTS="${NFSOPTS}"
871 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
874 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
888 size=$(fs_size "${fromdev}" "" "used")
890 if [ -b "${fromdev}" ]
893 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
895 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
896 freespace=$(df -k | awk '/'${todev}'/{print $4}')
898 freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
901 tomount="/mnt/tmpsnap"
903 if [ ! -d "${tomount}" ]
905 mkdir -p "${tomount}"
908 fstype=$(get_fstype "${fromdev}")
910 if [ -n "${fstype}" ]
913 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
914 cp -a "${tomount}"/* ${todir}
917 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
922 if echo ${fromdev} | grep -qs loop
924 losetup -d "${fromdev}"
931 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
937 # Look for ${snap_label}.* in block devices
940 if [ "${PERSISTENT}" != "nofiles" ]
942 # search for image files
943 snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snap_label}.ext4 ${snap_label}.jffs2")
946 if [ -z "${snapdata}" ]
948 snapdata=$(find_cow_device "${snap_label}")
955 # copy the contents of previously found snapshot to ${snap_mount}
956 # and remember the device and filename for resync on exit in live-initramfs.init
962 if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
964 log_success_msg "found snapshot: ${snapdata}"
965 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
966 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
967 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
970 if ! try_mount "${snapdev}" "${snapback}" "ro"
975 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
977 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
978 dev=$(get_backing_device "${snapback}/${snapfile}")
980 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
985 zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
987 if [ "${RES}" != "0" ]
989 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories\""
994 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
996 if [ "${RES}" != "0" ]
998 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
1001 elif [ -b "${snapdata}" ]
1003 # Try to find if it could be a snapshot partition
1005 log_success_msg "found snapshot ${snap_type} device on ${dev}"
1006 if echo "${dev}" | grep -qs loop
1008 # strange things happens, user confused?
1009 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
1010 snapfile=$(basename ${snaploop})
1011 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
1016 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1018 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1021 if [ -n "${snapfile}" ]
1023 # it was a loop device, user confused
1028 log_warning_msg "Impossible to include the ${snap_type} Snapshot"
1032 echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1038 image_directory="${1}"
1040 addimage_directory="${3}"
1041 modprobe -q -b ${UNIONTYPE}
1043 # run-init can't deal with images in a subdir, but we're going to
1044 # move all of these away before it runs anyway. No, we're not,
1045 # put them in / since move-mounting them into / breaks mono and
1050 # Let's just mount the read-only file systems first
1053 minor_kernel_version=$(uname -r|cut -c 5-|sed 's/[^0-9].*//')
1055 if [ "${NETBOOT}" = "nfs" ] && [ "${minor_kernel_version}" -lt 22 ]
1057 # go aroung a bug in nfs-unionfs locking for unionfs <= 1.4
1059 elif [ "${UNIONTYPE}" = "aufs" ]
1066 if [ -z "${PLAIN_ROOT}" ]
1068 # Read image names from ${MODULE}.module if it exists
1069 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1071 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1073 image_string="${image_string} ${image_directory}/${IMAGE}"
1075 elif [ -e "${image_directory}/${MODULE}.module" ]
1077 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1079 image_string="${image_string} ${image_directory}/${IMAGE}"
1082 # ${MODULE}.module does not exist, create a list of images
1083 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1085 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1087 if [ -e "${IMAGE}" ]
1089 image_string="${image_string} ${IMAGE}"
1094 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1096 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1098 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1100 if [ -e "${IMAGE}" ]
1102 image_string="${image_string} ${IMAGE}"
1109 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1112 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1116 for image in ${image_string}
1118 imagename=$(basename "${image}")
1120 export image devname
1121 maybe_break live-realpremount
1122 log_begin_msg "Running /scripts/live-realpremount"
1123 run_scripts /scripts/live-realpremount
1126 if [ -d "${image}" ]
1128 # it is a plain directory: do nothing
1129 rofsstring="${image}=${roopt}:${rofsstring}"
1130 rofslist="${image} ${rofslist}"
1131 elif [ -f "${image}" ]
1133 if losetup --help 2>&1 | grep -q -- "-r\b"
1135 backdev=$(get_backing_device "${image}" "-r")
1137 backdev=$(get_backing_device "${image}")
1139 fstype=$(get_fstype "${backdev}")
1141 if [ "${fstype}" = "unknown" ]
1143 panic "Unknown file system type on ${backdev} (${image})"
1146 if [ -z "${fstype}" ]
1148 fstype="${imagename##*.}"
1149 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1152 mkdir -p "${croot}/${imagename}"
1153 log_begin_msg "Mounting \"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1154 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}"
1159 # we have a plain root system
1160 mkdir -p "${croot}/filesystem"
1161 log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
1162 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}"
1164 mount -o bind ${croot}/filesystem $mountpoint
1168 rofsstring=${rofsstring%:}
1172 # Looking for "${root_persistence}" device or file
1173 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1176 num_block=$(ls -l /sys/block | wc -l)
1177 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1179 modprobe -q -b ${module}
1182 if [ -x /sbin/udevadm ]
1193 # For some reason, udevsettle does not block in this scenario,
1194 # so we sleep for a little while.
1196 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1197 for timeout in 5 4 3 2 1
1201 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1207 # search for label and files (this could be hugely optimized)
1208 cowprobe=$(find_cow_device "${root_persistence}")
1209 if [ -b "${cowprobe}" ]
1211 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1212 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1213 # snapshots to be sure to really store some e.g key config files,
1214 # but not on the same media
1215 blacklistdev="${cowprobe}"
1216 PERSISTENCE_IS_ON="1"
1217 export PERSISTENCE_IS_ON
1219 # homecow just mount something on /home, this should be generalized some way
1220 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1221 if [ -b "${homecow}" ]
1223 PERSISTENCE_IS_ON="1"
1224 export PERSISTENCE_IS_ON
1226 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1227 # This second type should be removed when snapshot will get smarter,
1228 # hence when "/etc/live-snapshot*list" will be supported also by
1229 # ext2|ext3|ext4|jffs2 snapshot types.
1230 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1232 if [ -b "${cowprobe}" ]
1234 cowdevice=${cowprobe}
1235 cow_fstype=$(get_fstype "${cowprobe}")
1236 cow_mountopt="rw,noatime"
1238 if [ "${FORCEPERSISTENTFSCK}" = "Yes" ]
1240 fsck -y ${cowdevice}
1243 log_warning_msg "Unable to find the persistent medium"
1246 cow_mountopt="rw,noatime,mode=755"
1248 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1250 # check if there are any nfs options
1251 if echo ${NFS_COW}|grep -q ','
1253 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1254 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1256 nfs_cow_opts="-o nolock"
1262 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1265 panic "unable to determine mac address"
1270 cow_mountopt="rw,noatime,mode=755"
1273 if [ "${cow_fstype}" = "nfs" ]
1276 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1277 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1278 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1280 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1281 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1284 rofscount=$(echo ${rofslist} |wc -w)
1286 if [ -n "${EXPOSED_ROOT}" ]
1288 if [ ${rofscount} -ne 1 ]
1290 panic "only one RO file system supported with exposedroot: ${rofslist}"
1292 exposedrootfs=${rofslist%% }
1294 mount --bind ${exposedrootfs} ${rootmnt} || \
1295 panic "bind mount of ${exposedrootfs} failed"
1297 if [ -z "${SKIP_UNION_MOUNTS}" ]
1299 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1304 for dir in ${cow_dirs}; do
1306 mount -t ${UNIONTYPE} \
1307 -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro \
1308 ${UNIONTYPE} "${rootmnt}${dir}" || \
1309 panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option \
1310 rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro"
1313 mount -t ${UNIONTYPE} -o noatime,dirs=/cow=rw:${rofsstring} \
1314 ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on \
1315 ${rootmnt} failed with option noatime,dirs=/cow=rw:${rofsstring}"
1318 # Correct the permissions of /:
1319 chmod 0755 "${rootmnt}"
1321 # tmpfs file systems
1323 mkdir -p "${rootmnt}/live"
1324 mount -t tmpfs tmpfs ${rootmnt}/live
1326 # Adding other custom mounts
1327 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1329 # directly mount /home
1330 # FIXME: add a custom mounts configurable system
1332 if [ -b "${homecow}" ]
1334 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1335 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1337 log_warning_msg "Unable to find the persistent home medium"
1340 # Look for other snapshots to copy in
1341 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1342 # This second type should be removed when snapshot grow smarter
1343 try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
1346 if [ -n "${SHOWMOUNTS}" ]
1348 for d in ${rofslist}
1350 mkdir -p "${rootmnt}/live/${d##*/}"
1354 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1358 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1364 # shows cow fs on /cow for use by live-snapshot
1365 mkdir -p "${rootmnt}/live/cow"
1366 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"
1373 skip_uuid_check="${3}"
1375 if [ -z "${devname}" ]
1377 devname=$(sys2dev "${sysdev}")
1380 if [ -d "${devname}" ]
1382 mount -o bind "${devname}" $mountpoint || continue
1384 if is_live_path $mountpoint
1393 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1395 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1396 devname="${loopdevname}"
1399 fstype=$(get_fstype "${devname}")
1401 if is_supported_fs ${fstype}
1403 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1405 if is_live_path ${mountpoint} && \
1406 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1411 umount ${mountpoint}
1415 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1417 losetup -d "${loopdevname}"
1427 # don't start autodetection before timeout has expired
1428 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1430 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1436 # first look at the one specified in the command line
1437 case "${LIVE_MEDIA}" in
1439 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1441 if [ "$(cat ${sysblock}/removable)" = "1" ]
1443 if readlink ${sysblock} | grep -q usb ||
1444 readlink ${sysblock}/device | grep -q usb # linux < 2.6.29
1446 for dev in $(subdevices "${sysblock}")
1448 if check_dev "${dev}"
1459 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1461 if [ "$(cat ${sysblock}/removable)" = "1" ]
1463 for dev in $(subdevices "${sysblock}")
1465 if check_dev "${dev}"
1475 if [ ! -z "${LIVE_MEDIA}" ]
1477 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1485 # or do the scan of block devices
1486 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
1488 devname=$(sys2dev "${sysblock}")
1489 fstype=$(get_fstype "${devname}")
1491 if /lib/udev/cdrom_id ${devname} > /dev/null
1493 if check_dev "null" "${devname}"
1497 elif is_nice_device "${sysblock}"
1499 for dev in $(subdevices "${sysblock}")
1501 if check_dev "${dev}"
1506 elif [ "${fstype}" = "squashfs" -o \
1507 "${fstype}" = "ext2" -o \
1508 "${fstype}" = "ext3" -o \
1509 "${fstype}" = "ext4" -o \
1510 "${fstype}" = "jffs2" ]
1512 # This is an ugly hack situation, the block device has
1513 # an image directly on it. It's hopefully
1514 # live-initramfs, so take it and run with it.
1515 ln -s "${devname}" "${devname}.${fstype}"
1516 echo "${devname}.${fstype}"
1524 set_usplash_timeout ()
1526 if [ -x /sbin/usplash_write ]
1528 /sbin/usplash_write "TIMEOUT 120"
1529 else if [ -x /sbin/splashy_update ] ; then
1530 /sbin/splashy_update "TIMEOUT 120"
1536 media_mountpoint="${1}"
1538 log_begin_msg "Checking media integrity"
1540 cd ${media_mountpoint}
1541 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1546 if [ "${RC}" -eq 0 ]
1548 log_success_msg "Everything ok, will reboot in 10 seconds."
1551 umount ${media_mountpoint}
1553 echo u > /proc/sysrq-trigger
1554 echo b > /proc/sysrq-trigger
1556 panic "Not ok, a media defect is likely, switch to VT8 for details."
1562 if [ -x /scripts/local-top/cryptroot ]; then
1563 /scripts/local-top/cryptroot
1570 tail -f live.log >&7 &
1573 # Ensure 'panic' function is overridden
1574 . /scripts/live-functions
1580 maybe_break live-premount
1581 log_begin_msg "Running /scripts/live-premount"
1582 run_scripts /scripts/live-premount
1585 # Needed here too because some things (*cough* udev *cough*)
1586 # changes the timeout
1590 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1594 livefs_root="${mountpoint}"
1596 panic "Unable to find a live file system on the network"
1599 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1601 # Do a local boot from hd
1604 # Scan local devices for the image
1606 while [ "$i" -lt 60 ]
1608 livefs_root=$(find_livefs ${i})
1610 if [ -n "${livefs_root}" ]
1621 if [ -z "${livefs_root}" ]
1623 panic "Unable to find a medium containing a live file system"
1626 if [ "${INTEGRITY_CHECK}" ]
1628 integrity_check "${livefs_root}"
1634 elif [ "${TODISK}" ]
1636 live_dest="${TODISK}"
1639 if [ "${live_dest}" ]
1641 log_begin_msg "Copying live media to ${live_dest}"
1642 copy_live_to "${livefs_root}" "${live_dest}"
1646 if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
1648 setup_unionfs "${livefs_root}" "${rootmnt}"
1651 mac="$(echo ${mac} | sed 's/-//g')"
1652 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1657 maybe_break live-bottom
1658 log_begin_msg "Running /scripts/live-bottom\n"
1660 run_scripts /scripts/live-bottom
1666 [ -w "${rootmnt}/var/log/" ] && cp live.log "${rootmnt}/var/log/" 2>/dev/null