5 export PATH
="/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
7 echo "/root/lib" >> /etc
/ld.so.conf
8 echo "/root/usr/lib" >> /etc
/ld.so.conf
10 mountpoint
="/live/image"
11 LIVE_MEDIA_PATH
="live"
13 root_persistence
="live-rw"
14 home_persistence
="home-rw"
15 root_snapshot_label
="live-sn"
16 home_snapshot_label
="home-sn"
19 USERFULLNAME
="Live user"
22 mkdir
-p "${mountpoint}"
25 # Create /etc/mtab for debug purpose and future syncs
36 [ -f /etc
/live.conf
] && .
/etc
/live.conf
37 export USERNAME USERFULLNAME HOSTNAME
39 .
/scripts
/live-helpers
41 if [ ! -f /live.vars
]
51 for ARGUMENT
in $
(cat /proc
/cmdline
)
58 NOCONSOLEKEYBOARD
="Yes"
67 export NOACCESSIBILITY NOAPTCDROM NOAUTOLOGIN NOCONSOLEKEYBOARD NOFASTBOOT NOFSTAB NOHOSTS NONETWORKING NOTIMEZONE NOXAUTOCONFIG NOXAUTOLOGIN
71 ACCESS
="${ARGUMENT#access=}"
76 DEFCONSOLE
="${ARGUMENT#*=}"
88 DEVICE
="${ARGUMENT#ethdevice=}"
93 ETHDEVICE
="${ARGUMENT#ethdevice=}"
98 ETHDEV_TIMEOUT
="${ARGUMENT#ethdevice-timeout=}"
103 FETCH
="${ARGUMENT#fetch=}"
108 FORCEPERSISTENTFSCK
="Yes"
109 export FORCEPERSISTENTFSCK
113 FTPFS
="${ARGUMENT#ftpfs=}"
118 HTTPFS
="${ARGUMENT#httpfs=}"
123 FROMISO
="${ARGUMENT#*=}"
128 USERNAME
="${ARGUMENT#username=}"
130 export USERNAME LIVECONF
134 USERFULLNAME
="${ARGUMENT#userfullname=}"
136 export USERFULLNAME LIVECONF
145 INTEGRITY_CHECK
="Yes"
146 export INTEGRITY_CHECK
150 STATICIP
="${ARGUMENT#ip=}"
152 if [ -z "${STATICIP}" ]
160 keyb
=*|kbd-chooser
/method
=*)
165 klayout
=*|console-setup
/layoutcode
=*)
166 KLAYOUT
="${ARGUMENT#*=}"
170 kvariant
=*|console-setup
/variantcode
=*)
171 KVARIANT
="${ARGUMENT#*=}"
175 kmodel
=*|console-setup
/modelcode
=*)
176 KMODEL
="${ARGUMENT#*=}"
181 KOPTIONS
="${ARGUMENT#koptions=}"
190 live-media
=*|bootfrom
=*)
191 LIVE_MEDIA
="${ARGUMENT#*=}"
195 live-media-encryption
=*|encryption
=*)
196 LIVE_MEDIA_ENCRYPTION
="${ARGUMENT#*=}"
197 export LIVE_MEDIA_ENCRYPTION
201 LIVE_MEDIA_OFFSET
="${ARGUMENT#live-media-offset=}"
202 export LIVE_MEDIA_OFFSET
206 LIVE_MEDIA_PATH
="${ARGUMENT#live-media-path=}"
207 export LIVE_MEDIA_PATH
210 live-media-timeout
=*)
211 LIVE_MEDIA_TIMEOUT
="${ARGUMENT#live-media-timeout=}"
212 export LIVE_MEDIA_TIMEOUT
216 MODULE
="${ARGUMENT#module=}"
221 NETBOOT
="${ARGUMENT#netboot=}"
226 NFSOPTS
="${ARGUMENT#nfsopts=}"
231 NFS_COW
="${ARGUMENT#nfscow=}"
236 NOACCESSIBILITY
="Yes"
237 export NOACCESSIBILITY
256 NOCONSOLEKEYBOARD
="Yes"
257 export NOCONSOLEKEYBOARD
292 export NOXSCREENSAVER
301 PERSISTENT
="${ARGUMENT#persistent=}"
302 if [ -z "${PERSISTENT}" ]
310 PERSISTENT_PATH
="${ARGUMENT#persistent-path=}"
311 export PERSISTENT_PATH
314 persistent-subtext
=*)
315 root_persistence
="${root_persistence}-${ARGUMENT#persistent-subtext=}"
316 home_persistence
="${home_persistence}-${ARGUMENT#persistent-subtext=}"
317 root_snapshot_label
="${root_snapshot_label}-${ARGUMENT#persistent-subtext=}"
318 home_snapshot_label
="${home_snapshot_label}-${ARGUMENT#persistent-subtext=}"
327 QUICKUSBMODULES
="Yes"
328 export QUICKUSBMODULES
331 preseed
/file=*|
file=*)
332 LOCATIONS
="${ARGUMENT#*=} ${LOCATIONS}"
342 URL_LOCATION
="${ARGUMENT#url=}"
344 mount
-o bind /sys
/root
/sys
345 mount
-o bind /proc
/root
/proc
346 mount
-o bind /dev
/root
/dev
348 mkdir
-p /root
/var
/run
/network
349 [ "${NETBOOT}" ] || chroot
/root dhclient eth0
350 chroot
/root wget
-P /tmp
"${URL_LOCATION}"
351 [ "${NETBOOT}" ] || chroot
/root ifconfig eth0 down
357 LOCATIONS
="/tmp/$(basename ${URL_LOCATION}) ${LOCATIONS}"
361 question
="${ARGUMENT%%=*}"
362 value
="${ARGUMENT#*=}"
363 PRESEEDS
="${PRESEEDS}\"${question}=${value}\" "
383 TIMEZONE
="${ARGUMENT#timezone=}"
393 TODISK
="${ARGUMENT#todisk=}"
404 MODULETORAM
="${ARGUMENT#toram=}"
405 export TORAM MODULETORAM
419 SKIP_UNION_MOUNTS
="Yes"
420 export SKIP_UNION_MOUNTS
424 ROOT
="${ARGUMENT#root=}"
429 UNIONTYPE
="${ARGUMENT#union=}"
439 XDRIVER
="${ARGUMENT#xdriver=}"
444 XVIDEOMODE
="${ARGUMENT#xvideomode=}"
450 # sort of compatibility with netboot.h from linux docs
451 if [ -z "${NETBOOT}" ]
453 if [ "${ROOT}" = "/dev/nfs" ]
457 elif [ "${ROOT}" = "/dev/cifs" ]
464 if [ -z "${MODULE}" ]
470 if [ -z "${UNIONTYPE}" ]
481 if [ -d "${DIRECTORY}"/"${LIVE_MEDIA_PATH}" ]
483 for FILESYSTEM
in squashfs ext2 ext3 ext4 xfs dir jffs2
485 if [ "$(echo ${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM})" != "${DIRECTORY}/${LIVE_MEDIA_PATH}/*.${FILESYSTEM}" ]
497 if [ "${IGNORE_UUID}" ] ||
[ ! -e /conf
/uuid.conf
]
503 uuid
="$(cat /conf/uuid.conf)"
505 for try_uuid_file
in "${path}/.disk/live-uuid"*
507 [ -e "${try_uuid_file}" ] ||
continue
509 try_uuid
="$(cat "${try_uuid_file}")"
511 if [ "${uuid}" = "${try_uuid}" ]
520 get_backing_device
()
523 *.squashfs|
*.ext2|
*.ext3|
*.ext4|
*.jffs2
)
524 echo $
(setup_loop
"${1}" "loop" "/sys/block/loop*" '0' "${LIVE_MEDIA_ENCRYPTION}" "${2}")
532 panic
"Unrecognized live filesystem: ${1}"
537 match_files_in_dir
()
539 # Does any files match pattern ${1} ?
542 if [ "$(echo ${pattern})" != "${pattern}" ]
550 mount_images_in_directory
()
557 if match_files_in_dir
"${directory}/${LIVE_MEDIA_PATH}/*.squashfs" ||
558 match_files_in_dir
"${directory}/${LIVE_MEDIA_PATH}/*.ext2" ||
559 match_files_in_dir
"${directory}/${LIVE_MEDIA_PATH}/*.ext3" ||
560 match_files_in_dir
"${directory}/${LIVE_MEDIA_PATH}/*.ext4" ||
561 match_files_in_dir
"${directory}/${LIVE_MEDIA_PATH}/*.jffs2" ||
562 match_files_in_dir
"${directory}/${LIVE_MEDIA_PATH}/*.dir"
564 [ -n "${mac}" ] && adddirectory="${directory}/${LIVE_MEDIA_PATH}/${mac}"
565 setup_unionfs
"${directory}/${LIVE_MEDIA_PATH}" "${rootmnt}" "${adddirectory}"
567 panic
"No supported filesystem images found at /${LIVE_MEDIA_PATH}."
573 sysfs_path
="${1#/sys}"
575 if /lib
/udev
/path_id
"${sysfs_path}" |
egrep -q "ID_PATH=(usb|pci-|platform-orion-ehci|platform-mmc|platform-mxsdhci|)"
578 elif echo "${sysfs_path}" |
grep -q '^/block/vd[a-z]$'
581 elif echo ${sysfs_path} |
grep -q "^/block/dm-"
593 copyto
="${copyfrom}_swap"
595 if [ -z "${MODULETORAM}" ]
597 size
=$
(fs_size
"" ${copyfrom}/${LIVE_MEDIA_PATH} "used")
599 MODULETORAMFILE
="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
601 if [ -f "${MODULETORAMFILE}" ]
603 size
=$
( expr $
(ls -la ${MODULETORAMFILE} |
awk '{print $5}') / 1024 + 5000 )
605 log_warning_msg
"Error: toram-module ${MODULETORAM} (${MODULETORAMFILE}) could not be read."
610 if [ "${copytodev}" = "ram" ]
613 freespace
=$
(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc
/meminfo
)
614 mount_options
="-o size=${size}k"
619 # it should be a writable block device
620 if [ -b "${copytodev}" ]
624 fstype
=$
(get_fstype
"${dev}")
625 freespace
=$
(fs_size
"${dev}")
627 log_warning_msg
"${copytodev} is not a block device."
632 if [ "${freespace}" -lt "${size}" ]
634 log_warning_msg
"Not enough free ${free_string} (${freespace}k free, ${size}k needed) to copy live media in ${copytodev}."
638 # begin copying (or uncompressing)
640 log_begin_msg
"mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
641 mount
-t "${fstype}" ${mount_options} "${dev}" "${copyto}"
643 if [ "${extension}" = "tgz" ]
646 tar zxf
"${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
647 rm -f "${copyfrom}/${LIVE_MEDIA_PATH}/$(basename ${FETCH})"
648 mount
-r -o move
"${copyto}" "${rootmnt}"
651 if [ -n "${MODULETORAMFILE}" ]
655 echo " * Copying $MODULETORAMFILE to RAM" 1>/dev
/console
656 rsync
-a --progress ${MODULETORAMFILE} ${copyto} 1>/dev
/console
# copy only the filesystem module
658 cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
663 echo " * Copying whole medium to RAM" 1>/dev
/console
664 rsync
-a --progress ${copyfrom}/* ${copyto} 1>/dev
/console
# "cp -a" from busybox also copies hidden files
666 mkdir
-p ${copyto}/${LIVE_MEDIA_PATH}
667 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/* ${copyto}/${LIVE_MEDIA_PATH}
668 if [ -e ${copyfrom}/${LIVE_MEDIA_PATH}/.disk
]
670 cp -a ${copyfrom}/${LIVE_MEDIA_PATH}/.disk ${copyto}
676 mount
-r -o move
${copyto} ${copyfrom}
687 modprobe
-q af_packet
# For DHCP
692 if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
693 [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
696 # if ethdevice was not specified on the kernel command line
697 # make sure we try to get a working network configuration
698 # for *every* present network device (except for loopback of course)
699 if [ -z "$ETHDEVICE" ] ; then
700 echo "If you want to boot from a specific device use bootoption ethdevice=..."
701 for device
in /sys
/class
/net
/*; do
703 if [ "$dev" != "lo" ] ; then
704 ETHDEVICE
="$ETHDEVICE $dev"
709 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
710 for device
in $
(echo $ETHDEVICE |
sed 's/,/ /g') ; do
711 devlist
="$devlist $device"
714 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT
=15
715 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
717 # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
718 # an endless loop; iff execution fails give it two further tries, that's
719 # why we use '$devlist $devlist $devlist' for the other for loop
720 for dev
in $devlist $devlist $devlist ; do
721 echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
722 ipconfig
-t "$ETHDEV_TIMEOUT" $dev |
tee -a /netboot.config
&
724 sleep "$ETHDEV_TIMEOUT" ; sleep 1
725 if [ -r /proc
/"$jobid"/status
] ; then
726 echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
730 # if configuration of device worked we should have an assigned
731 # IP address, iff so let's use the according as $DEVICE for later usage
732 # simple and primitive approach which seems to work fine
733 if ifconfig
$dev |
grep -q 'inet.*addr:' ; then
740 ipconfig
${DEVICE} |
tee /netboot.config
743 # source relevant ipconfig output
744 OLDHOSTNAME
=${HOSTNAME}
745 .
/tmp
/net-
${DEVICE}.conf
746 [ -z ${HOSTNAME} ] && HOSTNAME
=${OLDHOSTNAME}
749 # Check if we have a network device at all
750 if ! ls /sys
/class
/net
/"$DEVICE" > /dev
/null
2>&1 && \
751 ! ls /sys
/class
/net
/eth0
> /dev
/null
2>&1 && \
752 ! ls /sys
/class
/net
/wlan0
> /dev
/null
2>&1 && \
753 ! ls /sys
/class
/net
/ath0
> /dev
/null
2>&1 && \
754 ! ls /sys
/class
/net
/ra0
> /dev
/null
2>&1
756 panic
"No supported network device found, maybe a non-mainline driver is required."
759 if [ "${NFSROOT}" = "auto" ]
761 NFSROOT
=${ROOTSERVER}:${ROOTPATH}
764 if ( [ -n "${FETCH}" ] || [ -n "${HTTPFS}" ] || [ -n "${FTPFS}" ] ) && do_httpmount
770 if [ "${NFSROOT#*:}" = "${NFSROOT}" ] && [ "$NETBOOT" != "cifs" ]
772 NFSROOT
=${ROOTSERVER}:${NFSROOT}
775 log_begin_msg
"Trying netboot from ${NFSROOT}"
777 if [ "${NETBOOT}" != "nfs" ] && do_cifsmount
794 dest
="${mountpoint}/${LIVE_MEDIA_PATH}"
795 mount
-t ramfs ram
"${mountpoint}"
798 for webfile
in HTTPFS FTPFS FETCH
800 url
="$(eval echo \"\$\{${webfile}\}\")"
801 extension
="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
805 case "${extension}" in
807 if [ "${webfile}" = "FETCH" ]
811 ip
="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
812 rfile
="$(echo $url | sed -e "s|tftp
://$ip||g
")"
813 lfile
="$(basename $url)"
814 log_begin_msg
"Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
815 tftp
-g -b 10240 -r $rfile -l ${dest}/$lfile $ip
819 log_begin_msg
"Trying wget ${url} -O ${dest}/$(basename ${url})"
820 wget
"${url}" -O "${dest}/$(basename ${url})"
824 log_begin_msg
"Trying to mount ${url} on ${dest}/$(basename ${url})"
825 if [ "${webfile}" = "FTPFS" ]
827 FUSE_MOUNT
="curlftpfs"
828 url
="$(dirname ${url})"
833 $FUSE_MOUNT "${url}" "${dest}"
835 [ ${?} -eq 0 ] && rc
=0
836 [ "${extension}" = "tgz" ] && live_dest
="ram"
841 log_begin_msg
"Unrecognized archive extension for ${url}"
849 umount
"${mountpoint}"
861 if [ -z "${NFSOPTS}" ]
866 log_begin_msg
"Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
868 # FIXME: This while loop is an ugly HACK round an nfs bug
870 while [ "$i" -lt 60 ]
872 nfsmount
-o nolock
-o ro
${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
884 if [ -x "/sbin
/mount.cifs
" ]
886 if [ -z "${NFSOPTS}" ]
888 CIFSOPTS="-ouser=root
,password
="
890 CIFSOPTS="${NFSOPTS}"
893 log_begin_msg "Trying mount.cifs
${NFSROOT} ${mountpoint} ${CIFSOPTS}"
896 if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
910 size=$(fs_size "${fromdev}" "" "used
")
912 if [ -b "${fromdev}" ]
915 if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME
" ]
917 todev=$(awk -v pat="$
(base_path
${todir})" '$2 == pat { print $1 }' /proc/mounts)
918 freespace=$(df -k | awk '/'${todev}'/{print $4}')
920 freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
923 tomount="/mnt
/tmpsnap
"
925 if [ ! -d "${tomount}" ]
927 mkdir -p "${tomount}"
930 fstype=$(get_fstype "${fromdev}")
932 if [ -n "${fstype}" ]
935 mount -o ro -t "${fstype}" "${fromdev}" "${tomount}" || log_warning_msg "Error in mount -t ${fstype} -o ro ${fromdev} ${tomount}"
936 cp -a "${tomount}"/* ${todir}
939 log_warning_msg "Unrecognized fstype
: ${fstype} on ${fromdev}:${snap_type}"
944 if echo ${fromdev} | grep -qs loop
946 losetup -d "${fromdev}"
953 log_warning_msg "Unable to
find the snapshot
${snap_type} medium
"
959 # Look for ${snap_label}.* in block devices
962 if [ "${PERSISTENT}" != "nofiles
" ]
964 # search for image files
965 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
")
968 if [ -z "${snapdata}" ]
970 snapdata=$(find_cow_device "${snap_label}")
977 # copy the contents of previously found snapshot to ${snap_mount}
978 # and remember the device and filename for resync on exit in live-boot.init
984 if [ -n "${snapdata}" ] && [ ! -b "${snapdata}" ]
986 log_success_msg "found snapshot
: ${snapdata}"
987 snapdev="$
(echo ${snapdata} | cut
-f1 -d ' ')"
988 snapback="$
(echo ${snapdata} | cut
-f2 -d ' ')"
989 snapfile="$
(echo ${snapdata} | cut
-f3 -d ' ')"
992 if ! try_mount "${snapdev}" "${snapback}" "ro
"
997 if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\|ext3\|ext4\|jffs2\)'
999 # squashfs, jffs2 or ext2/ext3/ext4 snapshot
1000 dev=$(get_backing_device "${snapback}/${snapfile}")
1002 do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1007 # Unfortunately klibc's cpio is incompatible with the
1008 # rest of the world; everything else requires -u -d,
1009 # while klibc doesn't implement them. Try to detect
1010 # whether it's in use.
1011 cpiopath="$
(which cpio)" || true
1012 if [ "$cpiopath" ] && grep -aq /lib/klibc "$cpiopath"
1016 cpioargs='--unconditional --make-directories'
1019 if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse 2>/dev/null)
1021 log_warning_msg "failure to
\"zcat
${snapback}/${snapfile} |
cpio $cpioargs --extract --preserve-modification-time --no-absolute-filenames --sparse\""
1025 umount "${snapback}" || log_warning_msg "failure to
\"umount
${snapback}\""
1027 if [ "${RES}" != "0" ]
1029 log_warning_msg "Impossible to include the
${snapfile} Snapshot
file"
1032 elif [ -b "${snapdata}" ]
1034 # Try to find if it could be a snapshot partition
1036 log_success_msg "found snapshot
${snap_type} device on
${dev}"
1037 if echo "${dev}" | grep -qs loop
1039 # strange things happens, user confused?
1040 snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
1041 snapfile=$(basename ${snaploop})
1042 snapdev=$(awk -v pat="$
( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
1047 if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"
1049 log_warning_msg "Impossible to include the
${snap_type} Snapshot
"
1052 if [ -n "${snapfile}" ]
1054 # it was a loop device, user confused
1059 log_warning_msg "Impossible to include the
${snap_type} Snapshot
"
1063 echo "export ${snap_type}SNAP="/cow${snap_mount#$rootmnt}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
1069 image_directory="${1}"
1071 addimage_directory="${3}"
1073 case ${UNIONTYPE} in
1075 modprobe -q -b ${UNIONTYPE}
1077 if ! cut -f2 /proc/filesystems | grep -q "^
${UNIONTYPE}\$
" && [ -x /bin/unionfs-fuse ]
1079 echo "${UNIONTYPE} not available
, falling back to unionfs-fuse.
"
1080 echo "This might be really slow.
"
1082 UNIONTYPE="unionfs-fuse
"
1087 if [ "${UNIONTYPE}" = unionfs-fuse ]
1092 # run-init can't deal with images in a subdir, but we're going to
1093 # move all of these away before it runs anyway. No, we're not,
1094 # put them in / since move-mounting them into / breaks mono and
1099 # Let's just mount the read-only file systems first
1103 if [ "${UNIONTYPE}" = "aufs
" ]
1106 noxino_opt="noxino
,"
1107 elif [ "${UNIONTYPE}" = "unionfs-fuse
" ]
1114 if [ -z "${PLAIN_ROOT}" ]
1116 # Read image names from ${MODULE}.module if it exists
1117 if [ -e "${image_directory}/filesystem.
${MODULE}.module
" ]
1119 for IMAGE in $(cat ${image_directory}/filesystem.${MODULE}.module)
1121 image_string="${image_string} ${image_directory}/${IMAGE}"
1123 elif [ -e "${image_directory}/${MODULE}.module
" ]
1125 for IMAGE in $(cat ${image_directory}/${MODULE}.module)
1127 image_string="${image_string} ${image_directory}/${IMAGE}"
1130 # ${MODULE}.module does not exist, create a list of images
1131 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1133 for IMAGE in "${image_directory}"/*."${FILESYSTEM}"
1135 if [ -e "${IMAGE}" ]
1137 image_string="${image_string} ${IMAGE}"
1142 if [ -n "${addimage_directory}" ] && [ -d "${addimage_directory}" ]
1144 for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
1146 for IMAGE in "${addimage_directory}"/*."${FILESYSTEM}"
1148 if [ -e "${IMAGE}" ]
1150 image_string="${image_string} ${IMAGE}"
1157 image_string="$
(echo ${image_string} |
sed -e 's/ /\n/g' |
sort )"
1160 [ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
1164 for image in ${image_string}
1166 imagename=$(basename "${image}")
1168 export image devname
1169 maybe_break live-realpremount
1170 log_begin_msg "Running
/scripts
/live-realpremount
"
1171 run_scripts /scripts/live-realpremount
1174 if [ -d "${image}" ]
1176 # it is a plain directory: do nothing
1177 rofsstring="${image}=${roopt}:${rofsstring}"
1178 rofslist="${image} ${rofslist}"
1179 elif [ -f "${image}" ]
1181 if losetup --help 2>&1 | grep -q -- "-r\b"
1183 backdev=$(get_backing_device "${image}" "-r")
1185 backdev=$(get_backing_device "${image}")
1187 fstype=$(get_fstype "${backdev}")
1189 if [ "${fstype}" = "unknown
" ]
1191 panic "Unknown
file system
type on
${backdev} (${image})"
1194 if [ -z "${fstype}" ]
1196 fstype="${imagename##*.}"
1197 log_warning_msg "Unknown
file system
type on
${backdev} (${image}), assuming ${fstype}.
"
1200 mkdir -p "${croot}/${imagename}"
1201 log_begin_msg "Mounting
\"${image}\" on \"${croot}${imagename}\" via \"${backdev}\""
1202 mount -t "${fstype}" -o ro,noatime "${backdev}" "${croot}/${imagename}" || panic "Can not mount ${backdev} (${image}) on ${croot}/${imagename}" && rofsstring="${croot}/${imagename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename} ${rofslist}"
1207 # we have a plain root system
1208 mkdir -p "${croot}/filesystem
"
1209 log_begin_msg "Mounting
\"${image_directory}\" on
\"${croot}/filesystem
\""
1210 mount -t $(get_fstype "${image_directory}") -o ro,noatime "${image_directory}" "${croot}/filesystem" || panic "Can not mount ${image_directory} on ${croot}/filesystem" && rofsstring="${croot}/filesystem=${roopt}:${rofsstring}" && rofslist="${croot}/filesystem ${rofslist}"
1212 mount -o bind ${croot}/filesystem $mountpoint
1216 rofsstring=${rofsstring%:}
1220 # Looking for "${root_persistence}" device or file
1221 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1223 if [ -z "${QUICKUSBMODULES}" ]
1226 num_block=$(ls -l /sys/block | wc -l)
1227 for module in sd_mod uhci-hcd ehci-hcd ohci-hcd usb-storage
1229 modprobe -q -b ${module}
1235 # For some reason, udevsettle does not block in this scenario,
1236 # so we sleep for a little while.
1238 # See https://bugs.launchpad.net/ubuntu/+source/casper/+bug/84591
1239 for timeout in 5 4 3 2 1
1243 if [ $(ls -l /sys/block | wc -l) -gt ${num_block} ]
1250 # search for label and files (this could be hugely optimized)
1251 cowprobe=$(find_cow_device "${root_persistence}")
1252 if [ -b "${cowprobe}" ]
1254 # Blacklist /cow device, to avoid inconsistent setups for overlapping snapshots
1255 # makes sense to have both persistence for /cow and /home mounted, maybe also with
1256 # snapshots to be sure to really store some e.g key config files,
1257 # but not on the same media
1258 blacklistdev="${cowprobe}"
1259 PERSISTENCE_IS_ON="1"
1260 export PERSISTENCE_IS_ON
1262 # homecow just mount something on /home, this should be generalized some way
1263 homecow=$(find_cow_device "${home_persistence}" "${blacklistdev}")
1264 if [ -b "${homecow}" ]
1266 PERSISTENCE_IS_ON="1"
1267 export PERSISTENCE_IS_ON
1269 root_snapdata=$(find_snap "${root_snapshot_label}" "${blacklistdev}")
1270 # This second type should be removed when snapshot will get smarter,
1271 # hence when "/etc
/live-snapshot
*list
" will be supported also by
1272 # ext2|ext3|ext4|jffs2 snapshot types.
1273 home_snapdata=$(find_snap "${home_snapshot_label}" "${blacklistdev}")
1275 if [ -b "${cowprobe}" ]
1277 cowdevice=${cowprobe}
1278 cow_fstype=$(get_fstype "${cowprobe}")
1279 cow_mountopt="rw
,noatime
"
1281 if [ "${FORCEPERSISTENTFSCK}" = "Yes
" ]
1283 fsck -y ${cowdevice}
1286 log_warning_msg "Unable to
find the persistent medium
"
1289 cow_mountopt="rw
,noatime
,mode
=755"
1291 elif [ -n "${NFS_COW}" ] && [ -z "${NOPERSISTENT}" ]
1293 # check if there are any nfs options
1294 if echo ${NFS_COW}|grep -q ','
1296 nfs_cow_opts="-o nolock
,$
(echo ${NFS_COW}|cut
-d, -f2-)"
1297 nfs_cow=$(echo ${NFS_COW}|cut -d, -f1)
1299 nfs_cow_opts="-o nolock
"
1305 cowdevice=$(echo ${nfs_cow}|sed "s
/client_mac_address
/${mac}/")
1308 panic "unable to determine mac address
"
1313 cow_mountopt="rw
,noatime
,mode
=755"
1316 if [ "${cow_fstype}" = "nfs
" ]
1319 "Trying nfsmount
${nfs_cow_opts} ${cowdevice} /cow
"
1320 nfsmount ${nfs_cow_opts} ${cowdevice} /cow || \
1321 panic "Can not mount
${cowdevice} (n
: ${cow_fstype}) on
/cow
"
1323 mount -t ${cow_fstype} -o ${cow_mountopt} ${cowdevice} /cow || \
1324 panic "Can not mount
${cowdevice} (o
: ${cow_fstype}) on
/cow
"
1327 rofscount=$(echo ${rofslist} |wc -w)
1329 if [ -n "${EXPOSED_ROOT}" ]
1331 if [ ${rofscount} -ne 1 ]
1333 panic "only one RO
file system supported with exposedroot
: ${rofslist}"
1335 exposedrootfs=${rofslist%% }
1337 mount --bind ${exposedrootfs} ${rootmnt} || \
1338 panic "bind mount of
${exposedrootfs} failed
"
1340 if [ -z "${SKIP_UNION_MOUNTS}" ]
1342 cow_dirs='/var/tmp /var/lock /var/run /var/log /var/spool /home /var/lib/live'
1347 for dir in ${cow_dirs}; do
1350 case "${UNIONTYPE}" in
1352 (ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:${exposedrootfs}${dir} "${rootmnt}${dir}" || panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option cow,noinitgroups,default_permissions,allow_other,use_ino,suid=/cow=RW:${exposedrootfs}${dir}")
1353 mkdir
-p /dev
/.initramfs
/varrun
1354 pidof unionfs-fuse
>> /dev
/.initramfs
/varrun
/sendsigs.omit || true
1358 mount
-t ${UNIONTYPE} -o rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro ${UNIONTYPE} "${rootmnt}${dir}" || panic "mount ${UNIONTYPE} on ${rootmnt}${dir} failed with option rw,noatime,dirs=/cow${dir}=rw:${exposedrootfs}${dir}=ro
"
1363 case "${UNIONTYPE}" in
1365 (ulimit -n 16384; unionfs-fuse -o cow -o noinitgroups -o default_permissions -o allow_other -o use_ino -o suid /cow=RW:${rofsstring} "${rootmnt}" || panic "mount ${UNIONTYPE} on ${rootmnt} failed with option cow,noinitgroups,default_permissions,allow_other,use_ino,suid=/cow:RW:${rofsstring}")
1366 mkdir
-p /dev
/.initramfs
/varrun
1367 pidof unionfs-fuse
>> /dev
/.initramfs
/varrun
/sendsigs.omit || true
1371 mount
-t ${UNIONTYPE} -o noatime,${noxino_opt}dirs=/cow=rw:${rofsstring} ${UNIONTYPE} "${rootmnt}" || panic "mount ${UNIONTYPE} on ${rootmnt} failed with option noatime,${noxino_opt}dirs=/cow=rw:${rofsstring}"
1376 # Correct the permissions of /:
1377 chmod 0755 "${rootmnt}"
1379 # tmpfs file systems
1381 mkdir -p "${rootmnt}/live
"
1382 mount -t tmpfs tmpfs ${rootmnt}/live
1384 # Adding other custom mounts
1385 if [ -n "${PERSISTENT}" ] && [ -z "${NOPERSISTENT}" ]
1387 # directly mount /home
1388 # FIXME: add a custom mounts configurable system
1390 if [ -b "${homecow}" ]
1392 mount -t $(get_fstype "${homecow}") -o rw,noatime "${homecow}" "${rootmnt}/home
"
1393 export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy()
1395 log_warning_msg "Unable to
find the persistent home medium
"
1398 # Look for other snapshots to copy in
1399 try_snap "${root_snapdata}" "${rootmnt}" "ROOT
"
1400 # This second type should be removed when snapshot grow smarter
1401 try_snap "${home_snapdata}" "${rootmnt}/home
" "HOME
"
1404 if [ -n "${SHOWMOUNTS}" ]
1406 for d in ${rofslist}
1408 mkdir -p "${rootmnt}/live
/${d##*/}"
1412 # do nothing # mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1416 case "${UNIONTYPE}" in
1418 mount -o bind "${d}" "${rootmnt}/live/${d##*/}"
1422 mount -o move "${d}" "${rootmnt}/live/${d##*/}"
1430 # shows cow fs on /cow for use by live-snapshot
1431 mkdir -p "${rootmnt}/live
/cow
"
1432 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
"
1439 skip_uuid_check="${3}"
1441 # support for fromiso=.../isofrom=....
1442 if [ -n "$FROMISO" ]
1444 ISO_DEVICE=$(dirname $FROMISO)
1445 if ! [ -b $ISO_DEVICE ]
1447 # to support unusual device names like /dev/cciss/c0d0p1
1448 # as well we have to identify the block device name, let's
1449 # do that for up to 15 levels
1451 while [ -n "$ISO_DEVICE" ] && [ "$i" -gt 0 ]
1453 ISO_DEVICE=$(dirname ${ISO_DEVICE})
1454 [ -b "$ISO_DEVICE" ] && break
1459 if [ "$ISO_DEVICE" = "/" ]
1461 echo "Warning
: device
for bootoption isofrom
= ($FROMISO) not found.
">>/live.log
1464 mount "$ISO_DEVICE" /isofrom
1465 ISO_NAME="$
(echo $FROMISO |
sed "s|$ISO_DEVICE||")"
1466 loopdevname=$(setup_loop "/isofrom
/${ISO_NAME}" "loop
" "/sys
/block
/loop
*" "" '')
1467 devname="${loopdevname}"
1471 if [ -z "${devname}" ]
1473 devname=$(sys2dev "${sysdev}")
1476 if [ -d "${devname}" ]
1478 mount -o bind "${devname}" $mountpoint || continue
1480 if is_live_path $mountpoint
1488 [ -e "$devname" ] || continue
1490 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1492 loopdevname=$(setup_loop "${devname}" "loop
" "/sys
/block
/loop
*" "${LIVE_MEDIA_OFFSET}" '')
1493 devname="${loopdevname}"
1496 fstype=$(get_fstype "${devname}")
1498 if is_supported_fs ${fstype}
1500 devuid=$(blkid -o value -s UUID "$devname")
1501 [ -n "$devuid" ] && grep -qs "\
<$devuid\
>" $tried && continue
1502 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
1503 [ -n "$devuid" ] && echo "$devuid" >> $tried
1505 if is_live_path ${mountpoint} && \
1506 ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
1511 umount ${mountpoint}
1515 if [ -n "${LIVE_MEDIA_OFFSET}" ]
1517 losetup -d "${loopdevname}"
1527 # don't start autodetection before timeout has expired
1528 if [ -n "${LIVE_MEDIA_TIMEOUT}" ]
1530 if [ "${timeout}" -lt "${LIVE_MEDIA_TIMEOUT}" ]
1536 # first look at the one specified in the command line
1537 case "${LIVE_MEDIA}" in
1539 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd
)")
1541 if [ "$
(cat ${sysblock}/removable
)" = "1" ]
1543 if readlink ${sysblock} | grep -q usb ||
1544 readlink ${sysblock}/device | grep -q usb # linux < 2.6.29
1546 for dev in $(subdevices "${sysblock}")
1548 if check_dev "${dev}"
1560 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd
)")
1562 if [ "$
(cat ${sysblock}/removable
)" = "1" ]
1564 for dev in $(subdevices "${sysblock}")
1566 if check_dev "${dev}"
1577 if [ ! -z "${LIVE_MEDIA}" ]
1579 if check_dev "null
" "${LIVE_MEDIA}" "skip_uuid_check
"
1587 # or do the scan of block devices
1588 # prefer removable devices over non-removable devices, so scan them first
1589 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | egrep -v "/(loop|ram|dm-|fd
)")
1591 if [ "$
(cat ${sysblock}/removable
)" = "1" ]
1593 removable_devices_to_scan="$removable_devices_to_scan $sysblock"
1595 nonremovable_devices_to_scan="$nonremovable_devices_to_scan $sysblock"
1598 devices_to_scan="$removable_devices_to_scan $nonremovable_devices_to_scan"
1600 for sysblock in $devices_to_scan
1602 devname=$(sys2dev "${sysblock}")
1603 [ -e "$devname" ] || continue
1604 fstype=$(get_fstype "${devname}")
1606 if /lib/udev/cdrom_id ${devname} > /dev/null
1608 if check_dev "null
" "${devname}"
1612 elif is_nice_device "${sysblock}"
1614 for dev in $(subdevices "${sysblock}")
1616 if check_dev "${dev}"
1621 elif [ "${fstype}" = "squashfs
" -o \
1622 "${fstype}" = "ext2
" -o \
1623 "${fstype}" = "ext3
" -o \
1624 "${fstype}" = "ext4
" -o \
1625 "${fstype}" = "jffs2
" ]
1627 # This is an ugly hack situation, the block device has
1628 # an image directly on it. It's hopefully
1629 # live-boot, so take it and run with it.
1630 ln -s "${devname}" "${devname}.${fstype}"
1631 echo "${devname}.
${fstype}"
1639 set_usplash_timeout ()
1641 if [ -x /sbin/usplash_write ]
1643 /sbin/usplash_write "TIMEOUT
120"
1644 else if [ -x /sbin/splashy_update ] ; then
1645 /sbin/splashy_update "TIMEOUT
120"
1651 media_mountpoint="${1}"
1653 log_begin_msg "Checking media integrity
"
1655 cd ${media_mountpoint}
1656 /bin/md5sum -c md5sum.txt < /dev/tty8 > /dev/tty8
1661 if [ "${RC}" -eq 0 ]
1663 log_success_msg "Everything ok
, will reboot
in 10 seconds.
"
1666 umount ${media_mountpoint}
1668 echo u > /proc/sysrq-trigger
1669 echo b > /proc/sysrq-trigger
1671 panic "Not ok
, a media defect is likely
, switch to VT8
for details.
"
1675 start_usplash_pulse ()
1677 if [ -x /sbin/usplash_write ]
1679 /sbin/usplash_write "PULSELOGO
"
1685 if [ -x /scripts/local-top/cryptroot ]; then
1686 /scripts/local-top/cryptroot
1693 tail -f live.log >&7 &
1696 # Ensure 'panic' function is overridden
1697 . /scripts/live-functions
1704 maybe_break live-premount
1705 log_begin_msg "Running
/scripts
/live-premount
"
1706 run_scripts /scripts/live-premount
1709 # Needed here too because some things (*cough* udev *cough*)
1710 # changes the timeout
1714 if [ ! -z "${NETBOOT}" ] || [ ! -z "${FETCH}" ] || [ ! -z "${HTTPFS}" ] || [ ! -z "${FTPFS}" ]
1718 livefs_root="${mountpoint}"
1720 panic "Unable to
find a live
file system on the network
"
1723 if [ -n "${PLAIN_ROOT}" ] && [ -n "${ROOT}" ]
1725 # Do a local boot from hd
1728 # Scan local devices for the image
1730 while [ "$i" -lt 60 ]
1732 livefs_root=$(find_livefs ${i})
1734 if [ -n "${livefs_root}" ]
1745 if [ -z "${livefs_root}" ]
1747 panic "Unable to
find a medium containing a live
file system
"
1750 if [ "${INTEGRITY_CHECK}" ]
1752 integrity_check "${livefs_root}"
1758 elif [ "${TODISK}" ]
1760 live_dest="${TODISK}"
1763 if [ "${live_dest}" ]
1765 log_begin_msg "Copying live media to
${live_dest}"
1766 copy_live_to "${livefs_root}" "${live_dest}"
1770 # if we do not unmount the ISO we can't run "fsck
/dev
/ice
" later on
1771 # because the mountpoint is left behind in /proc/mounts, so let's get
1772 # rid of it when running from RAM
1773 if [ -n "$FROMISO" ] && [ "${TORAM}" ]
1775 losetup -d /dev/loop0
1776 grep -q /isofrom /proc/mounts && umount /isofrom
1779 if [ -n "${MODULETORAMFILE}" ] || [ -n "${PLAIN_ROOT}" ]
1781 setup_unionfs "${livefs_root}" "${rootmnt}"
1784 mac="$
(echo ${mac} |
sed 's/-//g')"
1785 mount_images_in_directory "${livefs_root}" "${rootmnt}" "${mac}"
1790 # unionfs-fuse needs /dev to be bind-mounted for the duration of
1791 # live-bottom; udev's init script will take care of things after that
1792 if [ "${UNIONTYPE}" = unionfs-fuse ]
1794 mount -n -o bind /dev "${rootmnt}/dev
"
1797 # Move to the new root filesystem so that programs there can get at it.
1798 if [ ! -d /root/live/image ]
1800 mkdir -p /root/live/image
1801 mount --move /live/image /root/live/image
1804 maybe_break live-bottom
1805 log_begin_msg "Running
/scripts
/live-bottom
\n"
1807 run_scripts /scripts/live-bottom
1810 if [ "${UNIONFS}" = unionfs-fuse ]
1812 umount "${rootmnt}/dev
"
1818 [ -w "${rootmnt}/var
/log
/" ] && cp live.log "${rootmnt}/var
/log
/" 2>/dev/null
1819 if [ -f /etc/live.conf ]
1821 cp /etc/live.conf "${rootmnt}/etc
/"