Package: casper
Version: 1.77+debian-2
Severity: wishlist
Tags: patch

Another patch from me. :-)

Here's the situation it is intended for: I have a computer which is supposed
to be started without a keyboard or monitor attached.  Noise is a concern, so
the idea is to tun everything from a USB-stick.  However, if the USB-stick is
not available for some reason, there is a hard-disk which also contains the
system.

So I want casper to find my USB-stick and boot from it if possible.  But if it
cannot find it, it should boot from the hard disk (which also contains a
casper system).  Which device the BIOS booted from is irrelevant: when it
boots from hard disk, I still want to have casper detect the USB-stick and
ignore the hard disk.

The problem is that USB mass storage takes a while to work.  In that time,
casper has tried to find a file system several times.  Well, it should have
anyway.  What it did is find the system on the hard disk and use that.  Even
if I specify live-media=/dev/sda2.

The attached patch fixes that, by allowing an extra commandline option,
live-media-timeout, to be used in conjunction with live-media.  If it is
specified, auto-detection will not happen until the timeout has expired (but
only the specified live-media is tried).  Thus it is possible to use the
USB-stick even though it shows up late, but still use the hard disk if the
stick isn't present.

Also, the patch fixes the "ugly hack" situation, which once again had a syntax
error in it.  Does that get used by anyone?  I'm just asking, because it seems
to be broken all the time. ;-)

Note that I didn't actually test this patch, I'll probably do that tonight or
tomorrow.  I just wanted to let you know about it already.

Thanks,
Bas

-- 
I encourage people to send encrypted e-mail (see http://www.gnupg.org).
If you have problems reading my e-mail, use a better reader.
Please send the central message of e-mails as plain text
   in the message body, not as HTML and definitely not as MS Word.
Please do not use the MS Word format for attachments either.
For more information, see http://pcbcn10.phys.rug.nl/e-mail.html
diff -upr casper.orig/scripts/casper casper-1.77+debian/scripts/casper
--- casper.orig/scripts/casper  2006-11-06 15:11:27.000000000 +0100
+++ casper-1.77+debian/scripts/casper   2006-11-06 15:29:58.000000000 +0100
@@ -64,6 +64,8 @@ parse_cmdline ()
                 export LIVEMEDIA=${x#bootfrom=} ;;
             live-media=*)
                 export LIVEMEDIA=${x#live-media=} ;;
+           live-media-timeout=*)
+               export LIVEMEDIA_TIMEOUT=${x#live-media-timeout=} ;;
             debian-installer/locale=*)
                 export LOCALE=${x#debian-installer/locale=} ;;
             locale=*)
@@ -497,6 +499,12 @@ find_livefs() {
         if check_dev "null" "${LIVEMEDIA}"; then
             return 0
         fi
+       # don't start autodetection before timeout has expired
+       if [ ! -z "${LIVEMEDIA_TIMEOUT}" ]; then
+           if [ "$1" -lt "${LIVEMEDIA_TIMEOUT}" ]; then
+               return 1
+           fi
+       fi
     fi
     # or do the scan of block devices
     for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v 
ram); do
@@ -513,7 +521,7 @@ find_livefs() {
                 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
@@ -565,8 +573,8 @@ mountroot() {
         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)
+        for i in $(seq 0 19); do
+            livefs_root=$(find_livefs $i)
             if [ ! -z "${livefs_root}" ]; then
                 break
             fi

Attachment: signature.asc
Description: Digital signature

Reply via email to