Computer Magic
Software Design Just For You
 
 



Make a boot to USB boot disk

The instructions here are specific to RedHat Fedora Core 2. I will try to note differences between FC2 and later releases. In general, the steps should be the same as those for other releases (Mandrake, etc.)

mkbootdisk
A cool little utility. This will generate a boot disk for your system. This is great because it will pack up YOUR kernel and other files. You NEED to use a boot disk that has the same kernel as your installed system. If you don’t, you will run into problems. For instance, upgrading your kernel on your drive, then using an out dated boot disk will mean that you are still using the old kernel. Not the ideal solution. This means you will have to create a new boot disk every time the kernel changes.

Because you probly can’t boot directly to your USB drive, you will have to use a rescue disk to get at your newly installed linux drive. Boot from CD 1 of the linux install, and at the boot prompt, type:
linux rescue

Once this loads, you should be able to mount your USB drive (substitute your root partition if it is other than sda1):
mount /dev/sda1 /mnt/source

Use the CHROOT command to set your USB drive as the root file system:
chroot /mnt/source

Now, everything will run as if your USB drive was mounted the way it would have been if you could boot from it.

To use the mkboot utility, make sure a floppy is in the drive (one that can be erased!) and type (NOTE: the kernel-version should be replaced with the version of the kernel you want to put on your boot disk. Look in the /boot folder to see which kernels you have available. They start with vmlinuz and end with something similar to 2.6.5-1.452):
mkbootdisk kernel-version

Once you have a floppy boot disk, you have the base to start from. The generated disk has a copy of your current kernel

Extracting the startup information
Now that you have the floppy, you can extract the boot files from it. Why would you want to do that? Most likely your floppy won’t work. The floppy will boot, but it won’t load the USB drivers in time. If you bios doesn’t support booting from USB drives directly, then Linux will try to mount the root file system to your drive before your drive is visible.

You may need to make a directory to mount your floppy to:
mkdir /mnt/floppy

Mount the floppy drive so you can view it’s files:
mount /dev/fd0 /mnt/floppy

Make a directory so we can make our changes. The resulting changes will be too big for the floppy, so don’t try to make the changes directly to the floppy as it will run out of room.
mkdir /bootdisk

Copy all the files from the floppy to the /bootdisk folder
cp -R /mnt/floppy/* /bootdisk

Once that is copied, we are done with the floppy:
umount /mnt/floppy

Go to the temp directory we made:
cd /bootdisk

The file we care about is the initrd.img file. It is actually a file system stored within a compressed file. We want to extract all that so that we can manipulate it and add our USB drivers.
cp initrd.img initrd.gz
gzip -d initrd.gz
mkdir a

FC2 initrd files are loop back file systems. FC3 and later initrd files are cpio archives. This next command depends on what you wich version you are using.
FC2: mount -o loop initrd a; cd a
FC3: cd a; cpio –extract < ../initrd

If we look now, we have a directory full of what looks like another root file system (an etc folder, a bin folder, etc.)

We want to copy our USB drivers to the appropriate location in this boot file structure:
cd lib
cp /lib/modules/???????/kernel/drivers/scsi/scsi_mod.ko .
cp /lib/modules/???????/kernel/drivers/sd_mod.ko .
cp /lib/modules/???????/kernel/drivers/usb/host/ehci-hcd.ko .
cp /lib/modules/???????/kernel/drivers/usb/host/uhci-hcd.ko .
cp /lib/modules/???????/kernel/drivers/usb/host/ohci-hcd.ko .
cp /lib/modules/???????/kernel/drivers/usb/storage/usb-storage.ko .

Make sure to replace the ?????? with the correct version of the kernel you are working with (the one you used in the mkbootdisk command earlier). This is a folder, so you can look and see which versions are available.

The files are the modules that will allow USB drives to be seen by the kernel (USB drives are emulated as scsi drives in Linux, that is the reason for the scsi drivers).

Next, we need to edit the linuxrc file (or possibly init?) so that it will load the drivers at boot time.
cd ..
vi linuxrc

You can use a different editor besides VI if it is available.
Add the following lines AFTER the line that loads the ext3.ko module:
echo Loading USB drivers…
insmod /lib/scsi_mod.ko
insmod /lib/sd_mod.ko
insmod /lib/ehci-hcd.ko
insmod /lib/uhci-hcd.ko
insmod /lib/ohci-hcd.ko
insmod /lib/usb-storage.ko
echo Waiting for USB drive detection…
sleep 5

Save that and exit the text editor.

Those are all the changes we need. Now we need to unmount the boot disk file system:
FC2: cd ..; umount a
FC3: find . | cpio -o -H newc | gzip -9 ../initrd.img; cd ..

You are now ready to burn your own CD. I have a bootable ISO ready to go at http://debug.mine.nu/files/usbbootcd.iso. Copy the vmlinuz and initrd.img files into this ISO and burn the cd.

I prefer working with ISO files in windows. If you do too, then copy the vmlinuz and initrd.img files to a windows machine (via floppy, ftp, network, whatever works for you). I like MagicISO personally (google it to find a download link). You can download it and try it out. Open the ISO from the link above, then simply drag the vmlinuz and initrd.img files into the isolinux folder (it will ask you if you want to over write files, say yes). Then, save the ISO and burn it (with MagicISO, or any other burning program).

Ray Pulsipher

Owner

Computer Magic And Software Design

Comments are closed.


Home | My Blog | Products | Edumed | About Us | Portfolio | Services | Location | Contact Us | Embedded Python | College Courses | Quick Scan | Web Spy | EZ Auction | Web Hosting
This page has been viewed 864028 times.

Copyright © 2005 Computer Magic And Software Design
(360) 417-6844
computermagic@hotmail.com
computer magic