From: Kern Sibbald Date: Fri, 2 Jan 2009 16:51:26 +0000 (+0000) Subject: More USB rescue code X-Git-Tag: Release-5.0.3~846 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=43d8320202f049818d2b47527796b7661f07b863;p=bacula%2Frescue More USB rescue code --- diff --git a/rescue/linux/usb/README.usb b/rescue/linux/usb/README.usb new file mode 100644 index 0000000..ac1e3aa --- /dev/null +++ b/rescue/linux/usb/README.usb @@ -0,0 +1,22 @@ + +This directory is used to build a USB key containing a Kubuntu 8.04 LiveCD +with persistent OS files and persistent /home files. + + + + + + + + +Kubuntu boot tricks: +1. Booting with persistence added to the kernel options will permit + mounting of a USB casper-rw and home-rw partitions on the USB key. + casper-rw is used to store changed OS files, and home-rw is the + home directory. + + +Bugs with Kubuntu boot process: +1. The initrd.gz image must be opened, fixed and the repacked. +2. The fix involves removing the ,mode=755 from the mount line for + the persistent OS partition (casper-rw) or /cow diff --git a/rescue/linux/usb/getdiskinfo b/rescue/linux/usb/getdiskinfo new file mode 100755 index 0000000..4e90cd1 --- /dev/null +++ b/rescue/linux/usb/getdiskinfo @@ -0,0 +1,463 @@ +#!/bin/sh +# +# Create bootstrap information files -- prelude to creating a +# Bacula Rescue Disk +# +# Kern Sibbald, December MMII +# This source distributed under the GPL +# +export LANG=C +di=diskinfo +cwd=`pwd` +host=`uname -s` + +case $host in + Linux) + ;; + FreeBSD | SunOS | IRIX) + echo "" + echo "This code is not yet adapted to this OS" + exit 1 + ;; + *) + echo "" + echo "Unknown operating system type: $host" + exit 1 + ;; +esac +if [ ! `whoami` = "root" ] ; then + echo "" + echo "You need to be root to run this, otherwise" + echo "sfdisk produces no output. Continuing anyway ..." + echo "" +fi + +# +# First collect information +# +rm -rf format.* partition.* $di create-* +echo "Begin collecting system info ..." +mkdir -p $di +cd $di +mount -l >mount.bsi +mount -l -t ext2 >mount.ext2.bsi +mount -l -t ext3 >mount.ext3.bsi +mount -l -t reiserfs >mount.rei.bsi +cp /etc/fstab fstab.bsi +cp /etc/mtab mtab.bsi +df -Tl >df.bsi +sfdisk -s >sfdisk.disks.bsi +grep "^/dev/" sfdisk.disks.bsi | sed -n 's%\(^/dev/[A-Za-z]*\):.*$%\1%p' >disks.bsi +for i in `cat disks.bsi`; do + j=`echo $i | cut -c6-` + sfdisk -l $i >sfdisk.$j.bsi + sfdisk -d $i >sfdisk.make.$j.bsi +done +cat /proc/swaps > swaps.bsi +route -n >route.bsi +ifconfig >ifconfig.bsi + +# Gather LVM information +# Only tested on LVM2 +dolvm=0 +if which lvm > /dev/null 2>/dev/null ; then + echo "Gathering LVM information" + dolvm=1 + + lvm pvs --noheadings --nosuffix -o pv_name,vg_name | cat > lvm-pv.bsi + lvm vgs --noheadings --nosuffix -o vg_name,vg_extent_size --units=k | cat > lvm-vg.bsi + lvm lvs --noheadings --nosuffix -o lv_name,vg_name,lv_size --units=k | cat > lvm-lv.bsi +fi + +echo "Done collecting info." + +# +# Done collecting information +# + + +echo "Begin creating scripts ..." +# +# First create partitioning script(s) +# +for i in `cat disks.bsi`; do + j=`echo $i | cut -c6-` + cat >$cwd/partition.$j < $cwd/create-pv <> $cwd/create-pv + done + + cat >> $cwd/create-pv <> $cwd/create-pv + echo "lvm pvcreate -ff -y -v $pv" >> $cwd/create-pv + done + echo "echo \"Done.\"" >> $cwd/create-pv + echo "echo \"If there were no errors, run create-vg to create the volume groups.\"" >> $cwd/create-pv + chmod +x $cwd/create-pv + +# +# LVM phase 2: create Volume Groups +# + cat > $cwd/create-vg <> $cwd/create-vg + pelist="" + for pv in `cat lvm-pv.bsi | awk "\\\$2 == \"$vg\" { print \\\$1 }"` ; do + pelist="$pelist $pv" + done + echo "lvm vgcreate $vg -v -s ${pesize}k $pelist" >> $cwd/create-vg + done + echo "echo \"Done.\"" >> $cwd/create-vg + echo "echo \"If there were no errors, run create-lv to create the logical volumes.\"" >> $cwd/create-vg + chmod +x $cwd/create-vg + + +# +# LVM phase 3: create Logical Volumes +# +# One quick sidenote: this script creates LVs with a size based on the +# physical extent count, rather than the size in bytes. This is because +# at the time of writing this script, lvdisplay erroneously prints out +# the size in 512 byte sector count rather than 1024 byte blocks. +# Using the extent count should allow this script to continue to work +# even after the bug is fixed. + + cat > $cwd/create-lv <> $cwd/create-lv + echo "lvm lvcreate -L ${lvsize}k $vg -n $lv" >> $cwd/create-lv + done + chmod +x $cwd/create-lv +fi + +# +# Create formatting script(s) +# +echo "Begin making formatting script(s) ..." +for i in `cat disks.bsi`; do + j=`echo $i | cut -c6-` + cat >$cwd/format.$j <>$cwd/format.$j + echo "mkswap $check $disk" >>$cwd/format.$j + echo "echo \"\"" >>$cwd/format.$j + done + # Find ext2 partitions in mount output + k=`grep "^$i" mount.ext2.bsi | cut -d ' ' -f 1` + for disk in $k; do + echo "echo \"Formating $disk -- ext2 partition\"" >>$cwd/format.$j + label=`grep "^$disk" mount.ext2.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1` + if [ x$label = x ] ; then + echo "mke2fs -v \$check $disk" >>$cwd/format.$j + else + echo "mke2fs -v \$check -L $label $disk" >>$cwd/format.$j + fi + echo "echo \"\"" >>$cwd/format.$j + done + # Find ext3 partitions in mount output + k=`grep "^$i" mount.ext3.bsi | cut -d ' ' -f 1` + for disk in $k; do + echo "echo \"Formating $disk -- ext3 partition\"" >>$cwd/format.$j + label=`grep "^$disk" mount.ext3.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1` + if [ x$label = x ] ; then + echo "mke2fs -v -j \$check $disk" >>$cwd/format.$j + else + echo "mke2fs -v -j \$check -L $label $disk" >>$cwd/format.$j + fi + echo "echo \"\"" >>$cwd/format.$j + done + # Find reiserfs partitions in mount output + k=`grep "^$i" mount.rei.bsi | cut -d ' ' -f 1` + for disk in $k; do + echo "echo \"Formating $disk -- reiser partition\"" >>$cwd/format.$j + label=`grep "^$disk" mount.rei.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1` + if [ x$label = x ] ; then + echo "mkereiserfs -V \$check $disk" >>$cwd/format.$j + else + echo "mkereiserfs -V \$check -L $label $disk" >>$cwd/format.$j + fi + echo "echo \"\"" >>$cwd/format.$j + done + chmod 755 $cwd/format.$j +done + +# +# Create LVM formatting scripts(s) +# +# Somebody more clever than I with bash scripting +# could probably factor a lot of this code out. +# +if [ $dolvm -eq 1 ] ; then + echo "Begin making LVM formatting script(s) ..." + for i in `cat lvm-vg.bsi | awk '{print $1}'`; do + cat >$cwd/format.$i <>$cwd/format.$i + echo "mkswap $check $disk" >>$cwd/format.$i + echo "echo \"\"" >>$cwd/format.$i + done + # Find ext2 partitions in mount output + k=`grep "^$mapper" mount.ext2.bsi | cut -d ' ' -f 1` + for disk in $k; do + echo "echo \"Formating $disk -- ext2 partition\"" >>$cwd/format.$i + label=`grep "^$disk on" mount.ext2.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1` + if [ x$label = x ] ; then + echo "mke2fs -v \$check $disk" >>$cwd/format.$i + else + echo "mke2fs -v \$check -L $label $disk" >>$cwd/format.$i + fi + echo "echo \"\"" >>$cwd/format.$i + done + # Find ext3 partitions in mount output + k=`grep "^$mapper" mount.ext3.bsi | cut -d ' ' -f 1` + for disk in $k; do + echo "echo \"Formating $disk -- ext3 partition\"" >>$cwd/format.$i + label=`grep "^$disk on" mount.ext3.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1` + if [ x$label = x ] ; then + echo "mke2fs -v -j \$check $disk" >>$cwd/format.$i + else + echo "mke2fs -v -j \$check -L $label $disk" >>$cwd/format.$i + fi + echo "echo \"\"" >>$cwd/format.$i + done + # Find reiserfs partitions in mount output + k=`grep "^$mapper" mount.rei.bsi | cut -d ' ' -f 1` + for disk in $k; do + echo "echo \"Formating $disk -- reiser partition\"" >>$cwd/format.$i + label=`grep "^$disk on" mount.rei.bsi | cut -d ' ' -f 7 | cut -c2- | cut -d ] -f 1` + if [ x$label = x ] ; then + echo "mkereiserfs -V \$check $disk" >>$cwd/format.$i + else + echo "mkereiserfs -V \$check -L $label $disk" >>$cwd/format.$i + fi + echo "echo \"\"" >>$cwd/format.$i + done + chmod 755 $cwd/format.$i + done +fi + +cd $cwd + +# +# Create network start script +# +ifconfig eth0 2>/dev/null >/dev/null +if [ $? = 0 ] ; then + ip=`ifconfig eth0 | grep inet | head -1 | sed -n 's/\ \+inet addr:\([0-9]\+\(\.[0-9]\+\)\{3\}\).*/\1/p'` + cat >start_network <start_network +fi +# Try eth1 +ifconfig eth1 2>/dev/null >/dev/null +if [ $? = 0 ] ; then + ip=`ifconfig eth1 | grep inet | head -1 | sed -n 's/\ \+inet addr:\([0-9]\+\(\.[0-9]\+\)\{3\}\).*/\1/p'` + cat >>start_network <>start_network <mount_drives <${TMP1} +sed -n 's/\(^.*\)\ on\ \(.*\)\ type.*$/\1 \/mnt\/disk\2/p' $di/mount.ext3.bsi >>${TMP1} +sed -n 's/\(^.*\)\ on\ \(.*\)\ type.*$/\1 \/mnt\/disk\2/p' $di/mount.rei.bsi >>${TMP1} +# sort so that / is first +sort -k 2 <${TMP1} >${TMP2} +# output mkdir followed by its mount +sed -n 's/\(^.*\)\ \(.*$\)/mkdir -p \2\ +mount \1 \2/p' ${TMP2} >>mount_drives + +# Now build unmount_drives +cat >umount_drives <${TMP2} +sed -n 's/\(^.*\)\ \(.*$\)/umount \2/p' ${TMP2} >>umount_drives +echo "umount /mnt/cdrom 2>/dev/null >/dev/null" >>umount_drives +echo "sync" >>umount_drives +echo "sync" >>umount_drives + +rm -f ${TMP1} ${TMP2} + +chmod 755 mount_drives umount_drives +echo "Done building scripts." diff --git a/rescue/linux/usb/partitionusb b/rescue/linux/usb/partitionusb new file mode 100755 index 0000000..b21fd5c --- /dev/null +++ b/rescue/linux/usb/partitionusb @@ -0,0 +1,64 @@ +#!/bin/sh +# +# Partition the USB stick -- the stick is assumed to be at least 3GB in size +# +# First delete all existing partitions +# + +if [ ! `whoami` = "root" ] ; then + echo "" + echo "You need to be root to run this shell script" + echo "" + exit 1 +fi +if [ "x$USB_DEVICE" = "x" ] ; then + if [ "x$1" = "x" ] ; then + echo "You must supply the USB device name on the command line or in USB_DEVICE" + exit 1 + else + dev=$1 + fi +else + dev=$USB_DEVICE +fi +echo "This script will distroy everything on $dev" +echo "Answer yes to continue " +read a +if [ "$a" != "yes" ] ; then + echo "Device $dev unchanged" + exit 1 +fi + +fdisk $dev < ${size}k) to copy live media in ${copytodev}." + return 1 + fi + + # begin copying.. + mkdir "${copyto}" + echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}" + mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}" + + # add by penk + for target in autorun.inf boot boot.catalog casper info initrd.gz logo.ico misc opt vmlinuz; do + cp -a ${copyfrom}/${target} ${copyto} # "cp -a" from busybox also copies hidden files + done + + umount ${copyfrom} + mount -r -o move ${copyto} ${copyfrom} + rmdir ${copyto} + return 0 +} + +do_netmount() { + rc=1 + + modprobe "${MP_QUIET}" af_packet # For DHCP + + ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config + + if [ "${NFSROOT}" = "auto" ]; then + NFSROOT=${ROOTSERVER}:${ROOTPATH} + fi + + [ "$quiet" != "y" ] && log_begin_msg "Trying netboot from ${NFSROOT}" + + if [ "${NETBOOT}" != "nfs" ] && do_cifsmount ; then + rc=0 + elif do_nfsmount ; then + NETBOOT="nfs" + export NETBOOT + rc=0 + fi + + [ "$quiet" != "y" ] && log_end_msg + return ${rc} +} + +do_nfsmount() { + rc=1 + modprobe "${MP_QUIET}" nfs + if [ -z "${NFSOPTS}" ]; then + NFSOPTS="" + fi + + [ "$quiet" != "y" ] && log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}" + # FIXME: This for loop is an ugly HACK round an nfs bug + for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do + nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break + sleep 1 + done + return ${rc} +} + +do_cifsmount() { + rc=1 + if [ -x "/sbin/mount.cifs" ]; then + if [ -z "${NFSOPTS}" ]; then + CIFSOPTS="-ouser=root,password=" + else + CIFSOPTS="${NFSOPTS}" + fi + + [ "$quiet" != "y" ] && log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}" + modprobe "${MP_QUIET}" cifs + + if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}" ; then + rc=0 + fi + fi + return ${rc} +} + +do_snap_copy () +{ + fromdev="${1}" + todir="${2}" + snap_type="${3}" + + size=$(fs_size "${fromdev}" "" "used") + + if [ -b "${fromdev}" ]; then + # look for free mem + if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]; then + todev=$(cat /proc/mounts | grep -s " $(base_path ${todir}) " | awk '{print $1}' ) + freespace=$(df -k | grep -s ${todev} | awk '{print $4}') + else + freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - )) + fi + + tomount="/mnt/tmpsnap" + if [ ! -d "${tomount}" ] ; then + mkdir -p "${tomount}" + fi + + fstype=$(get_fstype "${fromdev}") + if [ -n "${fstype}" ]; then + # Copying stuff... + mount -t "${fstype}" -o ro "${fromdev}" "${tomount}" + cp -a "${tomount}"/* ${todir} + umount "${tomount}" + else + log_warning_msg "Unrecognized fstype: ${fstype} on ${fromdev}:${snap_type}" + fi + + rmdir "${tomount}" + if echo ${fromdev} | grep -qs loop; then + losetup -d "${fromdev}" + fi + return 0 + else + return 1 + [ "$quiet" != "y" ] && log_warning_msg "Unable to find the snapshot ${snap_type} medium" + fi +} + +try_snap () +{ + # Look for $snap_label.* in block devices and copy the contents to $snap_mount + # and remember the device and filename for resync on exit in casper.init + + snap_label="${1}" + snap_mount="${2}" + snap_type="${3}" + + snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2") + if [ ! -z "${snapdata}" ]; then + snapdev="$(echo ${snapdata} | cut -f1 -d ' ')" + snapback="$(echo ${snapdata} | cut -f2 -d ' ')" + snapfile="$(echo ${snapdata} | cut -f3 -d ' ')" + if echo "${snapfile}" | grep -qs '\(squashfs\|ext2\)'; then + # squashfs or ext2 snapshot + dev=$(get_backing_device "${snapback}/${snapfile}") + if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}"; then + log_warning_msg "Impossible to include the ${snapfile} Snapshot" + return 1 + fi + else + # cpio.gz snapshot + if ! (cd "${snap_mount}" && zcat "${snapback}/${snapfile}" | cpio -i -u -d 2>/dev/null) ; then + log_warning_msg "Impossible to include the ${snapfile} Snapshot" + return 1 + fi + fi + umount "${snapback}" + else + dev=$(find_cow_device "${snap_label}") + if [ -b ${dev} ]; then + if echo "${dev}" | grep -qs loop; then + # strange things happens, user confused? + snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' ) + snapfile=$(basename ${snaploop}) + snapdev=$(cat /proc/mounts | awk '{print $2,$1}' | grep -es "^$( dirname ${snaploop} )" | cut -f2 -d ' ') + else + snapdev="${dev}" + fi + if ! do_snap_copy "${dev}" "${snap_mount}" "${snap_type}" ; then + log_warning_msg "Impossible to include the ${snap_label} Snapshot" + return 1 + else + if [ -n "${snapfile}" ]; then + # it was a loop device, user confused + umount ${snapdev} + fi + fi + else + log_warning_msg "Impossible to include the ${snap_label} Snapshot" + return 1 + fi + fi + echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/casper.conf # for resync on reboot/halt + return 0 +} + +setup_unionfs() { + image_directory="$1" + rootmnt="$2" + + modprobe squashfs + + # 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 + rofsstring="" + rofslist="" + if [ "${NETBOOT}" = "nfs" ] ; then + roopt="nfsro" # go aroung a bug in nfs-unionfs locking + else + roopt="ro" + fi + + mkdir -p "${croot}" + for image_type in "ext2" "squashfs" "dir" ; do + for image in "${image_directory}"/*."${image_type}"; do + imagename=$(basename "${image}") + if [ -d "${image}" ]; then + # it is a plain directory: do nothing + rofsstring="${image}=${roopt}:${rofsstring}" + rofslist="${image} ${rofslist}" + elif [ -f "${image}" ]; then + backdev=$(get_backing_device "$image") + fstype=$(get_fstype "${backdev}") + if [ "${fstype}" = "unknown" ]; then + panic "Unknown file system type on ${backdev} (${image})" + fi + if [ -z "${fstype}" ]; then + fstype=squashfs + fi + mkdir -p "${croot}/${imagename}" + mount -t "${fstype}" -o ro "${backdev}" "${croot}/${imagename}" || panic "Can not mount $backdev ($image) on ${croot}/${imagename}" && rofsstring="${croot}/${imagename}=${roopt}:${rofsstring}" && rofslist="${croot}/${imagename} ${rofslist}" + fi + done + done + rofsstring=${rofsstring%:} + + mkdir -p /cow + cowdevice="tmpfs" + cow_fstype="tmpfs" + + # Looking for "${root_persistence}" device or file + if [ -n "${PERSISTENT}" ]; then + cowprobe=$(find_cow_device "${root_persistence}") + if [ -b "${cowprobe}" ]; then + cowdevice=${cowprobe} + cow_fstype=$(get_fstype "${cowprobe}") + else + [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent medium" + fi + fi + + mount ${cowdevice} -t ${cow_fstype} -o rw /cow || panic "Can not mount $cowdevice on /cow" + + # add by penk + if grep -q aufs /proc/cmdline; then + modprobe aufs + mount -t aufs -o dirs=/cow=rw:$rofsstring unionfs "$rootmnt" || panic "Unionfs (aufs) mount failed" + else + modprobe "${MP_QUIET}" -b unionfs + mount -t unionfs -o dirs=/cow=rw:$rofsstring unionfs "$rootmnt" || panic "Unionfs (unionfs) mount failed" + fi + + # Adding other custom mounts + if [ -n "${PERSISTENT}" ]; then + # directly mount /home + # FIXME: add a custom mounts configurable system + homecow=$(find_cow_device "${home_persistence}" ) + if [ -b "${homecow}" ]; then + mount -t $(get_fstype "${homecow}") -o rw "${homecow}" "${rootmnt}/home" + export HOMEMOUNTED=1 # used to proper calculate free space in do_snap_copy() + else + [ "$quiet" != "y" ] && log_warning_msg "Unable to find the persistent home medium" + fi + # Look for other snapshots to copy in + try_snap "${root_snapshot_label}" "${rootmnt}" "ROOT" + try_snap "${home_snapshot_label}" "${rootmnt}/home" "HOME" + fi + + if [ -n "${SHOWMOUNTS}" ]; then + for d in ${rofslist}; do + mkdir -p "${rootmnt}/casper/${d##*/}" + case d in + *.dir) # do nothing # mount -o bind "${d}" "${rootmnt}/casper/${d##*/}" + ;; + *) mount -o move "${d}" "${rootmnt}/casper/${d##*/}" + ;; + esac + done + # shows cow fs on /cow for use by casper-snapshot + mkdir -p "${rootmnt}/cow" + mount -o bind /cow "${rootmnt}/cow" + fi + + # 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 () +{ + sysdev="${1}" + devname="${2}" + 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 + if is_casper_path $mountpoint; then + echo $mountpoint + return 0 + else + 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}") + 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}" = "ext3" -o \ + "${fstype}" = "ext2" ]; then + # This is an ugly hack situation, the block device has + # an image directly on it. It's hopefully + # casper, so take it and run with it. + ln -s "${devname}" "${devname}.${fstype}" + echo "${devname}.${fstype}" + return 0 + fi + done + return 1 +} + +pulsate() { + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "PULSATE" + fi +} + +set_usplash_timeout() { + if [ -x /sbin/usplash_write ]; then + /sbin/usplash_write "TIMEOUT 120" + fi +} + +mountroot() { + exec 6>&1 + exec 7>&2 + exec > casper.log + exec 2>&1 + + # add by penk + parse_cmdline + + set_usplash_timeout + [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-premount" + pulsate + run_scripts /scripts/casper-premount + [ "$quiet" != "y" ] && log_end_msg + + # Needed here too because some things (*cough* udev *cough*) + # changes the timeout + + set_usplash_timeout + + if [ ! -z "${NETBOOT}" ]; then + if do_netmount ; then + livefs_root="${mountpoint}" + else + panic "Unable to find a the network rootfs live file system" + 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 $i) + if [ "${livefs_root}" ]; then + break + fi + sleep 1 + done + fi + + if [ -z "${livefs_root}" ]; then + panic "Unable to find a medium containing a live file system" + 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 + + mount_images_in_directory "${livefs_root}" "${rootmnt}" + + log_end_msg + + maybe_break casper-bottom + [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/casper-bottom" + + pulsate + run_scripts /scripts/casper-bottom + [ "$quiet" != "y" ] && log_end_msg + + exec 1>&6 6>&- + exec 2>&7 7>&- + cp casper.log "${rootmnt}/var/log/" +} diff --git a/rescue/linux/usb/prebuilt/initrd.gz b/rescue/linux/usb/prebuilt/initrd.gz new file mode 100644 index 0000000..b6949a9 Binary files /dev/null and b/rescue/linux/usb/prebuilt/initrd.gz differ diff --git a/rescue/linux/usb/prebuilt/syslinux.cfg b/rescue/linux/usb/prebuilt/syslinux.cfg new file mode 100644 index 0000000..c6a9dea --- /dev/null +++ b/rescue/linux/usb/prebuilt/syslinux.cfg @@ -0,0 +1,40 @@ +DEFAULT persistent +GFXBOOT bootlogo +APPEND file=/preseed/kubuntu.seed boot=casper initrd=/casper/initrd.gz -- +LABEL persistent + menu label ^Start Kubuntu saving changes to USB + kernel /casper/vmlinuz + append file=/preseed/kubuntu.seed boot=casper persistent initrd=/casper/initrd.gz -- +LABEL live + menu label ^Run Kubuntu without saving changes + kernel /casper/vmlinuz + append file=/preseed/kubuntu.seed boot=casper initrd=/casper/initrd.gz -- +LABEL live-install + menu label ^Install Kubuntu + kernel /casper/vmlinuz + append file=/preseed/kubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.gz -- +LABEL rescue + menu label ^Rescue a broken system + kernel /casper/vmlinuz + append file=/preseed/cli.seed boot=casper persistent rescue/enable=true initrd=/casper/initrd.gz -- +LABEL memtest + menu label Test ^memory + kernel mt86plus + append - +LABEL hd + menu label ^Boot from first hard disk + localboot 0x80 + append - +DISPLAY isolinux.txt +TIMEOUT 300 +PROMPT 1 +F1 f1.txt +F2 f2.txt +F3 f3.txt +F4 f4.txt +F5 f5.txt +F6 f6.txt +F7 f7.txt +F8 f8.txt +F9 f9.txt +F0 f10.txt