export PATH=/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin
-mountpoint=/live_media
+echo "/root/lib" >> /etc/ld.so.conf
+echo "/root/usr/lib" >> /etc/ld.so.conf
-root_persistence="casper-rw"
-home_persistence="home-rw"
-root_snapshot_label="casper-sn"
-home_snapshot_label="home-sn"
+mountpoint=/cdrom
-USERNAME="casper"
+USERNAME=casper
USERFULLNAME="Live session user"
-HOSTNAME="live"
-BUILD_SYSTEM="Debian"
+HOST=live
+BUILD_SYSTEM=Custom
mkdir -p $mountpoint
[ -f /etc/casper.conf ] && . /etc/casper.conf
-export USERNAME USERFULLNAME HOSTNAME BUILD_SYSTEM
+export USERNAME USERFULLNAME HOST BUILD_SYSTEM
. /scripts/casper-helpers
-parse_cmdline ()
-{
- # looking for casper specifics options as kernel parameters
- for x in $(cat /proc/cmdline); do
- case $x in
- userfullname=*)
- export USERFULLNAME=${x#userfullname=}
- export CASPERCONF="changed"
- ;;
- hostname=*)
- export HOSTNAME=${x#hostname=}
- export CASPERCONF="changed"
- ;;
- username=*)
- export USERNAME=${x#username=}
- export CASPERCONF="changed"
- ;;
- netboot*)
- export NETBOOT=${x#netboot=} ;;
- toram)
- export TORAM=1 ;;
- todisk=)
- export TODISK=${x#todisk=} ;;
- showmounts)
- export SHOWMOUNTS=1 ;;
- persistent)
- export PERSISTENT=1 ;;
- ip*)
- STATICIP=${x#ip=}
- if [ "${STATICIP}" == "" ]; then
- STATICIP="frommedia"
- fi
- export STATICIP ;;
- casper-getty)
- export CASPERGETTY=1 ;;
- console=*)
- export DEFCONSOLE=$(sed -e 's%.*console=%console=%' /proc/cmdline) ;;
- bootfrom=*)
- export LIVEMEDIA=${x#bootfrom=} ;;
- live-media=*)
- export LIVEMEDIA=${x#live-media=} ;;
- debian-installer/locale=*)
- export LOCALE=${x#debian-installer/locale=} ;;
- locale=*)
- export LOCALE=${x#locale=} ;;
- kbd-chooser/method=*)
- export KBD=${x#kbd-chooser/method=} ;;
- keyb=*)
- export KBD=${x#keyb=} ;;
- console-setup/layoutcode=*)
- export CSLAYOUT=${x#console-setup/layoutcode=} ;;
- console-setup/variantcode=*)
- export CSVARIANT=${x#console-setup/variantcode=} ;;
- console-setup/modelcode=*)
- export CSMODEL=${x#console-setup/modelcode=} ;;
- esac
- done
-
- # sort of compatibility with netboot.h from linux docs
- if [ -z "${NETBOOT}" ]; then
- if [ "${ROOT}" == "/dev/nfs" ]; then
- NETBOOT="nfs"
- export NETBOOT
- elif [ "${ROOT}" == "/dev/cifs" ]; then
- NETBOOT="cifs"
- export NETBOOT
- fi
- fi
-}
+if [ ! -f /casper.vars ]; then
+ touch /casper.vars
+fi
is_casper_path() {
path=$1
fi
}
-get_fstype() {
- local FSTYPE
- local FSSIZE
- eval $(fstype < $1)
- if [ "$FSTYPE" != "unknown" ]; then
- echo $FSTYPE
- return 0
- fi
- /lib/udev/vol_id -t $1 2>/dev/null
-}
-
is_nice_device() {
sysfs_path="${1#/sys}"
if /lib/udev/path_id "${sysfs_path}" | grep -E -q "ID_PATH=(usb|pci-[^-]*-[ide|scsi|usb])"; then
return 1
}
-is_supported_fs ()
-{
+is_supported_fs () {
# FIXME: do something better like the scan of supported filesystems
fstype="${1}"
case ${fstype} in
copytodev="${2}"
copyto="${copyfrom}_swap"
- size=$(used_fs_size "null" "${copyfrom}")
+ size=$(fs_size "" ${copyfrom} "used")
if [ "${copytodev}" = "ram" ]; then
# copying to ram:
else
# it should be a writable block device
if [ -b "${copytodev}" ]; then
- free_string="space"
- freespace="$(df -k ${copytodev} | grep -s ${copytodev} | awk '{print $4}')"
- fstype="$(get_fstype ${devname})"
dev="${copytodev}"
+ free_string="space"
+ fstype=$(get_fstype "${dev}")
+ freespace=$(fs_size "${dev}")
else
+ [ "$quiet" != "y" ] && log_warning_msg "${copytodev} is not a block device."
return 1
fi
fi
- if [ ! ${freespace} -lt ${size} ] ; then
- [ "$quiet" != "y" ] && log_begin_msg "Not enough free ${free_string} to copy live media in ${copytodev}."
- [ "$quiet" != "y" ] && log_end_msg
+ if [ "${freespace}" -lt "${size}" ] ; then
+ [ "$quiet" != "y" ] && log_warning_msg "Not enough free ${free_string} (${freespace}k > ${size}k) to copy live media in ${copytodev}."
return 1
fi
# begin copying..
- [ "$quiet" != "y" ] && log_begin_msg "Copying live media to ${copytodev}..."
mkdir "${copyto}"
+ echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
cp -a ${copyfrom}/* ${copyto} # "cp -a" from busybox also copies hidden files
umount ${copyfrom}
mount -r -o move ${copyto} ${copyfrom}
rmdir ${copyto}
- [ "$quiet" != "y" ] && log_end_msg
return 0
}
modprobe "${MP_QUIET}" af_packet # For DHCP
- ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf
+ udevtrigger
+ udevsettle
+
+ ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config
if [ "${NFSROOT}" = "auto" ]; then
NFSROOT=${ROOTSERVER}:${ROOTPATH}
todir="${2}"
snap_type="${3}"
- #size=$(used_fs_size "${fromdev}")
+ size=$(fs_size "${fromdev}" "" "used")
if [ -b "${fromdev}" ]; then
# look for free mem
# Let's just mount the read-only file systems first
rofsstring=""
rofslist=""
- if [ "${NETBOOT}" == "nfs" ] ; then
+ if [ "${NETBOOT}" = "nfs" ] ; then
roopt="nfsro" # go aroung a bug in nfs-unionfs locking
else
roopt="ro"
;;
esac
done
+ # shows cow fs on /cow for use by casper-snapshot
+ mkdir -p "${rootmnt}/cow"
+ mount -o bind /cow "${rootmnt}/cow"
fi
- # shows cow fs on /cow for use by casper-snapshot
- mkdir -p "${rootmnt}/cow"
- mount -o bind /cow "${rootmnt}/cow"
+ # move the first mount; no head in busybox-initramfs
+ for d in $(mount -t squashfs | cut -d\ -f 3); do
+ mkdir -p "${rootmnt}/rofs"
+ mount -o move "${d}" "${rootmnt}/rofs"
+ break
+ done
}
check_dev ()
if [ -z "${devname}" ]; then
devname=$(sys2dev "${sysdev}")
fi
+
+ if [ -n "${LIVEMEDIA_OFFSET}" ]; then
+ loopdevname=$(setup_loop "${devname}" "loop" "/sys/block/loop*" "${LIVEMEDIA_OFFSET}")
+ devname="${loopdevname}"
+ fi
+
fstype=$(get_fstype "${devname}")
if is_supported_fs ${fstype}; then
mount -t ${fstype} -o ro "${devname}" $mountpoint || continue
umount $mountpoint
fi
fi
+
+ if [ -n "${LIVEMEDIA_OFFSET}" ]; then
+ losetup -d "${loopdevname}"
+ fi
return 1
}
find_livefs() {
+ timeout="${1}"
# first look at the one specified in the command line
if [ ! -z "${LIVEMEDIA}" ]; then
if check_dev "null" "${LIVEMEDIA}"; then
return 0
fi
fi
+ # don't start autodetection before timeout has expired
+ if [ -n "${LIVEMEDIA_TIMEOUT}" ]; then
+ if [ "${timeout}" -lt "${LIVEMEDIA_TIMEOUT}" ]; then
+ return 1
+ fi
+ fi
# or do the scan of block devices
for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram); do
devname=$(sys2dev "${sysblock}")
fi
done
elif [ "${fstype}" = "squashfs" -o \
- "${fstype}" = "ext3" ] -o \
+ "${fstype}" = "ext3" -o \
"${fstype}" = "ext2" ]; then
# This is an ugly hack situation, the block device has
# an image directly on it. It's hopefully
exec > casper.log
exec 2>&1
- parse_cmdline
-
set_usplash_timeout
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-premount"
pulsate
if do_netmount ; then
livefs_root="${mountpoint}"
else
- panic "Unable to find a the network rootfs live file system"
+ panic "Unable to find a live file system on the network"
fi
else
# Scan local devices for the image
for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do
- livefs_root=$(find_livefs)
- if [ ! -z "${livefs_root}" ]; then
+ livefs_root=$(find_livefs $i)
+ if [ "${livefs_root}" ]; then
break
fi
sleep 1
panic "Unable to find a medium containing a live file system"
fi
- if [ ! -z "${TORAM}" ]; then
- copy_live_to "${livefs_root}" "ram"
- elif [ ! -z "${TODISK}" ]; then
- copy_live_to "${livefs_root}" "${TODISK}"
+ 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
mount_images_in_directory "${livefs_root}" "${rootmnt}"