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=}"
248 PERSISTENT="${ARGUMENT#persistent=}"
249 if [ -z "${PERSISTENT}" ]
257 PERSISTENT_MEDIA="${ARGUMENT#*=}"
258 export PERSISTENT_MEDIA
262 PERSISTENT_PATH="${ARGUMENT#persistent-path=}"
263 export PERSISTENT_PATH
266 persistent-subtext=*)
267 root_persistence="${root_persistence}-${ARGUMENT#persistent-subtext=}"
268 home_persistence="${home_persistence}-${ARGUMENT#persistent-subtext=}"
269 root_snapshot_label="${root_snapshot_label}-${ARGUMENT#persistent-subtext=}"
270 home_snapshot_label="${home_snapshot_label}-${ARGUMENT#persistent-subtext=}"
284 NOPROMPT="${ARGUMENT#noprompt=}"
289 QUICKUSBMODULES="Yes"
290 export QUICKUSBMODULES
293 preseed/file=*|file=*)
294 LOCATIONS="${ARGUMENT#*=} ${LOCATIONS}"
304 question="${ARGUMENT%%=*}"
305 value="${ARGUMENT#*=}"
306 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
321 TODISK="${ARGUMENT#todisk=}"
332 MODULETORAM="${ARGUMENT#toram=}"
333 export TORAM MODULETORAM
347 SKIP_UNION_MOUNTS="Yes"
348 export SKIP_UNION_MOUNTS
352 ROOT="${ARGUMENT#root=}"
357 UNIONTYPE="${ARGUMENT#union=}"
363 # sort of compatibility with netboot.h from linux docs
364 if [ -z "${NETBOOT}" ]
366 if [ "${ROOT}" = "/dev/nfs" ]
370 elif [ "${ROOT}" = "/dev/cifs" ]
377 if [ -z "${MODULE}" ]
383 if [ -z "${UNIONTYPE}" ]
394 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
396 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs dir jffs2
398 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
410 if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
416 uuid="$(cat /conf/uuid.conf)"
418 for try_uuid_file in "${path}/.disk/live-uuid"*
420 [ -e "${try_uuid_file}" ] || continue
422 try_uuid="$(cat "${try_uuid_file}")"
424 if [ "${uuid}" = "${try_uuid}" ]
433 get_backing_device ()
436 *.squashfs|*.ext2|*.ext3|*.ext4|*.jffs2)
437 echo $(setup_loop "${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
445 panic "Unrecognized live filesystem: ${1}"
450 match_files_in_dir ()
452 # Does any files match pattern ${1} ?
455 if [ "$(echo ${pattern})" != "${pattern}" ]
463 mount_images_in_directory ()
470 if match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
471 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
472 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
473 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
474 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
475 match_files_in_dir "${directory}/${LIVE_MEDIA_PATH}/*.dir"
477 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
478 setup_unionfs "${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
480 panic "No supported filesystem images found at /${LIVE_MEDIA_PATH}."
486 sysfs_path="${1#/sys}"
488 if [ -e /lib/udev/path_id ]
491 PATH_ID="/lib/udev/path_id"
493 # wheezy/sid (udev >= 174)
494 PATH_ID="/sbin/udevadm test-builtin path_id"
497 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)"
500 elif echo "${sysfs_path}" | grep -q '^/block/vd[a-z]$'
503 elif echo ${sysfs_path} | grep -q "^/block/dm-"
506 elif echo ${sysfs_path} | grep -q "^/block/mtdblock"
518 copyto="${copyfrom}_swap"
520 if [ -z "${MODULETORAM}" ]
522 size=$(fs_size "" ${copyfrom}/${LIVE_MEDIA_PATH} "used")
524 MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
526 if [ -f "${MODULETORAMFILE}" ]
528 size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
530 log_warning_msg "Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
535 if [ "${copytodev}" = "ram" ]
538 freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
539 mount_options="-o size=${size}k"
544 # it should be a writable block device
545 if [ -b "${copytodev}" ]
549 fstype=$(get_fstype "${dev}")
550 freespace=$(fs_size "${dev}")
552 log_warning_msg "${copytodev} is not a block device."
557 if [ "${freespace}" -lt "${size}" ]
559 log_warning_msg "Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
563 # Custom ramdisk size
564 if [ -z "${mount_options}" ] && [ -n "${ramdisk_size}" ]
566 # FIXME: should check for wrong values
567 mount_options="-o size=${ramdisk_size}"
570 # begin copying (or uncompressing)
572 log_begin_msg "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
573 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
575 if [ "${extension}" = "tgz" ]
578 tar zxf "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
579 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
580 mount -r -o move "${copyto}" "${rootmnt}"
583 if [ -n "${MODULETORAMFILE}" ]
587 echo " * Copying $MODULETORAMFILE to RAM" 1>/dev/console
588 rsync -a --progress ${MODULETORAMFILE} ${copyto} 1>/dev/console # copy only the filesystem module
590 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
595 echo " * Copying whole medium to RAM" 1>/dev/console
596 rsync -a --progress ${copyfrom}/* ${copyto} 1>/dev/console # "cp -a" from busybox also copies hidden files
598 mkdir -p ${copyto}/${LIVE_MEDIA_PATH}
599 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH}
600 if [ -e ${copyfrom}/${LIVE_MEDIA_PATH}/.disk ]
602 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/.disk ${copyto}
608 mount -r -o move ${copyto} ${copyfrom}
617 modprobe -q af_packet # For DHCP
622 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
623 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
625 if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
626 [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
630 # support for Syslinux IPAPPEND parameter
631 # it sets the BOOTIF variable on the kernel parameter
633 if [ -n "${BOOTIF}" ]
635 # pxelinux sets BOOTIF to a value based on the mac address of the
636 # network card used to PXE boot, so use this value for DEVICE rather
637 # than a hard-coded device name from initramfs.conf. this facilitates
638 # network booting when machines may have multiple network cards.
639 # pxelinux sets BOOTIF to 01-$mac_address
641 # strip off the leading "01-", which isn't part of the mac
643 temp_mac=${BOOTIF#*-}
645 # convert to typical mac address format by replacing "-" with ":"
650 if [ -z "$bootif_mac" ]
654 bootif_mac="$bootif_mac:$x"
659 # look for devices with matching mac address, and set DEVICE to
660 # appropriate value if match is found.
662 for device in /sys/class/net/*
664 if [ -f "$device/address" ]
666 current_mac=$(cat "$device/address")
668 if [ "$bootif_mac" = "$current_mac" ]
677 # if ethdevice was not specified on the kernel command line
678 # make sure we try to get a working network configuration
679 # for *every* present network device (except for loopback of course)
680 if [ -z "$ETHDEVICE" ] ; then
681 echo "If you want to boot from a specific device use bootoption ethdevice=..."
682 for device in /sys/class/net/*; do
684 if [ "$dev" != "lo" ] ; then
685 ETHDEVICE="$ETHDEVICE $dev"
690 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
691 for device in $(echo $ETHDEVICE | sed 's/,/ /g') ; do
692 devlist="$devlist $device"
695 # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
696 # an endless loop; iff execution fails give it two further tries, that's
697 # why we use '$devlist $devlist $devlist' for the other for loop
698 for dev in $devlist $devlist $devlist ; do
699 echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
700 ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
702 sleep "$ETHDEV_TIMEOUT" ; sleep 1
703 if [ -r /proc/"$jobid"/status ] ; then
704 echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
708 # if configuration of device worked we should have an assigned
709 # IP address, iff so let's use the according as $DEVICE for later usage
710 # simple and primitive approach which seems to work fine
711 if ifconfig $dev | grep -q 'inet.*addr:' ; then
718 for interface in ${DEVICE}; do
719 ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
720 [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
721 if [ "$IPV4ADDR" != "0.0.0.0" ]
728 for interface in ${DEVICE}; do
729 # source relevant ipconfig output
730 OLDHOSTNAME=${HOSTNAME}
731 [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
732 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
735 if [ -n "${interface}" ]
737 HWADDR="$(cat /sys/class/net/${interface}/address)"
740 if [ ! -e "/etc/resolv.conf" ]
742 echo "Creating /etc/resolv.conf"
744 if [ -n "${DNSDOMAIN}" ]
746 echo "domain ${DNSDOMAIN}" > /etc/resolv.conf
747 echo "search ${DNSDOMAIN}" >> /etc/resolv.conf
750 for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1}
752 if [ -n "$i" ] && [ "$i" != 0.0.0.0 ]
754 echo "nameserver $i" >> /etc/resolv.conf
759 # Check if we have a network device at all
760 if ! ls /sys/class/net/"$interface" > /dev/null 2>&1 && \
761 ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
762 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
763 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
764 ! ls /sys/class/net/ra0 > /dev/null 2>&1
766 panic "No supported network device found, maybe a non-mainline driver is required."
775 if [ "${NFSROOT}" = "auto" ]
777 NFSROOT=${ROOTSERVER}:${ROOTPATH}
782 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] )
788 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
790 NFSROOT=${ROOTSERVER}:${NFSROOT}
793 log_begin_msg "Trying netboot from ${NFSROOT}"
795 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
815 [ "${DEBUG}" == "Yes" ] && debugopt="-d 8"
816 #FIXME this name is supposed to be unique - some date + ifconfig hash?
817 ISCSI_INITIATORNAME="iqn.1993-08.org.debian.live:01:$(echo "${HWADDR}" | sed -e s/://g)"
818 export ISCSI_INITIATORNAME
819 if [ -n "${ISCSI_SERVER}" ] ; then
820 iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_SERVER}" -p "${ISCSI_PORT}"
822 iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_PORTAL}" -p 3260
826 panic "Failed to log into iscsi target"
828 local host="$(ls -d /sys/class/scsi_host/host*/device/iscsi_host:host* \
829 /sys/class/scsi_host/host*/device/iscsi_host/host* | sed -e 's:/device.*::' -e 's:.*host::')"
834 while [ -z "${devices}" -a $i -lt 60 ]
837 devices="$(ls -d /sys/class/scsi_device/${host}*/device/block:* \
838 /sys/class/scsi_device/${host}*/device/block/* | sed -e 's!.*[:/]!!')"
844 if check_dev "null" "/dev/$dev"
851 panic "Failed to locate a live device on iSCSI devices (tried: $devices)."
853 panic "Failed to locate iSCSI host in /sys"
861 for webfile in HTTPFS FTPFS FETCH
863 local url="$(eval echo \"\$\{${webfile}\}\")"
864 local extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
868 case "${extension}" in
869 iso|squashfs|tgz|tar)
870 if [ "${extension}" = "iso" ]
872 mkdir -p "${alt_mountpoint}"
873 dest="${alt_mountpoint}"
875 local dest="${mountpoint}/${LIVE_MEDIA_PATH}"
876 mount -t ramfs ram "${mountpoint}"
879 if [ "${webfile}" = "FETCH" ]
883 ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
884 rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
885 lfile="$(basename $url)"
886 log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
887 tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
891 log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
892 wget "${url}" -O "${dest}/$(basename ${url})"
896 log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
897 if [ "${webfile}" = "FTPFS" ]
899 FUSE_MOUNT="curlftpfs"
900 url="$(dirname ${url})"
905 $FUSE_MOUNT "${url}" "${dest}"
906 ROOT_PID="$(minips h -C "$FUSE_MOUNT" | { read x y ; echo "$x" ; } )"
908 [ ${?} -eq 0 ] && rc=0
909 [ "${extension}" = "tgz" ] && live_dest="ram"
910 if [ "${extension}" = "iso" ]
912 isoloop=$(setup_loop "${dest}/$(basename "${url}")" "loop" "/sys/block/loop*" "" '')
913 mount -t iso9660 "${isoloop}" "${mountpoint}"
920 log_begin_msg "Unrecognized archive extension for ${url}"
928 if [ -d "${alt_mountpoint}" ]
930 umount "${alt_mountpoint}"
931 rmdir "${alt_mountpoint}"
933 umount "${mountpoint}"
934 elif [ "${webfile}" != "FETCH" ] ; then
948 if [ -z "${NFSOPTS}" ]
953 log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
955 # FIXME: This while loop is an ugly HACK round an nfs bug
957 while [ "$i" -lt 60 ]
959 nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
971 if [ -x "/sbin/mount.cifs" ]
973 if [ -z "${NFSOPTS}" ]
975 CIFSOPTS="-ouser=root,password="
977 CIFSOPTS="${NFSOPTS}"
980 log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
983 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
997 size=$(fs_size "${fromdev}" "" "used")
999 if [ -b "${fromdev}" ]
1001 log_success_msg "Copying snapshot ${fromdev} to ${todir}..."
1004 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
1006 todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
1007 freespace=$(df -k | awk '/'${todev}'/{print $4}')
1009 freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
1012 tomount="/mnt/tmpsnap"
1014 if [ ! -d "${tomount}" ]
1016 mkdir -p "${tomount}"
1019 fstype=$(get_fstype "${fromdev}")
1021 if [ -n "${fstype}" ]
1024 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
1025 cp -a "${tomount}"/* ${todir}
1028 log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}"
1033 if echo ${fromdev} | grep -qs loop
1035 losetup -d "${fromdev}"
1040 log_warning_msg "Unable to find the snapshot ${snap_type} medium"
1047 # Look for ${snap_label}.* in block devices
1049 black_listed_devices="${2}"
1050 white_listed_devices="${3}"
1052 if [ "${PERSISTENT}" != "nofiles" ]
1054 # search for image files
1055 snapdata=$(find_files "${PERSISTENT_PATH}${snap_label}.squashfs ${PERSISTENT_PATH}${snap_label}.cpio.gz ${PERSISTENT_PATH}${snap_label}.ext2 ${PERSISTENT_PATH}${snap_label}.ext3 ${PERSISTENT_PATH}${snap_label}.ext4 ${PERSISTENT_PATH}${snap_label}.jffs2" "${black_listed_devices}" "${white_listed_devices}")
1058 if [ -z "${snapdata}" ]
1060 snapdata=$(find_cow_device "${snap_label}" "${black_listed_devices}" "${white_listed_devices}")
1067 # copy the contents of previously found snapshot to ${snap_mount}
1068 # and remember the device and filename for resync on exit in live-boot.init
1075 if [ -z "${snap_relpath}" ]
1077 # root snapshot, default usage
1080 # relative snapshot (actually used just for "/home" snapshots)
1081 snap_mount="${2}${snap_relpath}"
1084 if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
1086 log_success_msg "found snapshot: ${snapdata}"
1087 snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
1088 snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
1089 snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
1091 if ! try_mount "${snapdev}" "${snapback}" "ro"
1098 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
1100 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
1101 dev=$(get_backing_device "${snapback}/${snapfile}")
1103 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1108 # Unfortunately klibc's cpio is incompatible with the
1109 # rest of the world; everything else requires -u -d,
1110 # while klibc doesn't implement them. Try to detect
1111 # whether it's in use.
1112 cpiopath="$(which cpio)" || true
1113 if [ "$cpiopath" ] && grep -aq /lib/klibc "$cpiopath"
1117 cpioargs='--unconditional --make-directories'
1120 if [ -s "${snapback}/${snapfile}" ]
1123 cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | $cpiopath $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null
1127 log_warning_msg "${snapback}/${snapfile} is empty, adding it for sync on reboot."
1131 if [ "${RES}" != "0" ]
1133 log_warning_msg "failure to \"zcat ${snapback}/${snapfile} | $cpiopath $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse\""
1137 umount "${snapback}" || log_warning_msg "failure to \"umount ${snapback}\""
1139 if [ "${RES}" != "0" ]
1141 log_warning_msg "Impossible to include the ${snapfile} Snapshot file"
1144 elif [ -b "${snapdata}" ]
1146 # Try to find if it could be a snapshot partition
1148 log_success_msg "found snapshot ${snap_type} device on ${dev}"
1149 if echo "${dev}" | grep -qs loop
1151 # strange things happens, user confused?
1152 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
1153 snapfile=$(basename ${snaploop})
1154 snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
1159 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1161 log_warning_msg "Impossible to include the ${snap_type} Snapshot (i)"
1164 if [ -n "${snapfile}" ]
1166 # it was a loop device, user confused
1171 log_warning_msg "Impossible to include the ${snap_type} Snapshot (o)"
1175 echo "export ${snap_type}SNAP=${snap_relpath}:${snapdev}:${snapfile}" >> snapshot.conf # for resync on reboot/halt
1181 image_directory="${1}"
1183 addimage_directory="${3}"
1185 case ${UNIONTYPE} in
1187 modprobe -q -b ${UNIONTYPE}
1189 if ! cut -f2 /proc/filesystems | grep -q "^${UNIONTYPE}\$" && [ -x /bin/unionfs-fuse ]
1191 echo "${UNIONTYPE} not available, falling back to unionfs-fuse."
1192 echo "This might be really slow."
1194 UNIONTYPE="unionfs-fuse"
1199 if [ "${UNIONTYPE}" = unionfs-fuse ]
1204 # run-init can't deal with images in a subdir, but we're going to
1205 # move all of these away before it runs anyway. No, we're not,
1206 # put them in / since move-mounting them into / breaks mono and
1211 # Let's just mount the read-only file systems first
1214 if [ "${UNIONTYPE}" = "aufs" ]
1217 noxino_opt="noxino,"
1218 elif [ "${UNIONTYPE}" = "unionfs-fuse" ]
1225 if [ -z "${PLAIN_ROOT}" ]
1227 # Read image names from ${MODULE}.module if it exists
1228 if [ -e "${image_directory}/filesystem.${MODULE}.module" ]
1230 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1232 image_string="${image_string} ${image_directory}/${IMAGE}"
1234 elif [ -e "${image_directory}/${MODULE}.module" ]
1236 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1238 image_string="${image_string} ${image_directory}/${IMAGE}"
1241 # ${MODULE}.module does not exist, create a list of images
1242 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1244 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1246 if [ -e "${IMAGE}" ]
1248 image_string="${image_string} ${IMAGE}"
1253 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1255 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1257 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1259 if [ -e "${IMAGE}" ]
1261 image_string="${image_string} ${IMAGE}"
1268 image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
1271 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1275 for image in ${image_string}
1277 imagename=$(basename "${image}")
1279 export image devname
1280 maybe_break live-realpremount
1281 log_begin_msg "Running /scripts/live-realpremount"
1282 run_scripts /scripts/live-realpremount
1285 if [ -d "${image}" ]
1287 # it is a plain directory: do nothing
1288 rofslist="${image} ${rofslist}"
1289 elif [ -f "${image}" ]
1291 if losetup --help 2>&1 | grep -q -- "-r\b"
1293 backdev=$(get_backing_device "${image}" "-r")
1295 backdev=$(get_backing_device "${image}")
1297 fstype=$(get_fstype "${backdev}")
1299 if [ "${fstype}" = "unknown" ]
1301 panic "Unknown file system type on ${backdev} (${image})"
1304 if [ -z "${fstype}" ]
1306 fstype="${imagename##*.}"
1307 log_warning_msg "Unknown file system type on ${backdev} (${image}), assuming ${fstype}."
1310 if [ "${UNIONTYPE}" != "unionmount" ]
1312 mpoint="${croot}/${imagename}"
1313 rofslist="${mpoint} ${rofslist}"
1316 rofslist="${rootmnt} ${rofslist}"
1318 mkdir -p "${mpoint}"
1319 log_begin_msg "Mounting \"${image}\" on \"${mpoint}\" via \"${backdev}\""
1320 mount -t "${fstype}" -o ro,noatime "${backdev}" "${mpoint}" || panic "Can not mount ${backdev} (${image}) on ${mpoint}"
1325 # we have a plain root system
1326 mkdir -p "${croot}/filesystem"
1327 log_begin_msg "Mounting \"${image_directory}\" on \"${croot}/filesystem\""
1328 mount -t $(get_fstype "${image_directory}") -o ro,noatime "${image_directory}" "${croot}/filesystem" || \
1329 panic "Can not mount ${image_directory} on ${croot}/filesystem" && \
1330 rofslist="${croot}/filesystem ${rofslist}"
1332 mount -o bind ${croot}/filesystem $mountpoint
1338 # Looking for "${root_persistence}" device or file
1339 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1342 if [ -z "${QUICKUSBMODULES}" ]
1345 num_block=$(ls -l /sys/block | wc -l)
1346 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1348 modprobe -q -b ${module}
1354 # For some reason, udevsettle does not block in this scenario,
1355 # so we sleep for a little while.
1357 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1358 for timeout in 5 4 3 2 1
1362 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1369 case "${PERSISTENT_MEDIA}" in
1371 whitelistdev="$(removable_dev)"
1374 whitelistdev="$(removable_usb_dev)"
1381 # search for label and files (this could be hugely optimized)
1382 cowprobe=$(find_cow_device "${root_persistence}" "${blacklistdev}" "${whitelistdev}")
1383 if [ -b "${cowprobe}" ]
1385 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1386 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1387 # snapshots to be sure to really store some e.g key config files,
1388 # but not on the same media
1389 blacklistdev="${cowprobe}"
1390 PERSISTENCE_IS_ON="1"
1391 export PERSISTENCE_IS_ON
1393 # homecow just mount something on /home, this should be generalized some way
1394 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}" "${whitelistdev}")
1395 if [ -b "${homecow}" ]
1397 PERSISTENCE_IS_ON="1"
1398 export PERSISTENCE_IS_ON
1400 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}" "${whitelistdev}")
1401 # This second type should be removed when snapshot will get smarter,
1402 # hence when "/etc/live-snapshot*list" will be supported also by
1403 # ext2|ext3|ext4|jffs2 snapshot types.
1404 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}" "${whitelistdev}")
1406 if [ -b "${cowprobe}" ]
1408 cowdevice=${cowprobe}
1409 cow_fstype=$(get_fstype "${cowprobe}")
1410 cow_mountopt="rw,noatime"
1412 if [ "${FORCEPERSISTENTFSCK}" = "Yes" ]
1414 fsck -y ${cowdevice}
1417 log_warning_msg "Unable to find the persistent medium"
1420 cow_mountopt="rw,noatime,mode=755"
1422 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1424 # check if there are any nfs options
1425 if echo ${NFS_COW}|grep -q ','
1427 nfs_cow_opts="-o nolock,$(echo ${NFS_COW}|cut -d, -f2-)"
1428 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1430 nfs_cow_opts="-o nolock"
1436 cowdevice=$(echo ${nfs_cow}|sed "s/client_mac_address/${mac}/")
1439 panic "unable to determine mac address"
1444 cow_mountopt="rw,noatime,mode=755"
1447 if [ "${UNIONTYPE}" != "unionmount" ]
1450 if [ "${cow_fstype}" = "nfs" ]
1453 "Trying nfsmount ${nfs_cow_opts} ${cowdevice} /cow"
1454 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1455 panic "Can not mount ${cowdevice} (n: ${cow_fstype}) on /cow"
1457 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1458 panic "Can not mount ${cowdevice} (o: ${cow_fstype}) on /cow"
1462 rofscount=$(echo ${rofslist} |wc -w)
1464 if [ ${rofscount} -ne 1 ]
1466 panic "only one RO file system supported with exposedroot: ${rofslist}"
1470 if [ -n "${EXPOSED_ROOT}" ]
1472 mount --bind ${rofs} ${rootmnt} || \
1473 panic "bind mount of ${rofs} failed"
1475 if [ -z "${SKIP_UNION_MOUNTS}" ]
1477 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1485 if [ "${cow_fstype}" != "tmpfs" ] && [ "${cow_dirs}" != "/" ] && [ "${UNIONTYPE}" = "unionmount" ]
1487 true # FIXME: Maybe it does, I don't really know.
1488 #panic "unionmount does not support subunions (${cow_dirs})."
1494 for dir in ${cow_dirs}; do
1497 unionmountpoint="${rootmnt}${dir}"
1498 unionrw="/cow${dir}"
1499 unionro="${rofs}${dir}"
1500 # We don't handle spaces and other junk gracefully here, hopefully not needed.
1501 case "${UNIONTYPE}" in
1503 unionmountopts="-o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid"
1504 unionmountopts="${unionmountopts} ${unionrw}=RW:${unionro}=RO"
1505 ( sysctl -w fs.file-max=391524 ; ulimit -HSn 16384
1506 unionfs-fuse ${unionmountopts} "${unionmountpoint}" ) && \
1507 ( mkdir -p /run/sendsigs.omit.d
1508 pidof unionfs-fuse >> /run/sendsigs.omit.d/unionfs-fuse || true )
1512 unionmountopts="-t ${cow_fstype} -o noatime,union,${cow_mountopt} ${cowdevice}"
1513 mount_full $unionmountopts "${unionmountpoint}"
1518 unionmountopts="-o noatime,${noxino_opt}dirs=${unionrw}=rw:${unionro}=${roopt}"
1519 mount -t ${UNIONTYPE} ${unionmountopts} ${UNIONTYPE} "${unionmountpoint}"
1522 panic "mount ${UNIONTYPE} on ${unionmountpoint} failed with option ${unionmountopts}"
1525 # Correct the permissions of /:
1526 chmod 0755 "${rootmnt}"
1528 # tmpfs file systems
1530 mkdir -p "${rootmnt}/live"
1531 mount -t tmpfs tmpfs ${rootmnt}/live
1533 # Adding other custom mounts
1534 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1536 # directly mount /home
1537 # FIXME: add a custom mounts configurable system
1539 if [ -b "${homecow}" ]
1541 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home"
1542 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1544 log_warning_msg "Unable to find the persistent home medium"
1547 # Look for other snapshots to copy in
1548 try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
1549 # This second type should be removed when snapshot grow smarter
1550 try_snap "${home_snapdata}" "${rootmnt}" "HOME" "/home"
1553 if [ -n "${SHOWMOUNTS}" ]
1555 for d in ${rofslist}
1557 mkdir -p "${rootmnt}/live/${d##*/}"
1561 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1565 case "${UNIONTYPE}" in
1567 mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1571 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1579 # shows cow fs on /cow for use by live-snapshot
1580 mkdir -p "${rootmnt}/live/cow"
1581 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"
1588 skip_uuid_check="${3}"
1590 # support for fromiso=.../isofrom=....
1591 if [ -n "$FROMISO" ]
1593 ISO_DEVICE=$(dirname $FROMISO)
1594 if ! [ -b $ISO_DEVICE ]
1596 # to support unusual device names like /dev/cciss/c0d0p1
1597 # as well we have to identify the block device name, let's
1598 # do that for up to 15 levels
1600 while [ -n "$ISO_DEVICE" ] && [ "$i" -gt 0 ]
1602 ISO_DEVICE=$(dirname ${ISO_DEVICE})
1603 [ -b "$ISO_DEVICE" ] && break
1608 if [ "$ISO_DEVICE" = "/" ]
1610 echo "Warning: device for bootoption isofrom= ($FROMISO) not found.">>/live-boot.log
1612 fs_type=$(get_fstype "${ISO_DEVICE}")
1613 if is_supported_fs ${fs_type}
1616 mount -t $fs_type "$ISO_DEVICE" /isofrom
1617 ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
1618 loopdevname=$(setup_loop "/isofrom/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
1619 devname="${loopdevname}"
1621 echo "Warning: unable to mount $ISO_DEVICE." >>/live-boot.log
1626 if [ -z "${devname}" ]
1628 devname=$(sys2dev "${sysdev}")
1631 if [ -d "${devname}" ]
1633 mount -o bind "${devname}" $mountpoint || continue
1635 if is_live_path $mountpoint
1645 for device in ${devname}
1649 # Adding lvm support
1650 if [ -x /scripts/local-top/lvm2 ]
1652 ROOT="$device" resume="" /scripts/local-top/lvm2
1657 # Adding raid support
1658 if [ -x /scripts/local-top/mdadm ]
1660 cp /conf/conf.d/md /conf/conf.d/md.orig
1661 echo "MD_DEVS=$device " >> /conf/conf.d/md
1662 /scripts/local-top/mdadm
1663 mv /conf/conf.d/md.orig /conf/conf.d/md
1670 [ -n "$device" ] && devname="$device"
1672 [ -e "$devname" ] || continue
1674 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1676 loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVE_MEDIA_OFFSET}" '')
1677 devname="${loopdevname}"
1680 fstype=$(get_fstype "${devname}")
1682 if is_supported_fs ${fstype}
1684 devuid=$(blkid -o value -s UUID "$devname")
1685 [ -n "$devuid" ] && grep -qs "\<$devuid\>" $tried && continue
1686 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1687 [ -n "$devuid" ] && echo "$devuid" >> $tried
1689 if is_live_path ${mountpoint} && \
1690 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1695 umount ${mountpoint} 2>/dev/null
1699 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1701 losetup -d "${loopdevname}"
1711 # don't start autodetection before timeout has expired
1712 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1714 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1720 # first look at the one specified in the command line
1721 case "${LIVE_MEDIA}" in
1723 for sysblock in $(removable_usb_dev "sys")
1725 for dev in $(subdevices "${sysblock}")
1727 if check_dev "${dev}"
1737 for sysblock in $(removable_dev "sys")
1739 for dev in $(subdevices "${sysblock}")
1741 if check_dev "${dev}"
1751 if [ ! -z "${LIVE_MEDIA}" ]
1753 if check_dev "null" "${LIVE_MEDIA}" "skip_uuid_check"
1761 # or do the scan of block devices
1762 # prefer removable devices over non-removable devices, so scan them first
1763 devices_to_scan="$(removable_dev 'sys') $(non_removable_dev 'sys')"
1765 for sysblock in $devices_to_scan
1767 devname=$(sys2dev "${sysblock}")
1768 [ -e "$devname" ] || continue
1769 fstype=$(get_fstype "${devname}")
1771 if /lib/udev/cdrom_id ${devname} > /dev/null
1773 if check_dev "null" "${devname}"
1777 elif is_nice_device "${sysblock}"
1779 for dev in $(subdevices "${sysblock}")
1781 if check_dev "${dev}"
1786 elif [ "${fstype}" = "squashfs" -o \
1787 "${fstype}" = "btrfs" -o \
1788 "${fstype}" = "ext2" -o \
1789 "${fstype}" = "ext3" -o \
1790 "${fstype}" = "ext4" -o \
1791 "${fstype}" = "jffs2" ]
1793 # This is an ugly hack situation, the block device has
1794 # an image directly on it. It's hopefully
1795 # live-boot, so take it and run with it.
1796 ln -s "${devname}" "${devname}.${fstype}"
1797 echo "${devname}.${fstype}"
1807 media_mountpoint="${1}"
1809 log_begin_msg "Checking media integrity"
1811 cd ${media_mountpoint}
1812 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1817 if [ "${RC}" -eq 0 ]
1819 log_success_msg "Everything ok, will reboot in 10 seconds."
1822 umount ${media_mountpoint}
1824 echo u > /proc/sysrq-trigger
1825 echo b > /proc/sysrq-trigger
1827 panic "Not ok, a media defect is likely, switch to VT8 for details."
1833 if [ -x /scripts/local-top/cryptroot ]; then
1834 /scripts/local-top/cryptroot
1839 exec > live-boot.log
1841 tail -f live-boot.log >&7 &
1844 # Ensure 'panic' function is overridden
1845 . /scripts/live-functions
1849 maybe_break live-premount
1850 log_begin_msg "Running /scripts/live-premount"
1851 run_scripts /scripts/live-premount
1854 # Needed here too because some things (*cough* udev *cough*)
1855 # changes the timeout
1857 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1861 livefs_root="${mountpoint}"
1863 panic "Unable to find a live file system on the network"
1866 if [ -n "${ISCSI_PORTAL}" ]
1868 do_iscsi && livefs_root="${mountpoint}"
1869 elif [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1871 # Do a local boot from hd
1874 if [ -x /usr/bin/memdiskfind ]
1876 MEMDISK=$(/usr/bin/memdiskfind)
1880 # We found a memdisk, set up phram
1881 modprobe phram phram=memdisk,${MEMDISK}
1883 # Load mtdblock, the memdisk will be /dev/mtdblock0
1888 # Scan local devices for the image
1890 while [ "$i" -lt 60 ]
1892 livefs_root=$(find_livefs ${i})
1894 if [ -n "${livefs_root}" ]
1905 if [ -z "${livefs_root}" ]
1907 panic "Unable to find a medium containing a live file system"
1910 if [ "${INTEGRITY_CHECK}" ]
1912 integrity_check "${livefs_root}"
1918 elif [ "${TODISK}" ]
1920 live_dest="${TODISK}"
1923 if [ "${live_dest}" ]
1925 log_begin_msg "Copying live media to ${live_dest}"
1926 copy_live_to "${livefs_root}" "${live_dest}"
1930 # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
1931 # because the mountpoint is left behind in /proc/mounts, so let's get
1932 # rid of it when running from RAM
1933 if [ -n "$FROMISO" ] && [ "${TORAM}" ]
1935 losetup -d /dev/loop0
1936 grep -q /isofrom /proc/mounts && umount /isofrom
1939 if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
1941 setup_unionfs "${livefs_root}" "${rootmnt}"
1944 mac="$(echo ${mac} | sed 's/-//g')"
1945 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1949 if [ -n "${ROOT_PID}" ] ; then
1950 echo "${ROOT_PID}" > "${rootmnt}"/live/root.pid
1955 # unionfs-fuse needs /dev to be bind-mounted for the duration of
1956 # live-bottom; udev's init script will take care of things after that
1957 if [ "${UNIONTYPE}" = unionfs-fuse ]
1959 mount -n -o bind /dev "${rootmnt}/dev"
1962 # Move to the new root filesystem so that programs there can get at it.
1963 if [ ! -d /root/live/image ]
1965 mkdir -p /root/live/image
1966 mount --move /live/image /root/live/image
1969 # aufs2 in kernel versions around 2.6.33 has a regression:
1970 # directories can't be accessed when read for the first the time,
1971 # causing a failure for example when accessing /var/lib/fai
1972 # when booting FAI, this simple workaround solves it
1973 ls /root/* >/dev/null 2>&1
1975 # copy snapshot configuration if exists
1976 if [ -f snapshot.conf ]
1978 log_begin_msg "Copying snapshot.conf to ${rootmnt}/etc/live/boot.d"
1979 if [ ! -d "${rootmnt}/etc/live/boot.d" ]
1981 mkdir -p "${rootmnt}/etc/live/boot.d"
1983 cp snapshot.conf "${rootmnt}/etc/live/boot.d/"
1987 if [ -f /etc/resolv.conf ] && [ ! -s ${rootmnt}/etc/resolv.conf ]
1989 log_begin_msg "Copying /etc/resolv.conf to ${rootmnt}/etc/resolv.conf"
1990 cp -v /etc/resolv.conf ${rootmnt}/etc/resolv.conf
1994 maybe_break live-bottom
1995 log_begin_msg "Running /scripts/live-bottom\n"
1997 run_scripts /scripts/live-bottom
2000 if [ "${UNIONFS}" = unionfs-fuse ]
2002 umount "${rootmnt}/dev"
2008 [ -w "${rootmnt}/var/log/" ] && cp live-boot.log "${rootmnt}/var/log/" 2>/dev/null