Hi mika,
Hi all,

I liked it when I read in the announcement that grml-2008.11 supports a
fromiso bootoption. I wanted to use it for my USB thumb drive, so that I
can add the .iso file to it (so that I can burn a CD if I need one) and
as well boot from it (without requiring twice the space). However, it
did not work as I expected:
- it does not search for the ISO, but require the exact device name
- it does not expose the ISO partition to the booted system

So I patched the initramfs so that it supports another bootoption,
"findiso". When booting with findiso=/grml_2008.11.iso, it will look for
that .iso file on all disks where it usually looks for the .squashfs
file. When it is found, the disk containing the iso is read-only mounted
as /live/findiso (and exposed there after boot completed). The squashfs
file is searched inside that ISO file then.

It worked well in my tests, but of course that does not guarantee it is
bug-free. :)

I attached both the patch and a script I used (in a CD-booted GRML) to
apply the patch (and modify menu.lst), if anyone else wants to use it
with the current stable GRML.


regards,

Michael
diff -rup initramfs_orig/scripts/live initramfs/scripts/live
--- initramfs_orig/scripts/live 2008-12-06 12:33:00.676619000 +0000
+++ initramfs/scripts/live      2008-12-06 12:52:05.938629568 +0000
@@ -92,6 +92,11 @@ Arguments ()
                                export HOSTNAME LIVECONF
                                ;;
 
+                       findiso=*)
+                               FINDISO="${ARGUMENT#findiso=}"
+                               export FINDISO
+                               ;;
+
                        isofrom=*|fromiso=*)
                                FROMISO="${ARGUMENT#*=}"
                                export FROMISO
@@ -1365,6 +1370,17 @@ check_dev ()
        if is_supported_fs ${fstype}
        then
                mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || 
continue
+               if [ -n "${FINDISO}" ]
+               then
+                       if [ -f ${mountpoint}${FINDISO} ]; then
+                               umount ${mountpoint}
+                               mkdir /live/findiso -p
+                               mount -t ${fstype} -o ro,noatime "${devname}" 
/live/findiso
+                               loopdevname=$(setup_loop 
"/live/findiso${FINDISO}" "loop" "/sys/block/loop*" "" '')
+                               devname="${loopdevname}"
+                               mount -t iso9660 -o ro,noatime "${devname}" 
${mountpoint}
+                       fi
+               fi
 
                if is_live_path ${mountpoint} && \
                        ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
diff -rup initramfs_orig/scripts/live-bottom/05mountpoints 
initramfs/scripts/live-bottom/05mountpoints
--- initramfs_orig/scripts/live-bottom/05mountpoints    2008-12-06 
14:30:05.486694000 +0000
+++ initramfs/scripts/live-bottom/05mountpoints 2008-12-06 14:41:26.346606201 
+0000
@@ -38,4 +38,11 @@ if [ -n "$MOUNTED_ON" ] ; then
    echo "   -> Mounted live system on $MOUNTED_ON">/dev/console
 fi
 
+# Move findiso directory to the new root filesystem so that programs there can 
get at it.
+if [ -d /live/findiso -a ! -d /root/live/findiso ]
+then
+       mkdir -p /root/live/findiso
+       mount -n --move /live/findiso /root/live/findiso
+fi
+
 log_end_msg
#!/bin/sh -e
# Create an initramfs and a menu.lst that can be loaded from Grub on a USB
# key, where the ISO file is stored in the root directory
# (c) 2008 Michael Schierl
[ -n "$1" ]
cp findiso.patch /tmp
rm -rf /tmp/initramfs /tmp/x || true
mkdir /tmp/initramfs
rm -rf $1/boot/grml_2008.11 || true
mkdir -p $1/boot/grml_2008.11
cd /tmp/initramfs
zcat /live/image/boot/grml/initrd.gz | cpio -i
patch -p1 </tmp/findiso.patch
find | cpio -H newc -o | gzip --best >$1/boot/grml_2008.11/initrd.gz
sed s#boot/grml#boot/grml_2008.11# /live/image/boot/grub/menu.lst | \
        sed "s#linux26#linux26 findiso=/grml_2008.11.iso#" | \
        sed s#grub/splash#grml_2008.11/splash# | \
        sed s#-rc1## | \
        head -n 56 >$1/boot/grml_2008.11/menu.lst
cp /live/image/boot/grml/linux26 /live/image/boot/grub/splash.xpm.gz 
$1/boot/grml_2008.11
echo Done. Don"'"t forget to copy grml_2008.11.iso to $1.
_______________________________________________
Grml mailing list - [email protected]
http://lists.mur.at/mailman/listinfo/grml
join #grml on irc.freenode.org
grml-devel-blog: http://grml.supersized.org/

Reply via email to