-
- # run-init can't deal with images in a subdir, but we're going to
- # move all of these away before it runs anyway. No, we're not,
- # put them in / since move-mounting them into / breaks mono and
- # some other apps.
-
- croot="/"
-
- # Let's just mount the read-only file systems first
- rofslist=""
-
- if [ -z "${PLAIN_ROOT}" ]
- then
- # Read image names from ${MODULE}.module if it exists
- if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
- then
- for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
- do
- image_string="${image_string} ${image_directory}/${IMAGE}"
- done
- elif [ -e "${image_directory}/${MODULE}.module" ]
- then
- for IMAGE in $(cat ${image_directory}/${MODULE}.module)
- do
- image_string="${image_string} ${image_directory}/${IMAGE}"
- done
- else
- # ${MODULE}.module does not exist, create a list of images
- for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
- do
- for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
- do
- if [ -e "${IMAGE}" ]
- then
- image_string="${image_string} ${IMAGE}"
- fi
- done
- done
-
- if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
- then
- for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
- do
- for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
- do
- if [ -e "${IMAGE}" ]
- then
- image_string="${image_string} ${IMAGE}"
- fi
- done
- done
- fi
-
- # Now sort the list
- image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
- fi
-
- [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
-
- mkdir -p "${croot}"
-
- for image in ${image_string}
- do
- imagename=$(basename "${image}")
-
- export image devname
- maybe_break live-realpremount
- log_begin_msg "Running /scripts/live-realpremount"
- run_scripts /scripts/live-realpremount
- log_end_msg
-
- if [ -d "${image}" ]
- then
- # it is a plain directory: do nothing
- rofslist="${image} ${rofslist}"
- elif [ -f "${image}" ]
- then
- if losetup --help 2>&1 | grep -q -- "-r\b"
- then
- backdev=$(get_backing_device "${image}" "-r")
- else
- backdev=$(get_backing_device "${image}")
- fi
- fstype=$(get_fstype "${backdev}")
-
- if [ "${fstype}" = "unknown" ]
- then
- panic "Unknown file system type on ${backdev} (${image})"
- fi
-
- if [ -z "${fstype}" ]
- then
- fstype="${imagename##*.}"
- log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
- fi
-
- if [ "${UNIONTYPE}" != "unionmount" ]
- then
- mpoint="${croot}/${imagename}"
- rofslist="${mpoint} ${rofslist}"
- else
- mpoint="${rootmnt}"
- rofslist="${rootmnt} ${rofslist}"
- fi
- mkdir -p "${mpoint}"
- log_begin_msg "Mounting \"${image}\" on \"${mpoint}\" via \"${backdev}\""
- mount -t "${fstype}" -o ro,noatime "${backdev}" "${mpoint}" || panic "Can not mount ${backdev} (${image}) on ${mpoint}"
- log_end_msg
- fi
- done
- else
- # we have a plain root system
- mkdir -p "${croot}/filesystem"
- log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
- mount -t $(get_fstype "${image_directory}") -o ro,noatime "${image_directory}" "${croot}/filesystem" || \
- panic "Can not mount ${image_directory} on ${croot}/filesystem" && \
- rofslist="${croot}/filesystem ${rofslist}"
- # probably broken:
- mount -o bind ${croot}/filesystem $mountpoint
- log_end_msg
- fi
-
- # tmpfs file systems
- touch /etc/fstab
- mkdir -p /live
- mount -t tmpfs tmpfs /live
- mkdir -p /live/overlay
-
- # Looking for persistence devices or files
- if [ -n "${PERSISTENCE}" ] && [ -z "${NOPERSISTENCE}" ]
- then
-
- if [ -z "${QUICKUSBMODULES}" ]
- then
- # Load USB modules
- num_block=$(ls -l /sys/block | wc -l)
- for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
- do
- modprobe -q -b ${module}
- done
-
- udevadm trigger
- udevadm settle
-
- # For some reason, udevsettle does not block in this scenario,
- # so we sleep for a little while.
- #
- # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
- for timeout in 5 4 3 2 1
- do
- sleep 1
-
- if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
- then
- break
- fi
- done
- fi
-
- case "${PERSISTENCE_MEDIA}" in
- removable)
- whitelistdev="$(removable_dev)"
- ;;
- removable-usb)
- whitelistdev="$(removable_usb_dev)"
- ;;
- *)
- whitelistdev=""
- ;;
- esac
-
- if is_in_comma_sep_list overlay ${PERSISTENCE_METHOD}
- then
- overlays="${old_root_overlay_label} ${old_home_overlay_label} ${custom_overlay_label}"
- fi
-
- if is_in_comma_sep_list snapshot ${PERSISTENCE_METHOD}
- then
- snapshots="${root_snapshot_label} ${home_snapshot_label}"
- fi
-
- local root_snapdata=""
- local home_snapdata=""
- local overlay_devices=""
- for media in $(find_persistence_media "${overlays}" "${snapshots}" "${whitelistdev}")
- do
- media="$(echo ${media} | tr ":" " ")"
- case ${media} in
- ${root_snapshot_label}=*|${old_root_snapshot_label}=*)
- if [ -z "${root_snapdata}" ]
- then
- root_snapdata="${media#*=}"
- fi
- ;;
- ${home_snapshot_label}=*)
- # This second type should be removed when snapshot will get smarter,
- # hence when "/etc/live-snapshot*list" will be supported also by
- # ext2|ext3|ext4|jffs2 snapshot types.
- if [ -z "${home_snapdata}" ]
- then
- home_snapdata="${media#*=}"
- fi
- ;;
- ${old_root_overlay_label}=*)
- device="${media#*=}"
- fix_backwards_compatibility ${device} / union
- overlay_devices="${overlay_devices} ${device}"
- ;;
- ${old_home_overlay_label}=*)
- device="${media#*=}"
- fix_backwards_compatibility ${device} /home bind
- overlay_devices="${overlay_devices} ${device}"
- ;;
- ${custom_overlay_label}=*)
- device="${media#*=}"
- overlay_devices="${overlay_devices} ${device}"
- ;;
- esac
- done
- elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENCE}" ]
- then
- # check if there are any nfs options
- if echo ${NFS_COW}|grep -q ','
- then
- nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
- nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
- else
- nfs_cow_opts="-o nolock"
- nfs_cow=${NFS_COW}
- fi
-
- if [ -n "${PERSISTENCE_READONLY}" ]
- then
- nfs_cow_opts="${nfs_cow_opts},nocto,ro"
- fi
-
- mac="$(get_mac)"
- if [ -n "${mac}" ]
- then
- cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
- cow_fstype="nfs"
- else
- panic "unable to determine mac address"
- fi
- fi
-
- if [ -z "${cowdevice}" ]
- then
- cowdevice="tmpfs"
- cow_fstype="tmpfs"
- cow_mountopt="rw,noatime,mode=755"
- fi
-
- if [ "${UNIONTYPE}" != "unionmount" ]
- then
- if [ -n "${PERSISTENCE_READONLY}" ] && [ "${cowdevice}" != "tmpfs" ]
- then
- mount -t tmpfs -o rw,noatime,mode=755 tmpfs "/live/overlay"
- root_backing="/live/persistence/$(basename ${cowdevice})-root"
- mkdir -p ${root_backing}
- else
- root_backing="/live/overlay"
- fi
-
- if [ "${cow_fstype}" = "nfs" ]
- then
- log_begin_msg \
- "Trying nfsmount ${nfs_cow_opts} ${cowdevice} ${root_backing}"
- nfsmount ${nfs_cow_opts} ${cowdevice} ${root_backing} || \
- panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on ${root_backing}"
- else
- mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} ${root_backing} || \
- panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on ${root_backing}"
- fi
- fi
-
- rofscount=$(echo ${rofslist} |wc -w)
-
- rofs=${rofslist%% }
-
- if [ -n "${EXPOSED_ROOT}" ]
- then
- if [ ${rofscount} -ne 1 ]
- then
- panic "only one RO file system supported with exposedroot: ${rofslist}"
- fi
-
- mount --bind ${rofs} ${rootmnt} || \
- panic "bind mount of ${rofs} failed"
-
- if [ -z "${SKIP_UNION_MOUNTS}" ]
- then
- cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
- else
- cow_dirs=''
- fi
- else
- cow_dirs="/"
- fi
-
- if [ "${cow_fstype}" != "tmpfs" ] && [ "${cow_dirs}" != "/" ] && [ "${UNIONTYPE}" = "unionmount" ]
- then
- true # FIXME: Maybe it does, I don't really know.
- #panic "unionmount does not support subunions (${cow_dirs})."
- fi
-
- for dir in ${cow_dirs}; do
- unionmountpoint="${rootmnt}${dir}"
- mkdir -p ${unionmountpoint}
- if [ "${UNIONTYPE}" = "unionmount" ]
- then
- # FIXME: handle PERSISTENCE_READONLY
- unionmountopts="-t ${cow_fstype} -o noatime,union,${cow_mountopt} ${cowdevice}"
- mount_full $unionmountopts "${unionmountpoint}"
- else
- cow_dir="/live/overlay${dir}"
- rofs_dir="${rofs}${dir}"
- mkdir -p ${cow_dir}
- if [ -n "${PERSISTENCE_READONLY}" ] && [ "${cowdevice}" != "tmpfs" ]
- then
- do_union ${unionmountpoint} ${cow_dir} ${root_backing} ${rofs_dir}
- else
- do_union ${unionmountpoint} ${cow_dir} ${rofs_dir}
- fi
- fi || panic "mount ${UNIONTYPE} on ${unionmountpoint} failed with option ${unionmountopts}"
- done
-
- # Correct the permissions of /:
- chmod 0755 "${rootmnt}"
-
- live_rofs_list=""
- # SHOWMOUNTS is necessary for custom mounts with the union option
- # Since we may want to do custom mounts in user-space it's best to always enable SHOWMOUNTS
- if true #[ -n "${SHOWMOUNTS}" ] || ( [ -n "${PERSISTENCE}" ] && [ -z "${NOPERSISTENCE}" ] 1)
- then
- # 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).
- for d in ${rofslist}
- do
- live_rofs="/live/rofs/${d##*/}"
- live_rofs_list="${live_rofs_list} ${live_rofs}"
- mkdir -p "${live_rofs}"
- case d in
- *.dir)
- # do nothing # mount -o bind "${d}" "${live_rofs}"
- ;;
- *)
- case "${UNIONTYPE}" in
- unionfs-fuse)
- mount -o bind "${d}" "${live_rofs}"
- ;;
- *)
- mount -o move "${d}" "${live_rofs}"
- ;;
- esac
- ;;
- esac
- done
- fi
-
- # Adding custom persistence
- if [ -n "${PERSISTENCE}" ] && [ -z "${NOPERSISTENCE}" ]
- then
- local custom_mounts="/tmp/custom_mounts.list"
- rm -rf ${custom_mounts} 2> /dev/null
-
- # Gather information about custom mounts from devies detected as overlays
- get_custom_mounts ${custom_mounts} ${overlay_devices}
-
- [ -n "${DEBUG}" ] && cp ${custom_mounts} "/live/persistence"
-
- # Now we do the actual mounting (and symlinking)
- local used_overlays=""
- used_overlays=$(activate_custom_mounts ${custom_mounts})
- rm ${custom_mounts}
-
- # Close unused overlays (e.g. due to missing $persistence_list)
- for overlay in ${overlay_devices}
- do
- if echo ${used_overlays} | grep -qve "^\(.* \)\?${device}\( .*\)\?$"
- then
- close_persistence_media ${overlay}
- fi
- done
-
- # Look for other snapshots to copy in
- [ -n "${root_snapdata}" ] && try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
- # This second type should be removed when snapshot grow smarter
- [ -n "${home_snapdata}" ] && try_snap "${home_snapdata}" "${rootmnt}" "HOME" "/home"
- fi
-
- mkdir -p "${rootmnt}/live"
- mount -o move /live "${rootmnt}/live" >/dev/null 2>&1 || mount -o bind /live "${rootmnt}/live" || log_warning_msg "Unable to move or bind /live to ${rootmnt}/live"
-
- # shows cow fs on /overlay for use by live-snapshot
- mkdir -p "${rootmnt}/live/overlay"
- mount -o move /live/overlay "${rootmnt}/live/overlay" >/dev/null 2>&1 || mount -o bind /overlay "${rootmnt}/live/overlay" || log_warning_msg "Unable to move or bind /overlay to ${rootmnt}/live/overlay"
-
-}
-
-check_dev ()
-{
- sysdev="${1}"
- devname="${2}"
- skip_uuid_check="${3}"
-
- # support for fromiso=.../isofrom=....
- if [ -n "$FROMISO" ]
- then
- ISO_DEVICE=$(dirname $FROMISO)
- if ! [ -b $ISO_DEVICE ]
- then
- # to support unusual device names like /dev/cciss/c0d0p1
- # as well we have to identify the block device name, let's
- # do that for up to 15 levels
- i=15
- while [ -n "$ISO_DEVICE" ] && [ "$i" -gt 0 ]
- do
- ISO_DEVICE=$(dirname ${ISO_DEVICE})
- [ -b "$ISO_DEVICE" ] && break
- i=$(($i -1))
- done
- fi
-
- if [ "$ISO_DEVICE" = "/" ]
- then
- echo "Warning: device for bootoption fromiso= ($FROMISO) not found.">>/boot.log
- else
- fs_type=$(get_fstype "${ISO_DEVICE}")
- if is_supported_fs ${fs_type}
- then
- mkdir /live/fromiso
- mount -t $fs_type "$ISO_DEVICE" /live/fromiso
- ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
- loopdevname=$(setup_loop "/live/fromiso/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
- devname="${loopdevname}"
- else
- echo "Warning: unable to mount $ISO_DEVICE." >>/boot.log
- fi
- fi
- fi
-
- if [ -z "${devname}" ]
- then
- devname=$(sys2dev "${sysdev}")
- fi
-
- if [ -d "${devname}" ]
- then
- mount -o bind "${devname}" $mountpoint || continue
-
- if is_live_path $mountpoint
- then
- echo $mountpoint
- return 0
- else
- umount $mountpoint
- fi
- fi
-
- IFS=","
- for device in ${devname}
- do
- case "$device" in
- *mapper*)
- # Adding lvm support
- if [ -x /scripts/local-top/lvm2 ]
- then
- ROOT="$device" resume="" /scripts/local-top/lvm2
- fi
- ;;
-
- /dev/md*)
- # Adding raid support
- if [ -x /scripts/local-top/mdadm ]
- then
- cp /conf/conf.d/md /conf/conf.d/md.orig
- echo "MD_DEVS=$device " >> /conf/conf.d/md
- /scripts/local-top/mdadm
- mv /conf/conf.d/md.orig /conf/conf.d/md
- fi
- ;;
- esac
- done
- unset IFS
-
- [ -n "$device" ] && devname="$device"
-
- [ -e "$devname" ] || continue
-
- if [ -n "${LIVE_MEDIA_OFFSET}" ]
- then
- loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
- devname="${loopdevname}"
- fi
-
- fstype=$(get_fstype "${devname}")
-
- if is_supported_fs ${fstype}
- then
- devuid=$(blkid -o value -s UUID "$devname")
- [ -n "$devuid" ] && grep -qs "\<$devuid\>" $tried && continue
- mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
- [ -n "$devuid" ] && echo "$devuid" >> $tried
-
- if [ -n "${FINDISO}" ]
- then
- if [ -f ${mountpoint}/${FINDISO} ]
- then
- umount ${mountpoint}
- mkdir -p /live/findiso
- mount -t ${fstype} -o ro,noatime "${devname}" /live/findiso
- loopdevname=$(setup_loop "/live/findiso/${FINDISO}" "loop" "/sys/block/loop*" 0 "")
- devname="${loopdevname}"
- mount -t iso9660 -o ro,noatime "${devname}" ${mountpoint}
- else
- umount ${mountpoint}
- fi
- fi
-
- if is_live_path ${mountpoint} && \
- ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
- then
- echo ${mountpoint}
- return 0
- else
- umount ${mountpoint} 2>/dev/null
- fi
- fi
-
- if [ -n "${LIVE_MEDIA_OFFSET}" ]
- then
- losetup -d "${loopdevname}"
- fi
-
- return 1
-}
-
-find_livefs ()
-{
- timeout="${1}"
-
- # don't start autodetection before timeout has expired
- if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
- then
- if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
- then
- return 1
- fi
- fi
-
- # first look at the one specified in the command line
- case "${LIVE_MEDIA}" in
- removable-usb)
- for sysblock in $(removable_usb_dev "sys")
- do
- for dev in $(subdevices "${sysblock}")
- do
- if check_dev "${dev}"
- then
- return 0
- fi
- done
- done
- return 1
- ;;
-
- removable)
- for sysblock in $(removable_dev "sys")
- do
- for dev in $(subdevices "${sysblock}")
- do
- if check_dev "${dev}"
- then
- return 0
- fi
- done
- done
- return 1
- ;;
-
- *)
- if [ ! -z "${LIVE_MEDIA}" ]
- then
- if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
- then
- return 0
- fi
- fi
- ;;
- esac
-
- # or do the scan of block devices
- # prefer removable devices over non-removable devices, so scan them first
- devices_to_scan="$(removable_dev 'sys') $(non_removable_dev 'sys')"
-
- for sysblock in $devices_to_scan
- do
- devname=$(sys2dev "${sysblock}")
- [ -e "$devname" ] || continue
- fstype=$(get_fstype "${devname}")
-
- if /lib/udev/cdrom_id ${devname} > /dev/null
- then
- if check_dev "null" "${devname}"
- then
- return 0
- fi
- elif is_nice_device "${sysblock}"
- then
- for dev in $(subdevices "${sysblock}")
- do
- if check_dev "${dev}"
- then
- return 0
- fi
- done
- elif [ "${fstype}" = "squashfs" -o \
- "${fstype}" = "btrfs" -o \
- "${fstype}" = "ext2" -o \
- "${fstype}" = "ext3" -o \
- "${fstype}" = "ext4" -o \
- "${fstype}" = "jffs2" ]
- then
- # This is an ugly hack situation, the block device has
- # an image directly on it. It's hopefully
- # live-boot, so take it and run with it.
- ln -s "${devname}" "${devname}.${fstype}"
- echo "${devname}.${fstype}"
- return 0
- fi
- done
-
- return 1
-}
-
-integrity_check ()
-{
- media_mountpoint="${1}"
-
- log_begin_msg "Checking media integrity"
-
- cd ${media_mountpoint}
- /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
- RC="${?}"
-
- log_end_msg
-
- if [ "${RC}" -eq 0 ]
- then
- log_success_msg "Everything ok, will reboot in 10 seconds."
- sleep 10
- cd /
- umount ${media_mountpoint}
- sync
- echo u > /proc/sysrq-trigger
- echo b > /proc/sysrq-trigger
- else
- panic "Not ok, a media defect is likely, switch to VT8 for details."
- fi
-}
-
-mountroot ()
-{
- if [ -x /scripts/local-top/cryptroot ]; then
- /scripts/local-top/cryptroot
- fi
-
- exec 6>&1
- exec 7>&2
- exec > boot.log
- exec 2>&1
- tail -f boot.log >&7 &
- tailpid="${!}"
-
- # Ensure 'panic' function is overridden
- . /scripts/live-functions
-
- Arguments
-
- maybe_break live-premount
- log_begin_msg "Running /scripts/live-premount"
- run_scripts /scripts/live-premount
- log_end_msg
-
- # Needed here too because some things (*cough* udev *cough*)
- # changes the timeout
-
- if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
- then
- if do_netmount
- then
- livefs_root="${mountpoint}"
- else
- panic "Unable to find a live file system on the network"
- fi
- else
- if [ -n "${ISCSI_PORTAL}" ]
- then
- do_iscsi && livefs_root="${mountpoint}"
- elif [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
- then
- # Do a local boot from hd
- livefs_root=${ROOT}
- else
- if [ -x /usr/bin/memdiskfind ]
- then
- MEMDISK=$(/usr/bin/memdiskfind)
-
- if [ $? -eq 0 ]
- then
- # We found a memdisk, set up phram
- modprobe phram phram=memdisk,${MEMDISK}
-
- # Load mtdblock, the memdisk will be /dev/mtdblock0
- modprobe mtdblock
- fi
- fi
-
- # Scan local devices for the image
- i=0
- while [ "$i" -lt 60 ]
- do
- livefs_root=$(find_livefs ${i})
-
- if [ -n "${livefs_root}" ]
- then
- break
- fi
-
- sleep 1
- i="$(($i + 1))"
- done
- fi
- fi
-
- if [ -z "${livefs_root}" ]
- then
- panic "Unable to find a medium containing a live file system"
- fi
-
- if [ "${INTEGRITY_CHECK}" ]
- then
- integrity_check "${livefs_root}"
- fi
-
- if [ "${TORAM}" ]
- then
- live_dest="ram"
- elif [ "${TODISK}" ]
- then
- live_dest="${TODISK}"
- fi
-
- if [ "${live_dest}" ]
- then
- log_begin_msg "Copying live media to ${live_dest}"
- copy_live_to "${livefs_root}" "${live_dest}"
- log_end_msg
- fi
-
- # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
- # because the mountpoint is left behind in /proc/mounts, so let's get
- # rid of it when running from RAM
- if [ -n "$FROMISO" ] && [ "${TORAM}" ]
- then
- losetup -d /dev/loop0
-
- if is_mountpoint /live/fromiso
- then
- umount /live/fromiso
- rmdir --ignore-fail-on-non-empty /live/fromiso \
- >/dev/null 2>&1 || true
- fi
- fi
-
- if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
- then
- setup_unionfs "${livefs_root}" "${rootmnt}"
- else
- mac="$(get_mac)"
- mac="$(echo ${mac} | sed 's/-//g')"
- mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
- fi
-
-
- if [ -n "${ROOT_PID}" ] ; then
- echo "${ROOT_PID}" > "${rootmnt}"/live/root.pid
- fi
-
- log_end_msg
-
- # unionfs-fuse needs /dev to be bind-mounted for the duration of
- # live-bottom; udev's init script will take care of things after that
- if [ "${UNIONTYPE}" = unionfs-fuse ]
- then
- mount -n -o bind /dev "${rootmnt}/dev"
- fi
-
- # Move to the new root filesystem so that programs there can get at it.
- if [ ! -d /root/live/image ]
- then
- mkdir -p /root/live/image
- mount --move /live/image /root/live/image
- fi
-
- # aufs2 in kernel versions around 2.6.33 has a regression:
- # directories can't be accessed when read for the first the time,
- # causing a failure for example when accessing /var/lib/fai
- # when booting FAI, this simple workaround solves it
- ls /root/* >/dev/null 2>&1
-
- # Move findiso directory to the new root filesystem so that programs there can get at it.
- if [ -d /live/findiso ] && [ ! -d /root/live/findiso ]
- then
- mkdir -p /root/live/findiso
- mount -n --move /live/findiso /root/live/findiso
- fi
-
- # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
- # because the mountpoint is left behind in /proc/mounts, so let's get
- # rid of it when running from RAM
- if [ -n "$FINDISO" ] && [ "${TORAM}" ]
- then
- losetup -d /dev/loop0
-
- if is_mountpoint /root/live/findiso
- then
- umount /root/live/findiso
- rmdir --ignore-fail-on-non-empty /root/live/findiso \
- >/dev/null 2>&1 || true
- fi
- fi
-
- # copy snapshot configuration if exists
- if [ -f snapshot.conf ]
- then
- log_begin_msg "Copying snapshot.conf to ${rootmnt}/etc/live/boot.d"
- if [ ! -d "${rootmnt}/etc/live/boot.d" ]
- then
- mkdir -p "${rootmnt}/etc/live/boot.d"
- fi
- cp snapshot.conf "${rootmnt}/etc/live/boot.d/"
- log_end_msg
- fi
-
- if [ -f /etc/resolv.conf ] && [ ! -s ${rootmnt}/etc/resolv.conf ]
- then
- log_begin_msg "Copying /etc/resolv.conf to ${rootmnt}/etc/resolv.conf"
- cp -v /etc/resolv.conf ${rootmnt}/etc/resolv.conf
- log_end_msg
- fi
-
- maybe_break live-bottom
- log_begin_msg "Running /scripts/live-bottom\n"
-
- run_scripts /scripts/live-bottom
- log_end_msg
-
- if [ "${UNIONFS}" = unionfs-fuse ]
- then
- umount "${rootmnt}/dev"
- fi
-
- exec 1>&6 6>&-
- exec 2>&7 7>&-
- kill ${tailpid}
- [ -w "${rootmnt}/var/log/" ] && mkdir -p /var/log/live && cp boot.log "${rootmnt}/var/log/live" 2>/dev/null
-}