From: Mark Huang Date: Tue, 21 Jun 2005 18:48:19 +0000 (+0000) Subject: - add support for booting from USB flash device. X-Git-Tag: planetlab-3_3-rc2~16 X-Git-Url: http://git.onelab.eu/?p=bootcd.git;a=commitdiff_plain;h=36e2a978768633b0c489e2e912297ac945f747c6 - add support for booting from USB flash device. - the way this works is to loopback mount the usual ISO9660 image, which should reside as a regular file on the (presumably FAT) filesystem on the key. --- diff --git a/conf_files/pl_sysinit b/conf_files/pl_sysinit index 50a6b5c..9ec956f 100755 --- a/conf_files/pl_sysinit +++ b/conf_files/pl_sysinit @@ -9,12 +9,15 @@ echo "pl_sysinit: invoking hardware initialization script" /etc/init.d/pl_hwinit echo "pl_sysinit: finding cd to mount on /usr" -test_devices=/sys/block/* mounted=0 initrd_version=$(/bin/cat /pl_version) mkdir /usr -for device in $test_devices; do +# so that * expands to empty string if there are no block +# devices +shopt -s nullglob + +for device in /sys/block/*; do device=$(/bin/basename $device) # skipping any devices that start with md or ra (ram) or lo (loop) or @@ -24,6 +27,28 @@ for device in $test_devices; do [ "$start_device" == "lo" ] || [ "$start_device" == "fd" ]; then continue fi + + # If this is a removable (e.g., USB flash) device, then try to + # look for an ISO image on each of its partitions. + if [ "$(cat /sys/block/$device/removable)" = "1" ] ; then + partitions=$(/bin/awk "\$4 ~ /${device}[0-9]*/ { print \$4 }" /proc/partitions) + for partition in $partitions ; do + echo "pl_sysinit: checking $partition for iso image" + if /bin/mount -o ro -t msdos,ext2 /dev/$partition /usr 2>&1 > /dev/null ; then + # Look for the first ISO image + for iso in /usr/*.iso ; do + if /sbin/losetup /dev/loop0 $iso ; then + echo "pl_sysinit: using $iso on $partition" + device="loop0" + break + fi + done + if [ "$device" != "loop0" ] ; then + /bin/umount /usr 2>&1 > /dev/null + fi + fi + done + fi echo "pl_sysinit: checking $device for /usr contents" /bin/mount -o ro -t iso9660 /dev/$device /usr 2>&1 > /dev/null