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)
58 export NOACCESSIBILITY NOFASTBOOT NOFSTAB NONETWORKING
62 ACCESS="${ARGUMENT#access=}"
67 DEFCONSOLE="${ARGUMENT#*=}"
83 # Force dhcp even while netbooting
84 # Use for debugging in case somebody works on fixing dhclient
94 DEVICE="${ARGUMENT#ethdevice=}"
96 export DEVICE ETHDEVICE
100 ETHDEV_TIMEOUT="${ARGUMENT#ethdevice-timeout=}"
101 export ETHDEV_TIMEOUT
105 FETCH="${ARGUMENT#fetch=}"
110 FORCEPERSISTENTFSCK="Yes"
111 export FORCEPERSISTENTFSCK
115 FTPFS="${ARGUMENT#ftpfs=}"
120 HTTPFS="${ARGUMENT#httpfs=}"
125 ISCSI="${ARGUMENT#iscsi=}"
126 #ip:port - separated by ;
127 ISCSI_PORTAL="${ISCSI%;*}"
128 if echo "${ISCSI_PORTAL}" | grep -q , ; then
129 ISCSI_SERVER="${ISCSI_PORTAL%,*}"
130 ISCSI_PORT="${ISCSI_PORTAL#*,}"
133 ISCSI_TARGET="${ISCSI#*;}"
134 export ISCSI ISCSI_PORTAL ISCSI_TARGET ISCSI_SERVER ISCSI_PORT
138 FROMISO="${ARGUMENT#*=}"
148 INTEGRITY_CHECK="Yes"
149 export INTEGRITY_CHECK
153 STATICIP="${ARGUMENT#ip=}"
155 if [ -z "${STATICIP}" ]
168 live-media=*|bootfrom=*)
169 LIVE_MEDIA="${ARGUMENT#*=}"
173 live-media-encryption=*|encryption=*)
174 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
175 export LIVE_MEDIA_ENCRYPTION
179 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
180 export LIVE_MEDIA_OFFSET
184 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
185 export LIVE_MEDIA_PATH
188 live-media-timeout=*)
189 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
190 export LIVE_MEDIA_TIMEOUT
194 MODULE="${ARGUMENT#module=}"
199 NETBOOT="${ARGUMENT#netboot=}"
204 NFSOPTS="${ARGUMENT#nfsopts=}"
209 NFS_COW="${ARGUMENT#nfscow=}"
214 NOACCESSIBILITY="Yes"
215 export NOACCESSIBILITY
234 ramdisk_size="${ARGUMENT#ramdisk-size=}"
247 persistent-encryption=*)
248 PERSISTENT_ENCRYPTION="${ARGUMENT#*=}"
249 export PERSISTENT_ENCRYPTION
253 PERSISTENT_MEDIA="${ARGUMENT#*=}"
254 export PERSISTENT_MEDIA
257 PERSISTENT_METHOD="${ARGUMENT#*=}"
258 export PERSISTENT_METHOD
262 PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
263 export PERSISTENT_PATH
265 persistent-read-only)
266 PERSISTENT_READONLY="Yes"
267 export PERSISTENT_READONLY
270 persistent-storage=*)
271 PERSISTENT_STORAGE="${ARGUMENT#persistent-storage=}"
272 export PERSISTENT_STORAGE
275 persistent-subtext=*)
276 root_persistence="${root_persistence}-${ARGUMENT#persistent-subtext=}"
277 home_persistence="${home_persistence}-${ARGUMENT#persistent-subtext=}"
278 root_snapshot_label="${root_snapshot_label}-${ARGUMENT#persistent-subtext=}"
279 home_snapshot_label="${home_snapshot_label}-${ARGUMENT#persistent-subtext=}"
293 NOPROMPT="${ARGUMENT#noprompt=}"
298 QUICKUSBMODULES="Yes"
299 export QUICKUSBMODULES
302 preseed/file=*|file=*)
303 LOCATIONS="${ARGUMENT#*=} ${LOCATIONS}"
313 question="${ARGUMENT%%=*}"
314 value="${ARGUMENT#*=}"
315 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
330 TODISK="${ARGUMENT#todisk=}"
341 MODULETORAM="${ARGUMENT#toram=}"
342 export TORAM MODULETORAM
356 SKIP_UNION_MOUNTS="Yes"
357 export SKIP_UNION_MOUNTS
361 ROOT="${ARGUMENT#root=}"
366 UNIONTYPE="${ARGUMENT#union=}"
372 # sort of compatibility with netboot.h from linux docs
373 if [ -z "${NETBOOT}" ]
375 if [ "${ROOT}" = "/dev/nfs" ]
379 elif [ "${ROOT}" = "/dev/cifs" ]
386 if [ -z "${MODULE}" ]
392 if [ -z "${UNIONTYPE}" ]
398 if [ -z "${PERSISTENT_ENCRYPTION}" ]
400 PERSISTENT_ENCRYPTION="none"
401 export PERSISTENT_ENCRYPTION
402 elif echo ${PERSISTENT_ENCRYPTION} | grep -qe "\<luks\>"
404 if ! modprobe dm-crypt
406 log_warning_msg "Unable to load module dm-crypt"
407 PERSISTENT_ENCRYPTION=$(echo ${PERSISTENT_ENCRYPTION} | sed -e 's/\<luks,\|,\?luks$//g')
408 export PERSISTENT_ENCRYPTION
411 if [ ! -x /lib/cryptsetup/askpass ] || [ ! -x /sbin/cryptsetup ]
413 log_warning_msg "cryptsetup in unavailable"
414 PERSISTENT_ENCRYPTION=$(echo ${PERSISTENT_ENCRYPTION} | sed -e 's/\<luks,\|,\?luks$//g')
415 export PERSISTENT_ENCRYPTION
419 if [ -n "${PERSISTENT}" ] && [ -z "${PERSISTENT_METHOD}" ]
421 PERSISTENT_METHOD="snapshot,overlay"
422 export PERSISTENT_METHOD
425 if [ -n "${PERSISTENT}" ] && [ -z "${PERSISTENT_STORAGE}" ]
427 PERSISTENT_STORAGE="filesystem,file"
428 export PERSISTENT_STORAGE
436 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
438 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
440 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
452 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
458 uuid="$(cat /conf/uuid.conf)"
460 for try_uuid_file in "${path}/.disk/live-uuid"*
462 [ -e "${try_uuid_file}" ] || continue
464 try_uuid="$(cat "${try_uuid_file}")"
466 if [ "${uuid}" = "${try_uuid}" ]
475 get_backing_device ()
478 *.squashfs|*.ext2|*.ext3|*.ext4|*.jffs2)
479 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
487 panic "Unrecognized live filesystem: ${1}"
492 match_files_in_dir ()
494 # Does any files match pattern ${1} ?
497 if [ "$(echo ${pattern})" != "${pattern}" ]
505 mount_images_in_directory ()
512 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
513 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
514 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
515 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
516 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
517 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
519 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
520 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
522 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
528 sysfs_path="${1#/sys}"
530 if [ -e /lib/udev/path_id ]
533 PATH_ID="/lib/udev/path_id"
535 # wheezy/sid (udev >= 174)
536 PATH_ID="/sbin/udevadm test-builtin path_id"
539 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)"
542 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
545 elif echo ${sysfs_path} | grep -q "^/block/dm-"
548 elif echo ${sysfs_path} | grep -q "^/block/mtdblock"
560 copyto="${copyfrom}_swap"
562 if [ -z "${MODULETORAM}" ]
564 size=$(fs_size "" ${copyfrom}/${LIVE_MEDIA_PATH} "used")
566 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
568 if [ -f "${MODULETORAMFILE}" ]
570 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
572 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
577 if [ "${copytodev}" = "ram" ]
580 freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
581 mount_options="-o size=${size}k"
586 # it should be a writable block device
587 if [ -b "${copytodev}" ]
591 fstype=$(get_fstype "${dev}")
592 freespace=$(fs_size "${dev}")
594 log_warning_msg "${copytodev} is not a block device."
599 if [ "${freespace}" -lt "${size}" ]
601 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
605 # Custom ramdisk size
606 if [ -z "${mount_options}" ] && [ -n "${ramdisk_size}" ]
608 # FIXME: should check for wrong values
609 mount_options="-o size=${ramdisk_size}"
612 # begin copying (or uncompressing)
614 log_begin_msg "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
615 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
617 if [ "${extension}" = "tgz" ]
620 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
621 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
622 mount -r -o move "${copyto}" "${rootmnt}"
625 if [ -n "${MODULETORAMFILE}" ]
629 echo " * Copying $MODULETORAMFILE to RAM" 1>/dev/console
630 rsync -a --progress ${MODULETORAMFILE} ${copyto} 1>/dev/console # copy only the filesystem module
632 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
637 echo " * Copying whole medium to RAM" 1>/dev/console
638 rsync -a --progress ${copyfrom}/* ${copyto} 1>/dev/console # "cp -a" from busybox also copies hidden files
640 mkdir -p ${copyto}/${LIVE_MEDIA_PATH}
641 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH}
642 if [ -e ${copyfrom}/${LIVE_MEDIA_PATH}/.disk ]
644 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/.disk ${copyto}
650 mount -r -o move ${copyto} ${copyfrom}
659 modprobe -q af_packet # For DHCP
664 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
665 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
667 if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
668 [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
672 # support for Syslinux IPAPPEND parameter
673 # it sets the BOOTIF variable on the kernel parameter
675 if [ -n "${BOOTIF}" ]
677 # pxelinux sets BOOTIF to a value based on the mac address of the
678 # network card used to PXE boot, so use this value for DEVICE rather
679 # than a hard-coded device name from initramfs.conf. this facilitates
680 # network booting when machines may have multiple network cards.
681 # pxelinux sets BOOTIF to 01-$mac_address
683 # strip off the leading "01-", which isn't part of the mac
685 temp_mac=${BOOTIF#*-}
687 # convert to typical mac address format by replacing "-" with ":"
692 if [ -z "$bootif_mac" ]
696 bootif_mac="$bootif_mac:$x"
701 # look for devices with matching mac address, and set DEVICE to
702 # appropriate value if match is found.
704 for device in /sys/class/net/*
706 if [ -f "$device/address" ]
708 current_mac=$(cat "$device/address")
710 if [ "$bootif_mac" = "$current_mac" ]
719 # if ethdevice was not specified on the kernel command line
720 # make sure we try to get a working network configuration
721 # for *every* present network device (except for loopback of course)
722 if [ -z "$ETHDEVICE" ] ; then
723 echo "If you want to boot from a specific device use bootoption ethdevice=..."
724 for device in /sys/class/net/*; do
726 if [ "$dev" != "lo" ] ; then
727 ETHDEVICE="$ETHDEVICE $dev"
732 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
733 for device in $(echo $ETHDEVICE | sed 's/,/ /g') ; do
734 devlist="$devlist $device"
737 # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
738 # an endless loop; iff execution fails give it two further tries, that's
739 # why we use '$devlist $devlist $devlist' for the other for loop
740 for dev in $devlist $devlist $devlist ; do
741 echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
742 ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
744 sleep "$ETHDEV_TIMEOUT" ; sleep 1
745 if [ -r /proc/"$jobid"/status ] ; then
746 echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
750 # if configuration of device worked we should have an assigned
751 # IP address, iff so let's use the according as $DEVICE for later usage
752 # simple and primitive approach which seems to work fine
753 if ifconfig $dev | grep -q 'inet.*addr:' ; then
760 for interface in ${DEVICE}; do
761 ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
762 [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
763 if [ "$IPV4ADDR" != "0.0.0.0" ]
770 for interface in ${DEVICE}; do
771 # source relevant ipconfig output
772 OLDHOSTNAME=${HOSTNAME}
773 [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
774 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
777 if [ -n "${interface}" ]
779 HWADDR="$(cat /sys/class/net/${interface}/address)"
782 if [ ! -e "/etc/resolv.conf" ]
784 echo "Creating /etc/resolv.conf"
786 if [ -n "${DNSDOMAIN}" ]
788 echo "domain ${DNSDOMAIN}" > /etc/resolv.conf
789 echo "search ${DNSDOMAIN}" >> /etc/resolv.conf
792 for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1}
794 if [ -n "$i" ] && [ "$i" != 0.0.0.0 ]
796 echo "nameserver $i" >> /etc/resolv.conf
801 # Check if we have a network device at all
802 if ! ls /sys/class/net/"$interface" > /dev/null 2>&1 && \
803 ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
804 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
805 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
806 ! ls /sys/class/net/ra0 > /dev/null 2>&1
808 panic "No supported network device found, maybe a non-mainline driver is required."
817 if [ "${NFSROOT}" = "auto" ]
819 NFSROOT=${ROOTSERVER}:${ROOTPATH}
824 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] )
830 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
832 NFSROOT=${ROOTSERVER}:${NFSROOT}
835 log_begin_msg "Trying netboot from ${NFSROOT}"
837 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
857 [ "${DEBUG}" == "Yes" ] && debugopt="-d 8"
858 #FIXME this name is supposed to be unique - some date + ifconfig hash?
859 ISCSI_INITIATORNAME="iqn.1993-08.org.debian.live:01:$(echo "${HWADDR}" | sed -e s/://g)"
860 export ISCSI_INITIATORNAME
861 if [ -n "${ISCSI_SERVER}" ] ; then
862 iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_SERVER}" -p "${ISCSI_PORT}"
864 iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_PORTAL}" -p 3260
868 panic "Failed to log into iscsi target"
870 local host="$(ls -d /sys/class/scsi_host/host*/device/iscsi_host:host* \
871 /sys/class/scsi_host/host*/device/iscsi_host/host* | sed -e 's:/device.*::' -e 's:.*host::')"
876 while [ -z "${devices}" -a $i -lt 60 ]
879 devices="$(ls -d /sys/class/scsi_device/${host}*/device/block:* \
880 /sys/class/scsi_device/${host}*/device/block/* | sed -e 's!.*[:/]!!')"
886 if check_dev "null" "/dev/$dev"
893 panic "Failed to locate a live device on iSCSI devices (tried: $devices)."
895 panic "Failed to locate iSCSI host in /sys"
903 for webfile in HTTPFS FTPFS FETCH
905 local url="$(eval echo \"\$\{${webfile}\}\")"
906 local extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
910 case "${extension}" in
911 iso|squashfs|tgz|tar)
912 if [ "${extension}" = "iso" ]
914 mkdir -p "${alt_mountpoint}"
915 dest="${alt_mountpoint}"
917 local dest="${mountpoint}/${LIVE_MEDIA_PATH}"
918 mount -t ramfs ram "${mountpoint}"
921 if [ "${webfile}" = "FETCH" ]
925 ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
926 rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
927 lfile="$(basename $url)"
928 log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
929 tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
933 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
934 wget "${url}" -O "${dest}/$(basename ${url})"
938 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
939 if [ "${webfile}" = "FTPFS" ]
941 FUSE_MOUNT="curlftpfs"
942 url="$(dirname ${url})"
947 $FUSE_MOUNT "${url}" "${dest}"
948 ROOT_PID="$(minips h -C "$FUSE_MOUNT" | { read x y ; echo "$x" ; } )"
950 [ ${?} -eq 0 ] && rc=0
951 [ "${extension}" = "tgz" ] && live_dest="ram"
952 if [ "${extension}" = "iso" ]
954 isoloop=$(setup_loop "${dest}/$(basename "${url}")" "loop" "/sys/block/loop*" "" '')
955 mount -t iso9660 "${isoloop}" "${mountpoint}"
962 log_begin_msg "Unrecognized archive extension for ${url}"
970 if [ -d "${alt_mountpoint}" ]
972 umount "${alt_mountpoint}"
973 rmdir "${alt_mountpoint}"
975 umount "${mountpoint}"
976 elif [ "${webfile}" != "FETCH" ] ; then
990 if [ -z "${NFSOPTS}" ]
995 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
997 # FIXME: This while loop is an ugly HACK round an nfs bug
999 while [ "$i" -lt 60 ]
1001 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
1013 if [ -x "/sbin/mount.cifs" ]
1015 if [ -z "${NFSOPTS}" ]
1017 CIFSOPTS="-ouser=root,password="
1019 CIFSOPTS="${NFSOPTS}"
1022 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
1025 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
1039 size=$(fs_size "${fromdev}" "" "used")
1041 if [ -b "${fromdev}" ]
1043 log_success_msg "Copying snapshot ${fromdev} to ${todir}..."
1046 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
1048 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
1049 freespace=$(df -k | awk '/'${todev}'/{print $4}')
1051 freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
1054 tomount="/mnt/tmpsnap"
1056 if [ ! -d "${tomount}" ]
1058 mkdir -p "${tomount}"
1061 fstype=$(get_fstype "${fromdev}")
1063 if [ -n "${fstype}" ]
1066 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
1067 cp -a "${tomount}"/* ${todir}
1070 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
1075 if echo ${fromdev} | grep -qs loop
1077 losetup -d "${fromdev}"
1082 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
1089 # copy the contents of previously found snapshot to ${snap_mount}
1090 # and remember the device and filename for resync on exit in live-boot.init
1097 if [ -z "${snap_relpath}" ]
1099 # root snapshot, default usage
1102 # relative snapshot (actually used just for "/home" snapshots)
1103 snap_mount="${2}${snap_relpath}"
1106 if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
1108 log_success_msg "found snapshot: ${snapdata}"
1109 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
1110 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
1111 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
1113 if ! try_mount "${snapdev}" "${snapback}" "ro"
1120 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
1122 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
1123 dev=$(get_backing_device "${snapback}/${snapfile}")
1125 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1130 # Unfortunately klibc's cpio is incompatible with the
1131 # rest of the world; everything else requires -u -d,
1132 # while klibc doesn't implement them. Try to detect
1133 # whether it's in use.
1134 cpiopath="$(which cpio)" || true
1135 if [ "$cpiopath" ] && grep -aq /lib/klibc "$cpiopath"
1139 cpioargs='--unconditional --make-directories'
1142 if [ -s "${snapback}/${snapfile}" ]
1145 cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | $cpiopath $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null
1149 log_warning_msg "${snapback}/${snapfile} is empty, adding it for sync on reboot."
1153 if [ "${RES}" != "0" ]
1155 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | $cpiopath $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse\""
1159 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
1161 if [ "${RES}" != "0" ]
1163 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
1166 elif [ -b "${snapdata}" ]
1168 # Try to find if it could be a snapshot partition
1170 log_success_msg "found snapshot ${snap_type} device on ${dev}"
1171 if echo "${dev}" | grep -qs loop
1173 # strange things happens, user confused?
1174 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
1175 snapfile=$(basename ${snaploop})
1176 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
1181 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1183 log_warning_msg "Impossible to include the ${snap_type} Snapshot (i)"
1186 if [ -n "${snapfile}" ]
1188 # it was a loop device, user confused
1193 log_warning_msg "Impossible to include the ${snap_type} Snapshot (o)"
1197 if [ -z ${PERSISTENT_READONLY} ]
1199 echo "export ${snap_type}SNAP=${snap_relpath}:${snapdev}:${snapfile}" >> snapshot.conf # for resync on reboot/halt
1206 image_directory="${1}"
1208 addimage_directory="${3}"
1210 case ${UNIONTYPE} in
1211 aufs|unionfs|overlayfs)
1212 modprobe -q -b ${UNIONTYPE}
1214 if ! cut -f2 /proc/filesystems | grep -q "^${UNIONTYPE}\$" && [ -x /bin/unionfs-fuse ]
1216 echo "${UNIONTYPE} not available, falling back to unionfs-fuse."
1217 echo "This might be really slow."
1219 UNIONTYPE="unionfs-fuse"
1224 if [ "${UNIONTYPE}" = unionfs-fuse ]
1229 # run-init can't deal with images in a subdir, but we're going to
1230 # move all of these away before it runs anyway. No, we're not,
1231 # put them in / since move-mounting them into / breaks mono and
1236 # Let's just mount the read-only file systems first
1239 if [ "${UNIONTYPE}" = "aufs" ]
1242 noxino_opt="noxino,"
1243 elif [ "${UNIONTYPE}" = "unionfs-fuse" ]
1250 if [ -z "${PLAIN_ROOT}" ]
1252 # Read image names from ${MODULE}.module if it exists
1253 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1255 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1257 image_string="${image_string} ${image_directory}/${IMAGE}"
1259 elif [ -e "${image_directory}/${MODULE}.module" ]
1261 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1263 image_string="${image_string} ${image_directory}/${IMAGE}"
1266 # ${MODULE}.module does not exist, create a list of images
1267 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1269 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1271 if [ -e "${IMAGE}" ]
1273 image_string="${image_string} ${IMAGE}"
1278 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1280 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1282 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1284 if [ -e "${IMAGE}" ]
1286 image_string="${image_string} ${IMAGE}"
1293 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1296 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1300 for image in ${image_string}
1302 imagename=$(basename "${image}")
1304 export image devname
1305 maybe_break live-realpremount
1306 log_begin_msg "Running /scripts/live-realpremount"
1307 run_scripts /scripts/live-realpremount
1310 if [ -d "${image}" ]
1312 # it is a plain directory: do nothing
1313 rofslist="${image} ${rofslist}"
1314 elif [ -f "${image}" ]
1316 if losetup --help 2>&1 | grep -q -- "-r\b"
1318 backdev=$(get_backing_device "${image}" "-r")
1320 backdev=$(get_backing_device "${image}")
1322 fstype=$(get_fstype "${backdev}")
1324 if [ "${fstype}" = "unknown" ]
1326 panic "Unknown file system type on ${backdev} (${image})"
1329 if [ -z "${fstype}" ]
1331 fstype="${imagename##*.}"
1332 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1335 if [ "${UNIONTYPE}" != "unionmount" ]
1337 mpoint="${croot}/${imagename}"
1338 rofslist="${mpoint} ${rofslist}"
1341 rofslist="${rootmnt} ${rofslist}"
1343 mkdir -p "${mpoint}"
1344 log_begin_msg "Mounting \"${image}\" on \"${mpoint}\" via \"${backdev}\""
1345 mount -t "${fstype}" -o ro,noatime "${backdev}" "${mpoint}" || panic "Can not mount ${backdev} (${image}) on ${mpoint}"
1350 # we have a plain root system
1351 mkdir -p "${croot}/filesystem"
1352 log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
1353 mount -t $(get_fstype "${image_directory}") -o ro,noatime "${image_directory}" "${croot}/filesystem" || \
1354 panic "Can not mount ${image_directory} on ${croot}/filesystem" && \
1355 rofslist="${croot}/filesystem ${rofslist}"
1357 mount -o bind ${croot}/filesystem $mountpoint
1363 # Looking for "${root_persistence}" device or file
1364 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1367 if [ -z "${QUICKUSBMODULES}" ]
1370 num_block=$(ls -l /sys/block | wc -l)
1371 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1373 modprobe -q -b ${module}
1379 # For some reason, udevsettle does not block in this scenario,
1380 # so we sleep for a little while.
1382 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1383 for timeout in 5 4 3 2 1
1387 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1394 case "${PERSISTENT_MEDIA}" in
1396 whitelistdev="$(removable_dev)"
1399 whitelistdev="$(removable_usb_dev)"
1406 if echo ${PERSISTENT_METHOD} | grep -qe "\<overlay\>"
1408 overlays="${root_persistence} ${home_persistence}"
1411 if echo ${PERSISTENT_METHOD} | grep -qe "\<snapshot\>"
1413 snapshots="${root_snapshot_label} ${home_snapshot_label}"
1417 for media in $(find_persistent_media "${overlays}" "${snapshots}" "${blacklistdev}" "${whitelistdev}")
1419 media="$(echo ${media} | tr ":" " ")"
1421 ${root_persistence}=*)
1422 cowprobe="${media#*=}"
1424 ${home_persistence}=*)
1425 homecow="${media#*=}"
1427 ${root_snapshot_label}=*)
1428 root_snapdata="${media#*=}"
1430 ${home_snapshot_label}=*)
1431 # This second type should be removed when snapshot will get smarter,
1432 # hence when "/etc/live-snapshot*list" will be supported also by
1433 # ext2|ext3|ext4|jffs2 snapshot types.
1434 home_snapdata="${media#*=}"
1441 if [ -b "${cowprobe}" ] || [ -b "${homecow}" ]
1443 PERSISTENCE_IS_ON="1"
1444 export PERSISTENCE_IS_ON
1447 if [ -b "${cowprobe}" ]
1449 cowdevice=${cowprobe}
1450 cow_fstype=$(get_fstype "${cowprobe}")
1451 if [ -z "${PERSISTENT_READONLY}" ]
1453 cow_mountopt="rw,noatime"
1455 cow_mountopt="ro,noatime"
1458 if [ "${FORCEPERSISTENTFSCK}" = "Yes" ]
1460 fsck -y ${cowdevice}
1463 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1465 # check if there are any nfs options
1466 if echo ${NFS_COW}|grep -q ','
1468 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1469 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1471 nfs_cow_opts="-o nolock"
1475 if [ -n "${PERSISTENT_READONLY}" ]
1477 nfs_cow_opts="${nfs_cow_opts},nocto,ro"
1483 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1486 panic "unable to determine mac address"
1490 if [ -z "${cowdevice}" ]
1494 cow_mountopt="rw,noatime,mode=755"
1497 if [ "${UNIONTYPE}" != "unionmount" ]
1499 if [ -n "${PERSISTENT_READONLY}" ]
1501 persistent_root="/$(basename ${cowdevice})-backing"
1502 mkdir -p ${persistent_root}
1504 persistent_root="/cow"
1507 if [ "${cow_fstype}" = "nfs" ]
1510 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} ${persistent_root}"
1511 nfsmount ${nfs_cow_opts} ${cowdevice} ${persistent_root} || \
1512 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on ${persistent_root}"
1514 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} ${persistent_root} || \
1515 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on ${persistent_root}"
1519 rofscount=$(echo ${rofslist} |wc -w)
1521 if [ ${rofscount} -ne 1 ]
1523 panic "only one RO file system supported with exposedroot: ${rofslist}"
1527 if [ -n "${EXPOSED_ROOT}" ]
1529 mount --bind ${rofs} ${rootmnt} || \
1530 panic "bind mount of ${rofs} failed"
1532 if [ -z "${SKIP_UNION_MOUNTS}" ]
1534 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1542 if [ "${cow_fstype}" != "tmpfs" ] && [ "${cow_dirs}" != "/" ] && [ "${UNIONTYPE}" = "unionmount" ]
1544 true # FIXME: Maybe it does, I don't really know.
1545 #panic "unionmount does not support subunions (${cow_dirs})."
1551 for dir in ${cow_dirs}; do
1554 unionmountpoint="${rootmnt}${dir}"
1555 unionrw="/cow${dir}"
1556 unionro="${rofs}${dir}"
1557 # We don't handle spaces and other junk gracefully here, hopefully not needed.
1558 case "${UNIONTYPE}" in
1560 unionmountopts="-o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid"
1561 unionmountopts="${unionmountopts} ${unionrw}=RW:${unionro}=RO"
1562 ( sysctl -w fs.file-max=391524 ; ulimit -HSn 16384
1563 unionfs-fuse ${unionmountopts} "${unionmountpoint}" ) && \
1564 ( mkdir -p /run/sendsigs.omit.d
1565 pidof unionfs-fuse >> /run/sendsigs.omit.d/unionfs-fuse || true )
1569 unionmountopts="-t ${cow_fstype} -o noatime,union,${cow_mountopt} ${cowdevice}"
1570 mount_full $unionmountopts "${unionmountpoint}"
1574 unionmountopts="-o noatime,${noxino_opt},lowerdir=${unionro},upperdir=${unionrw}"
1575 mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}"
1579 if [ -n "${PERSISTENT_READONLY}" ]
1581 mount -t tmpfs -o rw,noatime,mode=755 tmpfs "${unionrw}"
1582 unionmountopts="-o noatime,${noxino_opt}dirs=${unionrw}=rw:${persistent_root}=${roopt}:${unionro}=${roopt}"
1584 unionmountopts="-o noatime,${noxino_opt}dirs=${unionrw}=rw:${unionro}=${roopt}"
1586 mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}"
1589 panic "mount ${UNIONTYPE} on ${unionmountpoint} failed with option ${unionmountopts}"
1592 # Correct the permissions of /:
1593 chmod 0755 "${rootmnt}"
1595 # tmpfs file systems
1597 mkdir -p "${rootmnt}/live"
1598 mount -t tmpfs tmpfs ${rootmnt}/live
1600 # Adding other custom mounts
1601 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1603 # directly mount /home
1604 # FIXME: add a custom mounts configurable system
1606 if [ -b "${homecow}" ]
1608 if [ -z "${PERSISTENT_READONLY}" ]
1610 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1613 homero="/$(basename ${homecow})-backing"
1614 homemountpoint="${rootmnt}/home"
1615 mkdir -p ${homerw} ${homero} ${homemountpoint}
1616 mount -t $(get_fstype "${homecow}") -o ro "${homecow}" "${homero}"
1617 mount -t "${UNIONTYPE}" -o "noatime,${noxino_opt}dirs=${homerw}=rw:${homero}=${roopt}" "${UNIONTYPE}" "${homemountpoint}"
1619 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1621 log_warning_msg "Unable to find the persistent home medium"
1624 # Look for other snapshots to copy in
1625 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1626 # This second type should be removed when snapshot grow smarter
1627 try_snap "${home_snapdata}" "${rootmnt}" "HOME" "/home"
1630 if [ -n "${SHOWMOUNTS}" ]
1632 for d in ${rofslist}
1634 mkdir -p "${rootmnt}/live/${d##*/}"
1638 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1642 case "${UNIONTYPE}" in
1644 mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1648 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1656 # shows cow fs on /cow for use by live-snapshot
1657 mkdir -p "${rootmnt}/live/cow"
1658 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"
1665 skip_uuid_check="${3}"
1667 # support for fromiso=.../isofrom=....
1668 if [ -n "$FROMISO" ]
1670 ISO_DEVICE=$(dirname $FROMISO)
1671 if ! [ -b $ISO_DEVICE ]
1673 # to support unusual device names like /dev/cciss/c0d0p1
1674 # as well we have to identify the block device name, let's
1675 # do that for up to 15 levels
1677 while [ -n "$ISO_DEVICE" ] && [ "$i" -gt 0 ]
1679 ISO_DEVICE=$(dirname ${ISO_DEVICE})
1680 [ -b "$ISO_DEVICE" ] && break
1685 if [ "$ISO_DEVICE" = "/" ]
1687 echo "Warning: device for bootoption isofrom= ($FROMISO) not found.">>/live-boot.log
1689 fs_type=$(get_fstype "${ISO_DEVICE}")
1690 if is_supported_fs ${fs_type}
1693 mount -t $fs_type "$ISO_DEVICE" /isofrom
1694 ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
1695 loopdevname=$(setup_loop "/isofrom/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
1696 devname="${loopdevname}"
1698 echo "Warning: unable to mount $ISO_DEVICE." >>/live-boot.log
1703 if [ -z "${devname}" ]
1705 devname=$(sys2dev "${sysdev}")
1708 if [ -d "${devname}" ]
1710 mount -o bind "${devname}" $mountpoint || continue
1712 if is_live_path $mountpoint
1722 for device in ${devname}
1726 # Adding lvm support
1727 if [ -x /scripts/local-top/lvm2 ]
1729 ROOT="$device" resume="" /scripts/local-top/lvm2
1734 # Adding raid support
1735 if [ -x /scripts/local-top/mdadm ]
1737 cp /conf/conf.d/md /conf/conf.d/md.orig
1738 echo "MD_DEVS=$device " >> /conf/conf.d/md
1739 /scripts/local-top/mdadm
1740 mv /conf/conf.d/md.orig /conf/conf.d/md
1747 [ -n "$device" ] && devname="$device"
1749 [ -e "$devname" ] || continue
1751 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1753 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1754 devname="${loopdevname}"
1757 fstype=$(get_fstype "${devname}")
1759 if is_supported_fs ${fstype}
1761 devuid=$(blkid -o value -s UUID "$devname")
1762 [ -n "$devuid" ] && grep -qs "\<$devuid\>" $tried && continue
1763 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1764 [ -n "$devuid" ] && echo "$devuid" >> $tried
1766 if is_live_path ${mountpoint} && \
1767 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1772 umount ${mountpoint} 2>/dev/null
1776 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1778 losetup -d "${loopdevname}"
1788 # don't start autodetection before timeout has expired
1789 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1791 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1797 # first look at the one specified in the command line
1798 case "${LIVE_MEDIA}" in
1800 for sysblock in $(removable_usb_dev "sys")
1802 for dev in $(subdevices "${sysblock}")
1804 if check_dev "${dev}"
1814 for sysblock in $(removable_dev "sys")
1816 for dev in $(subdevices "${sysblock}")
1818 if check_dev "${dev}"
1828 if [ ! -z "${LIVE_MEDIA}" ]
1830 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1838 # or do the scan of block devices
1839 # prefer removable devices over non-removable devices, so scan them first
1840 devices_to_scan="$(removable_dev 'sys') $(non_removable_dev 'sys')"
1842 for sysblock in $devices_to_scan
1844 devname=$(sys2dev "${sysblock}")
1845 [ -e "$devname" ] || continue
1846 fstype=$(get_fstype "${devname}")
1848 if /lib/udev/cdrom_id ${devname} > /dev/null
1850 if check_dev "null" "${devname}"
1854 elif is_nice_device "${sysblock}"
1856 for dev in $(subdevices "${sysblock}")
1858 if check_dev "${dev}"
1863 elif [ "${fstype}" = "squashfs" -o \
1864 "${fstype}" = "btrfs" -o \
1865 "${fstype}" = "ext2" -o \
1866 "${fstype}" = "ext3" -o \
1867 "${fstype}" = "ext4" -o \
1868 "${fstype}" = "jffs2" ]
1870 # This is an ugly hack situation, the block device has
1871 # an image directly on it. It's hopefully
1872 # live-boot, so take it and run with it.
1873 ln -s "${devname}" "${devname}.${fstype}"
1874 echo "${devname}.${fstype}"
1884 media_mountpoint="${1}"
1886 log_begin_msg "Checking media integrity"
1888 cd ${media_mountpoint}
1889 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1894 if [ "${RC}" -eq 0 ]
1896 log_success_msg "Everything ok, will reboot in 10 seconds."
1899 umount ${media_mountpoint}
1901 echo u > /proc/sysrq-trigger
1902 echo b > /proc/sysrq-trigger
1904 panic "Not ok, a media defect is likely, switch to VT8 for details."
1910 if [ -x /scripts/local-top/cryptroot ]; then
1911 /scripts/local-top/cryptroot
1916 exec > live-boot.log
1918 tail -f live-boot.log >&7 &
1921 # Ensure 'panic' function is overridden
1922 . /scripts/live-functions
1926 maybe_break live-premount
1927 log_begin_msg "Running /scripts/live-premount"
1928 run_scripts /scripts/live-premount
1931 # Needed here too because some things (*cough* udev *cough*)
1932 # changes the timeout
1934 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1938 livefs_root="${mountpoint}"
1940 panic "Unable to find a live file system on the network"
1943 if [ -n "${ISCSI_PORTAL}" ]
1945 do_iscsi && livefs_root="${mountpoint}"
1946 elif [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1948 # Do a local boot from hd
1951 if [ -x /usr/bin/memdiskfind ]
1953 MEMDISK=$(/usr/bin/memdiskfind)
1957 # We found a memdisk, set up phram
1958 modprobe phram phram=memdisk,${MEMDISK}
1960 # Load mtdblock, the memdisk will be /dev/mtdblock0
1965 # Scan local devices for the image
1967 while [ "$i" -lt 60 ]
1969 livefs_root=$(find_livefs ${i})
1971 if [ -n "${livefs_root}" ]
1982 if [ -z "${livefs_root}" ]
1984 panic "Unable to find a medium containing a live file system"
1987 if [ "${INTEGRITY_CHECK}" ]
1989 integrity_check "${livefs_root}"
1995 elif [ "${TODISK}" ]
1997 live_dest="${TODISK}"
2000 if [ "${live_dest}" ]
2002 log_begin_msg "Copying live media to ${live_dest}"
2003 copy_live_to "${livefs_root}" "${live_dest}"
2007 # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
2008 # because the mountpoint is left behind in /proc/mounts, so let's get
2009 # rid of it when running from RAM
2010 if [ -n "$FROMISO" ] && [ "${TORAM}" ]
2012 losetup -d /dev/loop0
2013 grep -q /isofrom /proc/mounts && umount /isofrom
2016 if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
2018 setup_unionfs "${livefs_root}" "${rootmnt}"
2021 mac="$(echo ${mac} | sed 's/-//g')"
2022 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
2026 if [ -n "${ROOT_PID}" ] ; then
2027 echo "${ROOT_PID}" > "${rootmnt}"/live/root.pid
2032 # unionfs-fuse needs /dev to be bind-mounted for the duration of
2033 # live-bottom; udev's init script will take care of things after that
2034 if [ "${UNIONTYPE}" = unionfs-fuse ]
2036 mount -n -o bind /dev "${rootmnt}/dev"
2039 # Move to the new root filesystem so that programs there can get at it.
2040 if [ ! -d /root/live/image ]
2042 mkdir -p /root/live/image
2043 mount --move /live/image /root/live/image
2046 # aufs2 in kernel versions around 2.6.33 has a regression:
2047 # directories can't be accessed when read for the first the time,
2048 # causing a failure for example when accessing /var/lib/fai
2049 # when booting FAI, this simple workaround solves it
2050 ls /root/* >/dev/null 2>&1
2052 # copy snapshot configuration if exists
2053 if [ -f snapshot.conf ]
2055 log_begin_msg "Copying snapshot.conf to ${rootmnt}/etc/live/boot.d"
2056 if [ ! -d "${rootmnt}/etc/live/boot.d" ]
2058 mkdir -p "${rootmnt}/etc/live/boot.d"
2060 cp snapshot.conf "${rootmnt}/etc/live/boot.d/"
2064 if [ -f /etc/resolv.conf ] && [ ! -s ${rootmnt}/etc/resolv.conf ]
2066 log_begin_msg "Copying /etc/resolv.conf to ${rootmnt}/etc/resolv.conf"
2067 cp -v /etc/resolv.conf ${rootmnt}/etc/resolv.conf
2071 maybe_break live-bottom
2072 log_begin_msg "Running /scripts/live-bottom\n"
2074 run_scripts /scripts/live-bottom
2077 if [ "${UNIONFS}" = unionfs-fuse ]
2079 umount "${rootmnt}/dev"
2085 [ -w "${rootmnt}/var/log/" ] && cp live-boot.log "${rootmnt}/var/log/" 2>/dev/null