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_overlay_label="full-ov"
15 custom_overlay_label="custom-ov"
16 root_snapshot_label="live-sn"
17 home_snapshot_label="home-sn"
18 persistence_list="live.persist"
21 USERFULLNAME="Live user"
24 mkdir -p "${mountpoint}"
27 # Create /etc/mtab for debug purpose and future syncs
38 . /scripts/live-helpers
40 if [ ! -f /live.vars ]
50 for ARGUMENT in $(cat /proc/cmdline)
59 export NOACCESSIBILITY NOFASTBOOT NOFSTAB NONETWORKING
63 ACCESS="${ARGUMENT#access=}"
68 DEFCONSOLE="${ARGUMENT#*=}"
84 # Force dhcp even while netbooting
85 # Use for debugging in case somebody works on fixing dhclient
95 DEVICE="${ARGUMENT#ethdevice=}"
97 export DEVICE ETHDEVICE
101 ETHDEV_TIMEOUT="${ARGUMENT#ethdevice-timeout=}"
102 export ETHDEV_TIMEOUT
106 FETCH="${ARGUMENT#fetch=}"
111 FORCEPERSISTENTFSCK="Yes"
112 export FORCEPERSISTENTFSCK
116 FTPFS="${ARGUMENT#ftpfs=}"
121 HTTPFS="${ARGUMENT#httpfs=}"
126 ISCSI="${ARGUMENT#iscsi=}"
127 #ip:port - separated by ;
128 ISCSI_PORTAL="${ISCSI%;*}"
129 if echo "${ISCSI_PORTAL}" | grep -q , ; then
130 ISCSI_SERVER="${ISCSI_PORTAL%,*}"
131 ISCSI_PORT="${ISCSI_PORTAL#*,}"
134 ISCSI_TARGET="${ISCSI#*;}"
135 export ISCSI ISCSI_PORTAL ISCSI_TARGET ISCSI_SERVER ISCSI_PORT
139 FROMISO="${ARGUMENT#*=}"
149 INTEGRITY_CHECK="Yes"
150 export INTEGRITY_CHECK
154 STATICIP="${ARGUMENT#ip=}"
156 if [ -z "${STATICIP}" ]
169 live-media=*|bootfrom=*)
170 LIVE_MEDIA="${ARGUMENT#*=}"
174 live-media-encryption=*|encryption=*)
175 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
176 export LIVE_MEDIA_ENCRYPTION
180 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
181 export LIVE_MEDIA_OFFSET
185 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
186 export LIVE_MEDIA_PATH
189 live-media-timeout=*)
190 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
191 export LIVE_MEDIA_TIMEOUT
195 MODULE="${ARGUMENT#module=}"
200 NETBOOT="${ARGUMENT#netboot=}"
205 NFSOPTS="${ARGUMENT#nfsopts=}"
210 NFS_COW="${ARGUMENT#nfscow=}"
215 NOACCESSIBILITY="Yes"
216 export NOACCESSIBILITY
235 ramdisk_size="${ARGUMENT#ramdisk-size=}"
248 persistent-encryption=*)
249 PERSISTENT_ENCRYPTION="${ARGUMENT#*=}"
250 export PERSISTENT_ENCRYPTION
254 PERSISTENT_MEDIA="${ARGUMENT#*=}"
255 export PERSISTENT_MEDIA
258 PERSISTENT_METHOD="${ARGUMENT#*=}"
259 export PERSISTENT_METHOD
263 PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
264 export PERSISTENT_PATH
266 persistent-read-only)
267 PERSISTENT_READONLY="Yes"
268 export PERSISTENT_READONLY
271 persistent-storage=*)
272 PERSISTENT_STORAGE="${ARGUMENT#persistent-storage=}"
273 export PERSISTENT_STORAGE
276 persistent-subtext=*)
277 root_overlay_label="${root_overlay_label}-${ARGUMENT#persistent-subtext=}"
278 custom_overlay_label="${custom_overlay_label}-${ARGUMENT#persistent-subtext=}"
279 root_snapshot_label="${root_snapshot_label}-${ARGUMENT#persistent-subtext=}"
280 home_snapshot_label="${home_snapshot_label}-${ARGUMENT#persistent-subtext=}"
294 NOPROMPT="${ARGUMENT#noprompt=}"
299 QUICKUSBMODULES="Yes"
300 export QUICKUSBMODULES
303 preseed/file=*|file=*)
304 LOCATIONS="${ARGUMENT#*=} ${LOCATIONS}"
314 question="${ARGUMENT%%=*}"
315 value="${ARGUMENT#*=}"
316 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
331 TODISK="${ARGUMENT#todisk=}"
342 MODULETORAM="${ARGUMENT#toram=}"
343 export TORAM MODULETORAM
357 SKIP_UNION_MOUNTS="Yes"
358 export SKIP_UNION_MOUNTS
362 ROOT="${ARGUMENT#root=}"
367 UNIONTYPE="${ARGUMENT#union=}"
373 # sort of compatibility with netboot.h from linux docs
374 if [ -z "${NETBOOT}" ]
376 if [ "${ROOT}" = "/dev/nfs" ]
380 elif [ "${ROOT}" = "/dev/cifs" ]
387 if [ -z "${MODULE}" ]
393 if [ -z "${UNIONTYPE}" ]
399 if [ -z "${PERSISTENT_ENCRYPTION}" ]
401 PERSISTENT_ENCRYPTION="none"
402 export PERSISTENT_ENCRYPTION
403 elif echo ${PERSISTENT_ENCRYPTION} | grep -qe "\<luks\>"
405 if ! modprobe dm-crypt
407 log_warning_msg "Unable to load module dm-crypt"
408 PERSISTENT_ENCRYPTION=$(echo ${PERSISTENT_ENCRYPTION} | sed -e 's/\<luks,\|,\?luks$//g')
409 export PERSISTENT_ENCRYPTION
412 if [ ! -x /lib/cryptsetup/askpass ] || [ ! -x /sbin/cryptsetup ]
414 log_warning_msg "cryptsetup in unavailable"
415 PERSISTENT_ENCRYPTION=$(echo ${PERSISTENT_ENCRYPTION} | sed -e 's/\<luks,\|,\?luks$//g')
416 export PERSISTENT_ENCRYPTION
420 if [ -n "${PERSISTENT}" ] && [ -z "${PERSISTENT_METHOD}" ]
422 PERSISTENT_METHOD="snapshot,overlay"
423 export PERSISTENT_METHOD
426 if [ -n "${PERSISTENT}" ] && [ -z "${PERSISTENT_STORAGE}" ]
428 PERSISTENT_STORAGE="filesystem,file"
429 export PERSISTENT_STORAGE
437 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
439 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
441 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
453 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
459 uuid="$(cat /conf/uuid.conf)"
461 for try_uuid_file in "${path}/.disk/live-uuid"*
463 [ -e "${try_uuid_file}" ] || continue
465 try_uuid="$(cat "${try_uuid_file}")"
467 if [ "${uuid}" = "${try_uuid}" ]
476 get_backing_device ()
479 *.squashfs|*.ext2|*.ext3|*.ext4|*.jffs2)
480 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
488 panic "Unrecognized live filesystem: ${1}"
493 match_files_in_dir ()
495 # Does any files match pattern ${1} ?
498 if [ "$(echo ${pattern})" != "${pattern}" ]
506 mount_images_in_directory ()
513 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
514 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
515 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
516 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
517 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
518 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
520 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
521 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
523 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
529 sysfs_path="${1#/sys}"
531 if [ -e /lib/udev/path_id ]
534 PATH_ID="/lib/udev/path_id"
536 # wheezy/sid (udev >= 174)
537 PATH_ID="/sbin/udevadm test-builtin path_id"
540 if ${PATH_ID} "${sysfs_path}" | egrep -q "ID_PATH=(usb|pci-[^-]*-(ide|sas|scsi|usb|virtio)|platform-sata_mv|platform-orion-ehci|platform-mmc|platform-mxsdhci)"
543 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
546 elif echo ${sysfs_path} | grep -q "^/block/dm-"
549 elif echo ${sysfs_path} | grep -q "^/block/mtdblock"
561 copyto="${copyfrom}_swap"
563 if [ -z "${MODULETORAM}" ]
565 size=$(fs_size "" ${copyfrom}/${LIVE_MEDIA_PATH} "used")
567 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
569 if [ -f "${MODULETORAMFILE}" ]
571 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
573 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
578 if [ "${copytodev}" = "ram" ]
581 freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
582 mount_options="-o size=${size}k"
587 # it should be a writable block device
588 if [ -b "${copytodev}" ]
592 fstype=$(get_fstype "${dev}")
593 freespace=$(fs_size "${dev}")
595 log_warning_msg "${copytodev} is not a block device."
600 if [ "${freespace}" -lt "${size}" ]
602 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
606 # Custom ramdisk size
607 if [ -z "${mount_options}" ] && [ -n "${ramdisk_size}" ]
609 # FIXME: should check for wrong values
610 mount_options="-o size=${ramdisk_size}"
613 # begin copying (or uncompressing)
615 log_begin_msg "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
616 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
618 if [ "${extension}" = "tgz" ]
621 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
622 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
623 mount -r -o move "${copyto}" "${rootmnt}"
626 if [ -n "${MODULETORAMFILE}" ]
630 echo " * Copying $MODULETORAMFILE to RAM" 1>/dev/console
631 rsync -a --progress ${MODULETORAMFILE} ${copyto} 1>/dev/console # copy only the filesystem module
633 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
638 echo " * Copying whole medium to RAM" 1>/dev/console
639 rsync -a --progress ${copyfrom}/* ${copyto} 1>/dev/console # "cp -a" from busybox also copies hidden files
641 mkdir -p ${copyto}/${LIVE_MEDIA_PATH}
642 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH}
643 if [ -e ${copyfrom}/${LIVE_MEDIA_PATH}/.disk ]
645 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/.disk ${copyto}
651 mount -r -o move ${copyto} ${copyfrom}
660 modprobe -q af_packet # For DHCP
665 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
666 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
668 if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
669 [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
673 # support for Syslinux IPAPPEND parameter
674 # it sets the BOOTIF variable on the kernel parameter
676 if [ -n "${BOOTIF}" ]
678 # pxelinux sets BOOTIF to a value based on the mac address of the
679 # network card used to PXE boot, so use this value for DEVICE rather
680 # than a hard-coded device name from initramfs.conf. this facilitates
681 # network booting when machines may have multiple network cards.
682 # pxelinux sets BOOTIF to 01-$mac_address
684 # strip off the leading "01-", which isn't part of the mac
686 temp_mac=${BOOTIF#*-}
688 # convert to typical mac address format by replacing "-" with ":"
693 if [ -z "$bootif_mac" ]
697 bootif_mac="$bootif_mac:$x"
702 # look for devices with matching mac address, and set DEVICE to
703 # appropriate value if match is found.
705 for device in /sys/class/net/*
707 if [ -f "$device/address" ]
709 current_mac=$(cat "$device/address")
711 if [ "$bootif_mac" = "$current_mac" ]
720 # if ethdevice was not specified on the kernel command line
721 # make sure we try to get a working network configuration
722 # for *every* present network device (except for loopback of course)
723 if [ -z "$ETHDEVICE" ] ; then
724 echo "If you want to boot from a specific device use bootoption ethdevice=..."
725 for device in /sys/class/net/*; do
727 if [ "$dev" != "lo" ] ; then
728 ETHDEVICE="$ETHDEVICE $dev"
733 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
734 for device in $(echo $ETHDEVICE | sed 's/,/ /g') ; do
735 devlist="$devlist $device"
738 # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
739 # an endless loop; iff execution fails give it two further tries, that's
740 # why we use '$devlist $devlist $devlist' for the other for loop
741 for dev in $devlist $devlist $devlist ; do
742 echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
743 ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
745 sleep "$ETHDEV_TIMEOUT" ; sleep 1
746 if [ -r /proc/"$jobid"/status ] ; then
747 echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
751 # if configuration of device worked we should have an assigned
752 # IP address, iff so let's use the according as $DEVICE for later usage
753 # simple and primitive approach which seems to work fine
754 if ifconfig $dev | grep -q 'inet.*addr:' ; then
761 for interface in ${DEVICE}; do
762 ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
763 [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
764 if [ "$IPV4ADDR" != "0.0.0.0" ]
771 for interface in ${DEVICE}; do
772 # source relevant ipconfig output
773 OLDHOSTNAME=${HOSTNAME}
774 [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
775 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
778 if [ -n "${interface}" ]
780 HWADDR="$(cat /sys/class/net/${interface}/address)"
783 if [ ! -e "/etc/resolv.conf" ]
785 echo "Creating /etc/resolv.conf"
787 if [ -n "${DNSDOMAIN}" ]
789 echo "domain ${DNSDOMAIN}" > /etc/resolv.conf
790 echo "search ${DNSDOMAIN}" >> /etc/resolv.conf
793 for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1}
795 if [ -n "$i" ] && [ "$i" != 0.0.0.0 ]
797 echo "nameserver $i" >> /etc/resolv.conf
802 # Check if we have a network device at all
803 if ! ls /sys/class/net/"$interface" > /dev/null 2>&1 && \
804 ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
805 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
806 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
807 ! ls /sys/class/net/ra0 > /dev/null 2>&1
809 panic "No supported network device found, maybe a non-mainline driver is required."
818 if [ "${NFSROOT}" = "auto" ]
820 NFSROOT=${ROOTSERVER}:${ROOTPATH}
825 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] )
831 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
833 NFSROOT=${ROOTSERVER}:${NFSROOT}
836 log_begin_msg "Trying netboot from ${NFSROOT}"
838 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
858 [ "${DEBUG}" = "Yes" ] && debugopt="-d 8"
859 #FIXME this name is supposed to be unique - some date + ifconfig hash?
860 ISCSI_INITIATORNAME="iqn.1993-08.org.debian.live:01:$(echo "${HWADDR}" | sed -e s/://g)"
861 export ISCSI_INITIATORNAME
862 if [ -n "${ISCSI_SERVER}" ] ; then
863 iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_SERVER}" -p "${ISCSI_PORT}"
865 iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_PORTAL}" -p 3260
869 panic "Failed to log into iscsi target"
871 local host="$(ls -d /sys/class/scsi_host/host*/device/iscsi_host:host* \
872 /sys/class/scsi_host/host*/device/iscsi_host/host* | sed -e 's:/device.*::' -e 's:.*host::')"
877 while [ -z "${devices}" -a $i -lt 60 ]
880 devices="$(ls -d /sys/class/scsi_device/${host}*/device/block:* \
881 /sys/class/scsi_device/${host}*/device/block/* | sed -e 's!.*[:/]!!')"
887 if check_dev "null" "/dev/$dev"
894 panic "Failed to locate a live device on iSCSI devices (tried: $devices)."
896 panic "Failed to locate iSCSI host in /sys"
904 for webfile in HTTPFS FTPFS FETCH
906 local url="$(eval echo \"\$\{${webfile}\}\")"
907 local extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
911 case "${extension}" in
912 iso|squashfs|tgz|tar)
913 if [ "${extension}" = "iso" ]
915 mkdir -p "${alt_mountpoint}"
916 dest="${alt_mountpoint}"
918 local dest="${mountpoint}/${LIVE_MEDIA_PATH}"
919 mount -t ramfs ram "${mountpoint}"
922 if [ "${webfile}" = "FETCH" ]
926 ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
927 rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
928 lfile="$(basename $url)"
929 log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
930 tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
934 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
935 wget "${url}" -O "${dest}/$(basename ${url})"
939 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
940 if [ "${webfile}" = "FTPFS" ]
942 FUSE_MOUNT="curlftpfs"
943 url="$(dirname ${url})"
948 $FUSE_MOUNT "${url}" "${dest}"
949 ROOT_PID="$(minips h -C "$FUSE_MOUNT" | { read x y ; echo "$x" ; } )"
951 [ ${?} -eq 0 ] && rc=0
952 [ "${extension}" = "tgz" ] && live_dest="ram"
953 if [ "${extension}" = "iso" ]
955 isoloop=$(setup_loop "${dest}/$(basename "${url}")" "loop" "/sys/block/loop*" "" '')
956 mount -t iso9660 "${isoloop}" "${mountpoint}"
963 log_begin_msg "Unrecognized archive extension for ${url}"
971 if [ -d "${alt_mountpoint}" ]
973 umount "${alt_mountpoint}"
974 rmdir "${alt_mountpoint}"
976 umount "${mountpoint}"
977 elif [ "${webfile}" != "FETCH" ] ; then
991 if [ -z "${NFSOPTS}" ]
996 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
998 # FIXME: This while loop is an ugly HACK round an nfs bug
1000 while [ "$i" -lt 60 ]
1002 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
1014 if [ -x "/sbin/mount.cifs" ]
1016 if [ -z "${NFSOPTS}" ]
1018 CIFSOPTS="-ouser=root,password="
1020 CIFSOPTS="${NFSOPTS}"
1023 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
1026 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
1040 size=$(fs_size "${fromdev}" "" "used")
1042 if [ -b "${fromdev}" ]
1044 log_success_msg "Copying snapshot ${fromdev} to ${todir}..."
1047 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
1049 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
1050 freespace=$(df -k | awk '/'${todev}'/{print $4}')
1052 freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
1055 tomount="/mnt/tmpsnap"
1057 if [ ! -d "${tomount}" ]
1059 mkdir -p "${tomount}"
1062 fstype=$(get_fstype "${fromdev}")
1064 if [ -n "${fstype}" ]
1067 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
1068 cp -a "${tomount}"/* ${todir}
1071 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
1076 if echo ${fromdev} | grep -qs loop
1078 losetup -d "${fromdev}"
1083 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
1090 # copy the contents of previously found snapshot to ${snap_mount}
1091 # and remember the device and filename for resync on exit in live-boot.init
1098 if [ -z "${snap_relpath}" ]
1100 # root snapshot, default usage
1103 # relative snapshot (actually used just for "/home" snapshots)
1104 snap_mount="${2}${snap_relpath}"
1107 if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
1109 log_success_msg "found snapshot: ${snapdata}"
1110 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
1111 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
1112 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
1114 if ! try_mount "${snapdev}" "${snapback}" "ro"
1121 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
1123 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
1124 dev=$(get_backing_device "${snapback}/${snapfile}")
1126 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1131 # Unfortunately klibc's cpio is incompatible with the
1132 # rest of the world; everything else requires -u -d,
1133 # while klibc doesn't implement them. Try to detect
1134 # whether it's in use.
1135 cpiopath="$(which cpio)" || true
1136 if [ "$cpiopath" ] && grep -aq /lib/klibc "$cpiopath"
1140 cpioargs='--unconditional --make-directories'
1143 if [ -s "${snapback}/${snapfile}" ]
1146 cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | $cpiopath $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null
1150 log_warning_msg "${snapback}/${snapfile} is empty, adding it for sync on reboot."
1154 if [ "${RES}" != "0" ]
1156 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | $cpiopath $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse\""
1160 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
1162 if [ "${RES}" != "0" ]
1164 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
1167 elif [ -b "${snapdata}" ]
1169 # Try to find if it could be a snapshot partition
1171 log_success_msg "found snapshot ${snap_type} device on ${dev}"
1172 if echo "${dev}" | grep -qs loop
1174 # strange things happens, user confused?
1175 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
1176 snapfile=$(basename ${snaploop})
1177 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
1182 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1184 log_warning_msg "Impossible to include the ${snap_type} Snapshot (i)"
1187 if [ -n "${snapfile}" ]
1189 # it was a loop device, user confused
1194 log_warning_msg "Impossible to include the ${snap_type} Snapshot (o)"
1198 if [ -z ${PERSISTENT_READONLY} ]
1200 echo "export ${snap_type}SNAP=${snap_relpath}:${snapdev}:${snapfile}" >> snapshot.conf # for resync on reboot/halt
1207 image_directory="${1}"
1209 addimage_directory="${3}"
1211 case ${UNIONTYPE} in
1212 aufs|unionfs|overlayfs)
1213 modprobe -q -b ${UNIONTYPE}
1215 if ! cut -f2 /proc/filesystems | grep -q "^${UNIONTYPE}\$" && [ -x /bin/unionfs-fuse ]
1217 echo "${UNIONTYPE} not available, falling back to unionfs-fuse."
1218 echo "This might be really slow."
1220 UNIONTYPE="unionfs-fuse"
1225 if [ "${UNIONTYPE}" = unionfs-fuse ]
1230 # run-init can't deal with images in a subdir, but we're going to
1231 # move all of these away before it runs anyway. No, we're not,
1232 # put them in / since move-mounting them into / breaks mono and
1237 # Let's just mount the read-only file systems first
1240 if [ -z "${PLAIN_ROOT}" ]
1242 # Read image names from ${MODULE}.module if it exists
1243 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1245 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1247 image_string="${image_string} ${image_directory}/${IMAGE}"
1249 elif [ -e "${image_directory}/${MODULE}.module" ]
1251 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1253 image_string="${image_string} ${image_directory}/${IMAGE}"
1256 # ${MODULE}.module does not exist, create a list of images
1257 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1259 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1261 if [ -e "${IMAGE}" ]
1263 image_string="${image_string} ${IMAGE}"
1268 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1270 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1272 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1274 if [ -e "${IMAGE}" ]
1276 image_string="${image_string} ${IMAGE}"
1283 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1286 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1290 for image in ${image_string}
1292 imagename=$(basename "${image}")
1294 export image devname
1295 maybe_break live-realpremount
1296 log_begin_msg "Running /scripts/live-realpremount"
1297 run_scripts /scripts/live-realpremount
1300 if [ -d "${image}" ]
1302 # it is a plain directory: do nothing
1303 rofslist="${image} ${rofslist}"
1304 elif [ -f "${image}" ]
1306 if losetup --help 2>&1 | grep -q -- "-r\b"
1308 backdev=$(get_backing_device "${image}" "-r")
1310 backdev=$(get_backing_device "${image}")
1312 fstype=$(get_fstype "${backdev}")
1314 if [ "${fstype}" = "unknown" ]
1316 panic "Unknown file system type on ${backdev} (${image})"
1319 if [ -z "${fstype}" ]
1321 fstype="${imagename##*.}"
1322 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1325 if [ "${UNIONTYPE}" != "unionmount" ]
1327 mpoint="${croot}/${imagename}"
1328 rofslist="${mpoint} ${rofslist}"
1331 rofslist="${rootmnt} ${rofslist}"
1333 mkdir -p "${mpoint}"
1334 log_begin_msg "Mounting \"${image}\" on \"${mpoint}\" via \"${backdev}\""
1335 mount -t "${fstype}" -o ro,noatime "${backdev}" "${mpoint}" || panic "Can not mount ${backdev} (${image}) on ${mpoint}"
1340 # we have a plain root system
1341 mkdir -p "${croot}/filesystem"
1342 log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
1343 mount -t $(get_fstype "${image_directory}") -o ro,noatime "${image_directory}" "${croot}/filesystem" || \
1344 panic "Can not mount ${image_directory} on ${croot}/filesystem" && \
1345 rofslist="${croot}/filesystem ${rofslist}"
1347 mount -o bind ${croot}/filesystem $mountpoint
1353 # Looking for persistent devices or files
1354 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1357 if [ -z "${QUICKUSBMODULES}" ]
1360 num_block=$(ls -l /sys/block | wc -l)
1361 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1363 modprobe -q -b ${module}
1369 # For some reason, udevsettle does not block in this scenario,
1370 # so we sleep for a little while.
1372 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1373 for timeout in 5 4 3 2 1
1377 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1384 case "${PERSISTENT_MEDIA}" in
1386 whitelistdev="$(removable_dev)"
1389 whitelistdev="$(removable_usb_dev)"
1396 if echo ${PERSISTENT_METHOD} | grep -qe "\<overlay\>"
1398 overlays="${root_overlay_label} ${custom_overlay_label}"
1401 if echo ${PERSISTENT_METHOD} | grep -qe "\<snapshot\>"
1403 snapshots="${root_snapshot_label} ${home_snapshot_label}"
1406 local root_snapdata=""
1407 local home_snapshot_label=""
1408 local root_overlay_label=""
1409 local overlay_devices=""
1410 for media in $(find_persistent_media "${overlays}" "${snapshots}" "${blacklistdev}" "${whitelistdev}")
1412 media="$(echo ${media} | tr ":" " ")"
1414 ${root_snapshot_label}=*)
1415 if [ -z "${root_snapdata}" ]
1417 root_snapdata="${media#*=}"
1420 ${home_snapshot_label}=*)
1421 # This second type should be removed when snapshot will get smarter,
1422 # hence when "/etc/live-snapshot*list" will be supported also by
1423 # ext2|ext3|ext4|jffs2 snapshot types.
1424 if [ -z "${home_snapdata}" ]
1426 home_snapdata="${media#*=}"
1429 ${root_overlay_label}=*)
1430 if [ -z "${root_overlay_device}" ]
1432 device="${media#*=}"
1433 root_overlay_device="${device}"
1436 ${custom_overlay_label}=*)
1437 device="${media#*=}"
1438 overlay_devices="${overlay_devices} ${device}"
1443 if [ -b "${root_overlay_device}" ]
1445 PERSISTENCE_IS_ON="1"
1446 export PERSISTENCE_IS_ON
1448 cowdevice=${root_overlay_device}
1449 cow_fstype=$(get_fstype "${root_overlay_device}")
1450 if [ -z "${PERSISTENT_READONLY}" ]
1452 cow_mountopt="rw,noatime"
1454 cow_mountopt="ro,noatime"
1457 if [ "${FORCEPERSISTENTFSCK}" = "Yes" ]
1459 fsck -y ${cowdevice}
1462 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1464 # check if there are any nfs options
1465 if echo ${NFS_COW}|grep -q ','
1467 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1468 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1470 nfs_cow_opts="-o nolock"
1474 if [ -n "${PERSISTENT_READONLY}" ]
1476 nfs_cow_opts="${nfs_cow_opts},nocto,ro"
1482 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1485 panic "unable to determine mac address"
1489 if [ -z "${cowdevice}" ]
1493 cow_mountopt="rw,noatime,mode=755"
1496 if [ "${UNIONTYPE}" != "unionmount" ]
1498 if [ -n "${PERSISTENT_READONLY}" ]
1500 mount -t tmpfs -o rw,noatime,mode=755 tmpfs "/cow"
1501 root_backing="${rootmnt}/live/persistent/$(basename ${cowdevice})-root"
1502 mkdir -p ${root_backing}
1507 if [ "${cow_fstype}" = "nfs" ]
1510 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} ${root_backing}"
1511 nfsmount ${nfs_cow_opts} ${cowdevice} ${root_backing} || \
1512 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on ${root_backing}"
1514 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} ${root_backing} || \
1515 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on ${root_backing}"
1519 rofscount=$(echo ${rofslist} |wc -w)
1521 # XXX: we now ensure that there can only be one read-only filesystem. Should this be inside the EXPOSED_ROOT if?
1522 if [ ${rofscount} -ne 1 ]
1524 panic "only one RO file system supported with exposedroot: ${rofslist}"
1528 if [ -n "${EXPOSED_ROOT}" ]
1530 mount --bind ${rofs} ${rootmnt} || \
1531 panic "bind mount of ${rofs} failed"
1533 if [ -z "${SKIP_UNION_MOUNTS}" ]
1535 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1543 if [ "${cow_fstype}" != "tmpfs" ] && [ "${cow_dirs}" != "/" ] && [ "${UNIONTYPE}" = "unionmount" ]
1545 true # FIXME: Maybe it does, I don't really know.
1546 #panic "unionmount does not support subunions (${cow_dirs})."
1549 for dir in ${cow_dirs}; do
1550 unionmountpoint="${rootmnt}${dir}"
1551 mkdir -p ${unionmountpoint}
1552 if [ "${UNIONTYPE}" = "unionmount" ]
1554 # FIXME: handle PERSISTENT_READONLY
1555 unionmountopts="-t ${cow_fstype} -o noatime,union,${cow_mountopt} ${cowdevice}"
1556 mount_full $unionmountopts "${unionmountpoint}"
1558 cow_dir="/cow${dir}"
1559 rofs_dir="${rofs}${dir}"
1561 if [ -n "${PERSISTENT_READONLY}" ] && [ "${cowdevice}" != "tmpfs" ]
1563 #mount -t tmpfs -o rw,noatime,mode=755 tmpfs "${cow_dir}"
1564 do_union ${unionmountpoint} ${cow_dir} ${root_backing} ${rofs_dir}
1566 do_union ${unionmountpoint} ${cow_dir} ${rofs_dir}
1568 fi || panic "mount ${UNIONTYPE} on ${unionmountpoint} failed with option ${unionmountopts}"
1571 # Correct the permissions of /:
1572 chmod 0755 "${rootmnt}"
1574 # tmpfs file systems
1576 mkdir -p "${rootmnt}/live"
1577 mount -t tmpfs tmpfs ${rootmnt}/live
1580 # SHOWMOUNTS is necessary for custom mounts with the union option
1581 # Since we may want to do custom mounts in user-space it's best to always enable SHOWMOUNTS
1582 if true #[ -n "${SHOWMOUNTS}" ] || ( [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ] 1)
1584 # XXX: is the for loop really necessary? rofslist can only contain one item (see above XXX about EXPOSEDROOT) and this is also assumed elsewhere above (see use of $rofs above).
1585 for d in ${rofslist}
1587 live_rofs="${rootmnt}/live/rofs/${d##*/}"
1588 live_rofs_list="${live_rofs_list} ${live_rofs}"
1589 mkdir -p "${live_rofs}"
1592 # do nothing # mount -o bind "${d}" "${live_rofs}"
1595 case "${UNIONTYPE}" in
1597 mount -o bind "${d}" "${live_rofs}"
1600 mount -o move "${d}" "${live_rofs}"
1608 # Adding custom persistent
1609 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1611 local custom_mounts="/custom_mounts.list"
1612 rm -rf ${custom_mounts} 2> /dev/null
1614 # Gather information about custom mounts from devies detected as overlays
1615 get_custom_mounts ${overlay_devices} ${custom_mounts} ${rootmnt}
1617 [ "${DEBUG}" = "Yes" ] && cp ${custom_mounts} "${rootmnt}/live/persistent"
1619 # Now we do the actual mounting (and symlinking)
1620 do_custom_mounts ${custom_mounts} ${rootmnt}
1623 # Look for other snapshots to copy in
1624 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1625 # This second type should be removed when snapshot grow smarter
1626 try_snap "${home_snapdata}" "${rootmnt}" "HOME" "/home"
1629 # shows cow fs on /cow for use by live-snapshot
1630 mkdir -p "${rootmnt}/live/cow"
1631 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"
1638 skip_uuid_check="${3}"
1640 # support for fromiso=.../isofrom=....
1641 if [ -n "$FROMISO" ]
1643 ISO_DEVICE=$(dirname $FROMISO)
1644 if ! [ -b $ISO_DEVICE ]
1646 # to support unusual device names like /dev/cciss/c0d0p1
1647 # as well we have to identify the block device name, let's
1648 # do that for up to 15 levels
1650 while [ -n "$ISO_DEVICE" ] && [ "$i" -gt 0 ]
1652 ISO_DEVICE=$(dirname ${ISO_DEVICE})
1653 [ -b "$ISO_DEVICE" ] && break
1658 if [ "$ISO_DEVICE" = "/" ]
1660 echo "Warning: device for bootoption isofrom= ($FROMISO) not found.">>/live-boot.log
1662 fs_type=$(get_fstype "${ISO_DEVICE}")
1663 if is_supported_fs ${fs_type}
1666 mount -t $fs_type "$ISO_DEVICE" /isofrom
1667 ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
1668 loopdevname=$(setup_loop "/isofrom/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
1669 devname="${loopdevname}"
1671 echo "Warning: unable to mount $ISO_DEVICE." >>/live-boot.log
1676 if [ -z "${devname}" ]
1678 devname=$(sys2dev "${sysdev}")
1681 if [ -d "${devname}" ]
1683 mount -o bind "${devname}" $mountpoint || continue
1685 if is_live_path $mountpoint
1695 for device in ${devname}
1699 # Adding lvm support
1700 if [ -x /scripts/local-top/lvm2 ]
1702 ROOT="$device" resume="" /scripts/local-top/lvm2
1707 # Adding raid support
1708 if [ -x /scripts/local-top/mdadm ]
1710 cp /conf/conf.d/md /conf/conf.d/md.orig
1711 echo "MD_DEVS=$device " >> /conf/conf.d/md
1712 /scripts/local-top/mdadm
1713 mv /conf/conf.d/md.orig /conf/conf.d/md
1720 [ -n "$device" ] && devname="$device"
1722 [ -e "$devname" ] || continue
1724 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1726 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1727 devname="${loopdevname}"
1730 fstype=$(get_fstype "${devname}")
1732 if is_supported_fs ${fstype}
1734 devuid=$(blkid -o value -s UUID "$devname")
1735 [ -n "$devuid" ] && grep -qs "\<$devuid\>" $tried && continue
1736 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1737 [ -n "$devuid" ] && echo "$devuid" >> $tried
1739 if is_live_path ${mountpoint} && \
1740 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1745 umount ${mountpoint} 2>/dev/null
1749 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1751 losetup -d "${loopdevname}"
1761 # don't start autodetection before timeout has expired
1762 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1764 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1770 # first look at the one specified in the command line
1771 case "${LIVE_MEDIA}" in
1773 for sysblock in $(removable_usb_dev "sys")
1775 for dev in $(subdevices "${sysblock}")
1777 if check_dev "${dev}"
1787 for sysblock in $(removable_dev "sys")
1789 for dev in $(subdevices "${sysblock}")
1791 if check_dev "${dev}"
1801 if [ ! -z "${LIVE_MEDIA}" ]
1803 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1811 # or do the scan of block devices
1812 # prefer removable devices over non-removable devices, so scan them first
1813 devices_to_scan="$(removable_dev 'sys') $(non_removable_dev 'sys')"
1815 for sysblock in $devices_to_scan
1817 devname=$(sys2dev "${sysblock}")
1818 [ -e "$devname" ] || continue
1819 fstype=$(get_fstype "${devname}")
1821 if /lib/udev/cdrom_id ${devname} > /dev/null
1823 if check_dev "null" "${devname}"
1827 elif is_nice_device "${sysblock}"
1829 for dev in $(subdevices "${sysblock}")
1831 if check_dev "${dev}"
1836 elif [ "${fstype}" = "squashfs" -o \
1837 "${fstype}" = "btrfs" -o \
1838 "${fstype}" = "ext2" -o \
1839 "${fstype}" = "ext3" -o \
1840 "${fstype}" = "ext4" -o \
1841 "${fstype}" = "jffs2" ]
1843 # This is an ugly hack situation, the block device has
1844 # an image directly on it. It's hopefully
1845 # live-boot, so take it and run with it.
1846 ln -s "${devname}" "${devname}.${fstype}"
1847 echo "${devname}.${fstype}"
1857 media_mountpoint="${1}"
1859 log_begin_msg "Checking media integrity"
1861 cd ${media_mountpoint}
1862 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1867 if [ "${RC}" -eq 0 ]
1869 log_success_msg "Everything ok, will reboot in 10 seconds."
1872 umount ${media_mountpoint}
1874 echo u > /proc/sysrq-trigger
1875 echo b > /proc/sysrq-trigger
1877 panic "Not ok, a media defect is likely, switch to VT8 for details."
1883 if [ -x /scripts/local-top/cryptroot ]; then
1884 /scripts/local-top/cryptroot
1889 exec > live-boot.log
1891 tail -f live-boot.log >&7 &
1894 # Ensure 'panic' function is overridden
1895 . /scripts/live-functions
1899 maybe_break live-premount
1900 log_begin_msg "Running /scripts/live-premount"
1901 run_scripts /scripts/live-premount
1904 # Needed here too because some things (*cough* udev *cough*)
1905 # changes the timeout
1907 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1911 livefs_root="${mountpoint}"
1913 panic "Unable to find a live file system on the network"
1916 if [ -n "${ISCSI_PORTAL}" ]
1918 do_iscsi && livefs_root="${mountpoint}"
1919 elif [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1921 # Do a local boot from hd
1924 if [ -x /usr/bin/memdiskfind ]
1926 MEMDISK=$(/usr/bin/memdiskfind)
1930 # We found a memdisk, set up phram
1931 modprobe phram phram=memdisk,${MEMDISK}
1933 # Load mtdblock, the memdisk will be /dev/mtdblock0
1938 # Scan local devices for the image
1940 while [ "$i" -lt 60 ]
1942 livefs_root=$(find_livefs ${i})
1944 if [ -n "${livefs_root}" ]
1955 if [ -z "${livefs_root}" ]
1957 panic "Unable to find a medium containing a live file system"
1960 if [ "${INTEGRITY_CHECK}" ]
1962 integrity_check "${livefs_root}"
1968 elif [ "${TODISK}" ]
1970 live_dest="${TODISK}"
1973 if [ "${live_dest}" ]
1975 log_begin_msg "Copying live media to ${live_dest}"
1976 copy_live_to "${livefs_root}" "${live_dest}"
1980 # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
1981 # because the mountpoint is left behind in /proc/mounts, so let's get
1982 # rid of it when running from RAM
1983 if [ -n "$FROMISO" ] && [ "${TORAM}" ]
1985 losetup -d /dev/loop0
1986 grep -q /isofrom /proc/mounts && umount /isofrom
1989 if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
1991 setup_unionfs "${livefs_root}" "${rootmnt}"
1994 mac="$(echo ${mac} | sed 's/-//g')"
1995 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1999 if [ -n "${ROOT_PID}" ] ; then
2000 echo "${ROOT_PID}" > "${rootmnt}"/live/root.pid
2005 # unionfs-fuse needs /dev to be bind-mounted for the duration of
2006 # live-bottom; udev's init script will take care of things after that
2007 if [ "${UNIONTYPE}" = unionfs-fuse ]
2009 mount -n -o bind /dev "${rootmnt}/dev"
2012 # Move to the new root filesystem so that programs there can get at it.
2013 if [ ! -d /root/live/image ]
2015 mkdir -p /root/live/image
2016 mount --move /live/image /root/live/image
2019 # aufs2 in kernel versions around 2.6.33 has a regression:
2020 # directories can't be accessed when read for the first the time,
2021 # causing a failure for example when accessing /var/lib/fai
2022 # when booting FAI, this simple workaround solves it
2023 ls /root/* >/dev/null 2>&1
2025 # copy snapshot configuration if exists
2026 if [ -f snapshot.conf ]
2028 log_begin_msg "Copying snapshot.conf to ${rootmnt}/etc/live/boot.d"
2029 if [ ! -d "${rootmnt}/etc/live/boot.d" ]
2031 mkdir -p "${rootmnt}/etc/live/boot.d"
2033 cp snapshot.conf "${rootmnt}/etc/live/boot.d/"
2037 if [ -f /etc/resolv.conf ] && [ ! -s ${rootmnt}/etc/resolv.conf ]
2039 log_begin_msg "Copying /etc/resolv.conf to ${rootmnt}/etc/resolv.conf"
2040 cp -v /etc/resolv.conf ${rootmnt}/etc/resolv.conf
2044 maybe_break live-bottom
2045 log_begin_msg "Running /scripts/live-bottom\n"
2047 run_scripts /scripts/live-bottom
2050 if [ "${UNIONFS}" = unionfs-fuse ]
2052 umount "${rootmnt}/dev"
2058 [ -w "${rootmnt}/var/log/" ] && cp live-boot.log "${rootmnt}/var/log/" 2>/dev/null