[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [debian-knoppix] iso booting without cloop



Niall Walsh wrote:

Hi again :-)

I'm interested in seeing booting from iso working in Knoppix.

And I still am :-)

Attached is a patch to the linuxrc from the minirt26 of Knoppix 3.7.

For this patch to work you also need to adjust the minirt as follows:

1.   Make an /isosrc directory
2.   Put the loop.*o module in /modules
3. Put Fabian's tiny-losetup into /static (from http://debian.tu-bs.de/knoppix/experiments/tiny-losetup/ Thanks Fabian)

It will support ntfs aswell if the ntfs.*o module is added to /modules.

If you add a mount to /static it will try and mount vfat or ntfs partitions uid=1000,gid=1000.

Now I started to think about trying to rework the modules disk loading code so it could load the loop ntfs module from a floppy image, but I thought I should just send this first and save that for another day.

Also included in here is a little adjustment to not try and use the parallel cd drive if "NOCD" has been passed. Forgive me if this is wrong!

The fromiso cheatcode works as follows:

On it's own it will make the linuxrc scan for KNOPPIX/KNOPPIX within KNOPPIX/KNOPPIX.ISO

You can set knoppix_iso_dir (default KNOPPIX) and/or knoppix_iso_name (default KNOPPIX.ISO) to look elsewhere

As fromiso=foo/bar.iso it will scan for KNOPPIX/KNOPPIX within foo/bar.iso, this overwrites knoppix_iso_* cheatcodes

Wildcards are fine in fromiso and knoppix_iso_*.

fromhd will work as always to allow you to specify the device to check, otherwise it will check the same devices it would have checked for a cd.

When fromiso is set it mounts the discs/partitions on /isosrc and then if it finds the iso it uses the losetup to setup /dev/loop0 and mounts it on /cdrom. The only side real unexpected side effect I have come across is the problem where you cannot work as normal on the drive mounted as /isosrc if it is vfat/ntfs as it will be mounted effectively uid=0 gid=0 and does not appear to be remountable.

I hope I've remembered everything!

Niall Walsh
--- linuxrc.26.37.orig	2004-11-28 23:57:02.000000000 +0000
+++ linuxrc	2004-12-03 00:49:38.000000000 +0000
@@ -44,14 +44,19 @@
 RMMOD="rmmod"
 [ -x /modules/rmmod ] && RMMOD="/modules/rmmod"
 
+[ -x /static/mount ] && USEMNTOPT="yes"
+if test -z "$USEMNTOPT" ; then MNTOPT="" ; fi
+
 # Builin filesystems
 BUILTIN_FS="iso9660 ext2 vfat"
+test -f /modules/ntfs.*o && insmod /modules/ntfs.*o && BUILTIN_FS="$BUILTIN_FS ntfs" && NTFSLOADED="y"
 
 mountit(){
 # Usage: mountit src dst "options"
 # Uses builtin mount of ash.knoppix
 for fs in $BUILTIN_FS; do
-test -b $1 && mount -t $fs $3 $1 $2 >/dev/null 2>&1 && return 0
+if test -n "$USEMNTOPT" ; then case "$fs" in vfat|ntfs) MNTOPT=" -o uid=1000,gid=1000" ; ;; *) MNTOPT="" ; ;; esac fi
+test -b $1 && mount -t $fs $MNTOPT $3 $1 $2 >/dev/null 2>&1 && return 0
 done
 return 1
 }
@@ -126,6 +131,7 @@
 case "$CMDLINE" in *nousb*|*nobootusb*) NOUSB="yes"; ;; esac
 case "$CMDLINE" in *nofirewire*|*nobootfirewire*) NOFIREWIRE="yes"; ;; esac
 NOCD=""
+case "$CMDLINE" in *fromiso*) FROMISO="yes"; LOADLOOP="yes"; ;; esac
 case "$CMDLINE" in *fromhd*) NOCD="yes"; ;; esac
 case "$CMDLINE" in *fromdvd*) FROMDVD="yes"; ;; esac
 case "$CMDLINE" in *idecd*|*atapicd*) IDECD="yes"; ;; esac
@@ -136,6 +142,22 @@
 KNOPPIX_NAME="KNOPPIX"
 case "$CMDLINE" in *knoppix_dir=*) KNOPPIX_DIR="$knoppix_dir"; ;; esac
 case "$CMDLINE" in *knoppix_name=*) KNOPPIX_NAME="$knoppix_name"; ;; esac
