-
Junior Member
registered user
Making Knoppix 3.6 Bootable from a 1 GB USB Flash Memory Stick
2004/10/28 pbs
REQUIRED: 1 GB or more USB stick, Knoppix_V3.6-2004-08-16-EN CD or similar, and an alert mind.
I've benefited from many suggestions on the web. In kind thanks, here is a yet more "compleat" and commented recipe.
PREPARATION:
Read everything through completely before beginning.
Be awake and alert! While experimenting and learning (the hard way!), I corrupted a couple hard disk partition tables by mistyping -- sda and hda are one character apart, and subconcious habits are dominant when weary! Backups are good. If you decide to try this, the consequences are yours.
You'll need to be root for these operations. CTRL-ALT-F1 (or F2,F3,F4) is a quick way to switch to root console access, CTRL-ALT-F5 puts you back into the GUI as knoppix rather than as root. Depending on how your hardware is assigned at boot time, the USB stick may be referenced as sda, sdb, or sdc, etc. Notice there is a difference between /dev/sda and /dev/sda1, being the entire drive as a block device or its first partition respectively.
Backup any important files on your USB to a folder on another disk; the USB stick WILL be reformatted in the process below, and it is then very easy to copy them back afterwards.
Backup sector 0 from the USB stick (and any other important hard drive!) somewhere safe like onto a floppy. It contains the MBR in the first 306 bytes and the partition table for the first four partitions in the remaining 206 bytes. If need be and you've goofed, you can replace this later by swapping input if= and output of= locations (don't mix them up). Five minutes now can save days of recovery later.
dd if=/dev/sda of=/dev/fd0/myUSBMBR.bin bs=512 count=1
dd if=/dev/hda of=/dev/fd0/myHDMBR.bin bs=512 count=1
PROCESS:
Partition and format the USB stick. This will wipe out your previous data! Use cfdisk to create a partition >700 Mb (not sure how much is needed), make it bootable and of type 06 for FAT16, and lastly write the configuration back to USB. The menus are easy to use.
cfdisk /dev/sda
...
mkdosfs /dev/sda1
Download free SysLinux 2.11 (http://syslinux.zytor.com/) to get a viable MBR for the USB stick. The next commands transfer only 306 bytes rather than 512 because mbr.bin is only that long, leaving the trailing 206 partition table bytes of the sector unchanged.
cd /Path/To/Unpacked/Syslinux2.11/
dd if=./mbr.bin of=/dev/sda
Use syslinux to install ldlinux.sys located at beginning of partition (it doesn't have to be redone later, and both v2.04 included with knoppix or v2.11 worked fine for me).
./syslinux /dev/sda1
Now copy the boot files from the CD.
mkdir /mnt/sda1
mount -t vfat /dev/sda1 /mnt/sda1
cp /cdrom/boot/isolinux/* /mnt/sda1
cd /mnt/sda1
mv isolinux.cfg syslinux.cfg
rm isolinux.bin
rm boot.cat
Edit linuxrc inside minirt24.gz (repeat for minirt26.gz if you want)
cp minirt*.gz /tmp
gunzip /tmp/m*.gz
mkdir /mnt/m24
mkdir /mnt/m26
mount /tmp/minirt24.gz /mnt/m24 -o loop -o rw
mount /tmp/minirt26.gz /mnt/m26 -o loop -o rw
Edit /mnt/m24/linuxrc and add a line midway through the file ...
test -n "$FOUND_USB" -a -z "$NOUSB" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9]"
... as shown in the following snippet which shows the lines immediately prior and after. Find it by looking for the commented section line reading
# Now that the right SCSI driver is (hopefully) loaded, try to find CDROM
<snip>
test -n "$FOUND_SCSI" -a -z "$NOSCSI" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9]"
test -n "$FOUND_USB" -a -z "$NOUSB" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9]"
DEVICES="$DEVICES /dev/hd?[1-9] /dev/hd?[1-9][0-9]"
<snip>
If you edited it somewhere else as knoppix (e.g. in the GUI), then copied it back as root,
you may have to set linuxrc back to being root owned.
ls -al
chown root:root /mnt/m24/linuxrc
ls -al
To repeat this for /mnt/m26, you can just copy the file as both kernel 2.4 and 2.6
linuxrc files were identical in KNXv3.6 when I compared them with diff.
cp /mnt/mr24/linuxrc /mnt/m26
Umount, recompress, and put back on USB stick. Minirt*.gz already has the necessary USB driver files and appropriate sleep times in it now, so there's no need to add those.
umount /mnt/m2*
gzip -9 /tmp/mini*
cp /tmp/mini*.gz /mnt/sda1
Now copy over the Knoppix directory from the cdrom. Have patience, it's big, and you're probably working at USB1.0 rather than USB2.0 speeds as that's the tested Knoppix default.
cp -r /cdrom/knoppix /mnt/sda1
If you like the initial webpage at startup, then copy
cp /cdrom/index.html /mnt/sda1
Unmount USB stick and WAIT for changes to finish writing.
umount /dev/sda1
Select boot from usb in your PC BIOS -- the specifics are system dependent -- and reboot.
FINAL NOTES:
If upon booting you want the USB stick to be writeable, you'll have to mount it again as a loop device. The USB partition containing /KNOPPIX/Knoppix file system is already mounted as read-only, and unfortunately the default desktop icon Hard Disk [sda1] refers to that. Create a new mount point /mnt/myusb to write to the drive.
mkdir /mnt/myusb
mount /dev/sda1 /mnt/myusb -o loop -o rw
ALWAYS remember to unmount the new USB stick access point first to save all cached changes before quitting, or you might corrupt the stick and have to start completely over.
umount /mnt/myusb
Hint: if it won't unmount, close all GUI windows that display this drive, cd / to get out of /mnt/myusb in all work spaces, e.g. CTRL-ALT-F1 to F4. You may even have to "init 3", thus closing the GUI to get stuck Konqueror inodes to release (check with "ps aux"). Then try umount /mnt/myusb again. "init 5" will restart the GUI, or "init 6" will complete the shutdown.
An alternative is to figure out how much is needed for Knoppix and it's boot files, limit the first partition size, and to create a second partition for writing user data. Starting with one partition first helps get it all working; also if everything is all in one space, if you suddenly need room on the USB from another OS or computer, you can wipe out /knoppix/knoppix, then replace it from CD later, though it may get fragmented on rewriting.
.ISO BOOT?:
Setting up the USB to boot from a .ISO stored on itself is less easy to do. It requires access to a number of programs in a non-ISO-encapsulated /knoppix/knoppix file system to accomplish the root transfer, and there's not enough room for both. I suppose one could add the necessary programs (and dependencies?) to minirt.gz, but it would likely take much more effort. Cool, but is it really worth it?
LAST RITES:
If in the process of experimenting with making the USB stick bootable, you've somehow corrupted it so badly that it cannot be mounted or reformatted under Linux or Windows, and even dd fails (yikes!) to wipe sector 0 with if=/dev/zero count=1, and feel your new stick is utterly destroyed ... don't despair. Http://www.killdisk.com has a freeware windows console utility that runs even under win2k's and winXP's direct disk access restrictions to wipe all blocks on a chosen drive to zero, with no mounting or existing format questions asked. RTFM. And triple check you've got the right drive! You can then reformat. This worked when even the HP Utility format utility got stuck.
Or worse, suppose you've wiped out the MBR and the partition table of the wrong hard drive, thus losing the starting cluster number for each partition in spite of the precautions above. You can still possibly recover it with "gpart", which will go searching for lost partition tables -- IF you've not made any further writes to the disk: i.e. don't write any type of data, don't delete and recreate partitions with cfdisk, qtparted, or whatever else tempts you. These will rewrite the very information tables needed for recovery. Best advice now is stop, relax!, have a cup of tea, and think it through before trying anything. Don't be hasty. I had already mucked everything up beyond gpart's powers before even knowing it existed, which left me rebuilding my HD from scratch. Now you at least have a valuable headstart hint, if you've read this in time.
POSTLUDE:
Good luck, go forth and multiply by sharing; enjoy your bootable, full function Knoppix USB stick with lots more applications, storage, and tinier form factor than a PDA!
Similar Threads
-
By mabhatter in forum Networking
Replies: 1
Last Post: 12-08-2005, 10:38 PM
-
By lilsirecho in forum The Lounge
Replies: 31
Last Post: 11-07-2004, 08:52 PM
-
By MaldiGola in forum Networking
Replies: 0
Last Post: 09-27-2004, 03:37 PM
-
By dvessey in forum The Lounge
Replies: 3
Last Post: 03-03-2003, 08:27 PM
-
By dvessey in forum Customising & Remastering
Replies: 14
Last Post: 02-18-2003, 01:31 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules

Intel Core i5-12500T SRL5W 2GHz 18MB 6 Core Socket LGA1700 Desktop CPU Processor
$114.99

INTEL CORE I9-10940X X-SERIES PROCESSOR | 3.30GHZ | SRGSH
$179.99

ASRock b560 ATX Motherboard + Intel Core i5-11600K CPU Combo Gaming + 32 GB DDR4
$300.00

LAST BATCH *Brand New-Sealed* AMD Ryzen 9 9950X3D2 Dual Ed. 4.3GHz 16Core AM5
$768.00

Intel Core i7-9700 Octa-Core 3 GHz Desktop Processor LGA 1151
$79.99

Intel Core i7-3770K 3.5 GHz Processor
$39.00

Intel Core I7-7700 SR338 3.60 Ghz Processor
$39.99

Intel Core i7-7700K SR33A 4.20GHz 4-Core LGA1151 CPU Processor
$62.95

AMD - Ryzen 7 5800X3D 8-Core - 16-Thread 3.4 GHz (4.5 GHz Max Boost) w/ Ice Pad
$355.99

Intel 6th Gen Core i7-6700K 4.0GHz (Turbo 4.2GHz) 4-Core LGA1151 CPU SR2L0
$38.00