<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/1.1.8">
  <TITLE>Boot KNOPPIX from an USB Memory Stick</TITLE>
</HEAD>
<BODY>
Guys,<BR>
<BR>
I really enjoyed our meeting yesterday.<BR>
Greg and phil expressed an interest in some of the things you can do with KNOPPIX. Here is the first.<BR>
<BR>
Regards,<BR>
<BR>
Andrew Ballantine<BR>
<BR>
&nbsp;<BR>
&nbsp;<BR>

<HR>

<H1>Boot KNOPPIX from an USB Memory Stick</H1>
<H2>What you'll need:</H2>
<UL>
    <LI><A HREF="http://www.knoppix.net/">Knoppix</A> or an already <A HREF="http://www.knoppix.net/docs/index.php/KnoppixCustomizations">stripped down version</A>
    <LI>USB Memory Stick 
    <LI>Computer capable of booting from USB 
    <LI>kernel with cloop-support 
    <LI>syslinux 
</UL>
<BR>
<H2>Preparing everything:</H2>
I used <A HREF="http://www.damnsmalllinux.org/">Damn Small Linux</A> for this (it's only 51MB and has fluxbox ;-), but every other stripped down Knoppix version should do (if you have enough space on your memory stick).<BR>
You can also strip down your own version of knoppix (see the <A HREF="http://www.knoppix.net/docs/index.php/FaqCustomising">Knoppix Customising FAQ).</A><BR>
<BR>
<BR>
<BR>
<H2>Modifying miniroot.gz:</H2>
First you need to modify the boot-image (KNOPPIX/boot.img). Mount it (mount -o loop boot.img /mnt) and copy everything in a directory (e.g. ~/knoppix-usb/bootdisk). You need to modify <FONT SIZE="3"><B>linuxrc</B></FONT> in <FONT SIZE="3"><B>miniroot.gz</B></FONT> and put the relevant usb modules in <FONT SIZE="3"><B>modules/usb/</B></FONT>. <BR>
<BR>
Now use gunzip to uncompress miniroot.gz and then mount it (mount -o loop miniroot /mnt). Open <FONT SIZE="3"><B>linuxrc</B></FONT> with your editor. You need to load the relevant usb-modules and <FONT SIZE="3"><B>make sure to sleep some time</B></FONT>, because the modules need some time to recognize your USB Memory stick. I put the relevant parts before the scsi modules are loaded to make sure, that my USB Memory Stick will be /dev/sda: 
<PRE># load usb-modules first (so that memory-stick becomes /dev/sda1)
# uncomment for USB 2.0 support (experimental)
#insmod -f /modules/usb/ehci-hcd.o
insmod -f /modules/usb/usbcore.o
insmod -f /modules/usb/usb-uhci.o
insmod -f /modules/usb/uhci.o
insmod -f /modules/usb/usb-ohci.o
insmod -f /modules/usb/usb-storage.o
# need to sleep because it takes some time to register things
ash -c &quot;sleep 4&quot;</PRE>
<BR>
Now you need to make sure, that your root-fs is mounted to /cdrom: I commented out the section in <FONT SIZE="3"><B>linuxrc</B></FONT> where a CDROM is searched and put the following lines in: 
<PRE># mount /dev/sda1 (memorystick to cdrom)
FOUND_KNOPPIX=&quot;/dev/sda1&quot;
mount -t vfat /dev/sda1 /cdrom</PRE>
You can get my modified linuxrc <A HREF="linuxrc">here</A><BR>
<BR>
Now we still need the usb modules (that aren't on the miniroot). Mount the compressed KNOPPIX file (insmod cloop file=PATH/KNOPPIX &amp;&amp; mount -t iso9660 /dev/cloop /cdrom) and copy the following files under /cdrom/lib/modules/$KERNELVERSION/kernel/drivers/usb/ to /mnt/modules/usb/:<BR>
<FONT SIZE="3"><B>ehci-hcd.o uhci.o usb-ohci.o usb-storage.o usb-uhci.o usbcore.o</B></FONT><BR>
Now you're finished modifying miniroot. Umount it and gzip the file again. <BR>
<BR>
<BR>
<H2>Preparing the Memory Stick</H2>
Create a fat-partition on your stick and format it with mkfs.vfat<BR>
Mount the memory stick<BR>
Copy the files from ~/knoppix-usb/bootdisk/ on the memory stick (that should include your modified miniroot.gz)<BR>
Copy the other files from your modified knoppix to the memory stick (the most important is KNOPPIX/KNOPPIX)<BR>
The layout on your Memory Stick should look like this: 
<PRE>sh-2.05b# ls -lR
.:
total 1576
-rw-r--r--    1 root     root           54 Apr 27 12:48 autorun.bat
-rw-r--r--    1 root     root           47 Apr 27 12:48 autorun.inf
-rw-r--r--    1 root     root          180 Apr 27 12:48 boot.msg
-rw-r--r--    1 root     root         1759 Apr 27 12:48 f2
-rw-r--r--    1 root     root          256 Apr 27 12:48 german.kbd
dr-xr--r--    2 root     root         4096 Apr 27 12:48 knoppix
-rw-r--r--    1 root     root         3262 Apr 27 12:48 knoppix.ico
-r--r--r--    1 root     root         7836 Apr 27 12:51 ldlinux.sys
-rw-r--r--    1 root     root        34395 Apr 27 12:48 logo.16
-rw-r--r--    1 root     root       607866 Apr 27 14:03 miniroot.gz
-rw-r--r--    1 root     root         2402 Apr 27 12:48 syslinux.cfg
-rw-r--r--    1 root     root       921602 Apr 27 12:48 vmlinuz

./knoppix:
total 50820
-rw-r--r--    1 root     root         2048 Apr 27 12:48 boot.cat
-rw-r--r--    1 root     root      1474560 Apr 27 12:48 boot.img
-rw-r--r--    1 root     root     50553629 Apr 27 04:48 knoppix
-rw-r--r--    1 root     root           27 Apr 27 12:48 mkfloppy.bat</PRE>
Now you need to get the Memory Stick bootable: umount it and run '<FONT SIZE="3"><B>syslinux /dev/sda1</B></FONT>' (or /dev/sd?1 depending on your system). <BR>
<BR>
<BR>
<H2>The ugly part: booting</H2>
If you're lucky your computer will boot out of the box when you select <FONT SIZE="3"><B>USB ZIP</B></FONT> as a bootdevice. Otherwise read on... <BR>
<BR>
<UL>
    <LI>You can try the other USB Boot Options (Floppy, CD-ROM, Harddisk), if still nothing happens you might have to enable USB Keyboard Support in your BIOS (needed on some motherboards with AMI BIOS and a Via chipset, including Epia-m and Shuttle mv42n). 
    <LI>On some broken boards (like my Epia-M...) you need to plug the memory stick in without any power (remove your power plug), otherwise the BIOS might not recognize the memory stick. 
    <LI>If your BIOS boots from the Memory Stick, but you can see only sequences of ones and zeroes, you can try an alternative bootsector from <A HREF="http://www.8ung.at/spblinux/">spblinux</A>. As the site is sometimes down you can download the bootsector <A HREF="spb2_mbr.sec">here</A>(Version 1.01). Just put this one on /dev/sda and try it out (<FONT SIZE="3"><B>dd if=spb2_mbr.sec of=/dev/sda</B></FONT>). Many thanks to Christian Ostheimer for his great work (I didn't believe anymore in booting from USB, but his spblinux made it possible ;-) 
</UL>
You can get my modified Damn Small Linux <A HREF="damnsmall-0.3.6-usb.tar">here (52 MB)</A><BR>
<BR>
Comments to: <A HREF="mailto:an@droi.de">Matthias M&#252;ller</A> 
<HR>
<FONT SIZE="2">Last update: Sun Jun 1 20:45:48 CEST 2003 </FONT><BR>
<FONT SIZE="3"><BR>
*****************************************************************<BR>
This email has been checked by the altohiway e-Sweeper Service<BR>
*****************************************************************</FONT><BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
-- <BR>
Andrew Ballantine &lt;<A HREF="mailto:andrewballantine@btconnect.com">andrewballantine@btconnect.com</A>&gt;<BR>
Ballantine Projects Ltd
</TD>
</TR>
</TABLE>

</BODY>
</HTML>