+KNOPPIX_ISO_DIR="KNOPPIX"
+KNOPPIX_ISO_NAME="KNOPPIX.ISO"
+case "$CMDLINE" in *knoppix_iso_dir=*) KNOPPIX_ISO_DIR="$knoppix_iso_dir"; ;; esac
+case "$CMDLINE" in *knoppix_iso_name=*) KNOPPIX_ISO_NAME="$knoppix_iso_name"; ;; esac
+KNOPPIX_ISO="$KNOPPIX_ISO_DIR/$KNOPPIX_ISO_NAME"
+case "$CMDLINE" in *fromiso=*) KNOPPIX_ISO="$fromiso"; ;; esac
+
+# fromiso needs the loop module and Fabian's losetup
+if test -n "$LOADLOOP"
+then
+test -f /modules/loop.*o && insmod /modules/loop.*o || LOADLOOP=""
+if test -z "$LOADLOOP"
+then
+echo -n "${RED}Loop module requested but not loaded!${NORMAL}"
+fi
+fi
 
 # WARNING: In Kernel 2.4.27, CD-Roms cease to work if both, ide-scsi and ide-cd, are loaded. :-(
 if test -n "$IDECD"; then
@@ -317,13 +339,15 @@
 DEVICES="/dev/hd?"
 test -n "$FOUND_SCSI" -a -z "$NOCD" && DEVICES="/dev/scd? /dev/scd?? $DEVICES"
 # New: Also try parallel port CD-Roms [for Mike].
-DEVICES="$DEVICES /dev/pcd?"
+test -z "$NOCD" && DEVICES="$DEVICES /dev/pcd?"
 # New: also check HD partitions for a KNOPPIX/KNOPPIX image
 test -n "$FOUND_SCSI" -a -z "$NOSCSI" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9]"
 DEVICES="$DEVICES /dev/hd?[1-9] /dev/hd?[1-9][0-9]"
 case "$CMDLINE" in *fromhd=/dev/*) DEVICES="$fromhd"; ;; esac
 for i in $DEVICES
 do
+if test -z "$FROMISO"
+then
 echo -n "${CRE}${BLUE}Looking for CDROM in: ${MAGENTA}$i${NORMAL}   "
 if mountit $i /cdrom "-o ro" >/dev/null 2>&1
 then
@@ -335,6 +359,28 @@
 fi
 umount /cdrom
 fi
+else
+if mountit $i /isosrc "-o ro" >/dev/null 2>&1
+then
+if test -f /isosrc/$KNOPPIX_ISO
+then
+losetup /dev/loop0 /isosrc/$KNOPPIX_ISO
+if mount -t iso9660 -o ro /dev/loop0 /cdrom >/dev/null 2>&1
+then
+if test -f /cdrom/$KNOPPIX_DIR/$KNOPPIX_NAME
+then
+echo -n "${CRE} ${GREEN}Accessing KNOPPIX IMAGE at ${MAGENTA}$i/$KNOPPIX_ISO${GREEN}...${NORMAL}"
+FOUND_KNOPPIX="$i/$KNOPPIX_ISO"
+break
+fi
+umount /cdrom
+# if you use a normal losetup this would need to be losetup -d /dev/loop0
+fi
+losetup /dev/loop0
+fi
+umount /isosrc
+fi
+fi
 done
 
 # Harddisk-installed script part version has been removed
@@ -380,7 +426,7 @@
   
   # load filesystems
   /KNOPPIX/sbin/modprobe reiserfs
-  /KNOPPIX/sbin/modprobe ntfs    # BE CAREFUL! - Only mount it read only! - FF
+  if test -z "$NTFSLOADED" ; then /KNOPPIX/sbin/modprobe ntfs ; fi   # BE CAREFUL! - Only mount it read only! - FF
  
   if [ -n "$ISO_PATH" ]
   then
@@ -388,7 +434,7 @@
      LOOP_SOURCE2="$LOOP_SOURCE"
      TARGET_DEV="$LOOP_SOURCE$ISO_PATH"
      /bin/mkdir $LOOP_SOURCE
-     /KNOPPIX/sbin/modprobe loop
+     if test -z $LOADLOOP ; then /KNOPPIX/sbin/modprobe loop ; fi
 
      /bin/mount -o ro $LOOP_DEV $LOOP_SOURCE || LOOP_SOURCE=""
      /bin/mount -n -o loop $LOOP_SOURCE2$ISO_PATH $TARGET

Reply to: