How to Boot and Run Fedora Linux with a USB Disk

Copyright © 2006  Pu JIAN

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.  

DISCLAIMER:   No liability for the contents of this document can be accepted. Use the concepts, examples and information at your own risk. There may be errors and inaccuracies, that could be damaging to your system. Proceed with caution, and although it is highly unlikely that accidents will happen because of following advice or procedures described in this document, the author do not take any responsibility for any damage claimed to be caused by doing so.


This document records the steps that the author have taken to install Fedora Core (FC) on a USB external hard disk, then boot and run Fedora Linux with the USB external hard disk.

The steps are taken basing on the following conditions:  

(a)    the USB external hard disk is a blank disk;
(b)    the computer has 1 ATA/IDE internal hard disk but without any existing FC installation; and
(c)    no other USB or SCSI devices are installed or connected to the computer.


Step 1: Specify "expert" installation mode

Plug the USB external hard disk to a USB port of the computer.  Put the FC first installation CD into the CD drive and boot the computer.  When the FC installer shows the prompt, enter

linux expert

This calls up the expert installation mode and the FC installer will show the detected USB external hard disk.


More Information

The expert mode/option is not shown on the FC installer help screen.


Step 2: Select the external hard disk


When the FC installer shows the hard disks, the USB external hard disk is shown as "/dev/sda".  Select the USB external hard disk as the target disk for installing FC!  Make sure the selection is correct, otherwise the internal hard disk will get formatted.  

More Information

To play save, some people recommend removing all other hard disks from the computer before commencing the FC installation. 


Step 3: Partition the external hard disk

The simplest way is to let the FC installer automatically partition the external hard disk.  In this case, the external hard disk will have the following partitions:

Partition Device name
/boot /dev/sda1
/ /dev/sda2
/home /dev/sda3
swap /dev/sda4

Mark the "/boot" partition as bootable.  After that, follow the instructions on screen to do the installation.


Step 4: Specify the location for installing "grub"

When the FC installer prompts for the location for installing "grub", instruct it to install "grub" in the "/boot" partition.  After that, follow the instructions on screen to complete the installation.


Step 5: Reboot to "rescue" mode

After completing the installation, put the first FC installation CD back to the CD drive and reboot the computer.  When the FC installer shows the prompt, enter

linux rescue

When the FC installer shows prompt screens, respond as follows:

FC Prompt Selection
Choose language English
Choose keyboard US
Start network interface No
Detect existing Linux installation Yes
Hint for exit OK

Finally, the FC installer shows a text mode command shell (i.e "sh").  



Step 6:  Prepare an "initrd" image for mounting the USB external hard disk

At the command prompt, enter the following commands to prepare an "initrd-usb.img" (i.e. initialization RAM disk image for USB), then move it to the "/boot" partition:

mkdir /mnt/sda1
mount /dev/sda1 /mnt/sda1
mkdir /mnt/sda2
mount /dev/sda2 /mnt/sda2
chroot /mnt/sda2

mkinitrd -v -f --with=uhci-hcd --with=ohci-hcd --with=ehci-hcd --with=scsi_mod --with=sd_mod --witth=sg --with=sr_mod --with=usb_storage initrd-usb.img ``uname -r`

exit
mv /mnt/sda2/initrd-usb.img /mnt/sda1

Note

The mkinitrd command is an one-line command although it may appear to be more than one line on screen.


Step 7: Edit the "grub.conf" file


At the command prompt, enter the following commands to get access to the "grub.conf" file:

cd /mnt/sda1/grub

Use the "vi" editor to open "grub.conf" and find the following line in "grub.conf":

/initrd /initrd-2.6...._FC5.img

Add a "#" sign at the beginning of that line to comment it out.  So the line looks like:

#   
/initrd /initrd-2.6 ... FC5.img

Insert the following line below the commented line:

/initrd /initrd-usb.img

Fedora Linux will load the "initrd-usb.img" file by default in subsequent booting.


Step 8: Change BIOS settings

Remove the FC installation CD from CD drive.  At the command prompt, enter the following command to exit and wait for the computer to reboot:

exit

If necessary, change the relevant BIOS setting(s) to enable the computer to boot from USB external hard disk.  Save the settings and reboot.  

If the computer can boot from USB external hard disk and successfully load Fedora Linux, that's all (i.e. skip the following steps).  Otherwise, it is necessary to complete the steps below. 



Step 9: Prepare a "grub boot" floppy and a "grub.conf" floppy

Put the first FC installation CD back to the CD drive and reboot the computer.  When the installation prompt shows up, enter

linux rescue

Respond appropriately and wait for the FC installer to show the text mode command shell.  See also Step 5 above.


Put a blank floppy disk into the floppy drive of the computer.  WARNING: All the information on the floppy disk will be erased.  DO NOT use floppy disk with stored information.

At the command prompt, enter the following commands to copy the required "grub" boot files to make a "grub boot" floppy disk: 

mkdir /mnt/sda2
mount /dev/sda2 /mnt/sda2
cd /mnt/sda2/usr/share/grub/i386-redhat
dd if=stage1 of=/dev/fd0 bs=512 count=1
dd if=stage2 of=/dev/fd0 bs=512 seek=1


Remove the "grub boot" floppy disk from the floppy drive.

Put another blank DOS formatted floppy disk into the floppy drive of the computer, and enter the following commands to make a "grub.conf" floppy disk:

cd /
mkdir /mnt/sda1
mount /dev/sda1 /mnt/sda1
mcopy /mnt/sda1/grub/grub.conf a:

Remove the "grub.conf" floppy disk from the floppy drive.  It is unfortunate that the "grub.conf" file cannot be store in the "grub boot" floppy disk because the "grub" boot files occupy the system area of the floppy disk.


Step 10a: Manually boot from floppy disks

Remove the FC installation CD from CD drive.  Put the "grub boot" floppy disk in the floppy drive of the computer.  At the command prompt, enter the following command to exit and wait for the computer to reboot:

exit

When the "grub" command prompt shows up, replace the "grub boot" floppy disk by the "grub.conf" floppy disk, then enter:

configfile /grub.conf

More Information

If there is problem with the "grub.conf" floppy disk, it is also possible to enter the following commands manually at the "grub" command prompt:

root (hd1,0)
kernel /vmlinuz ro root=LABEL=/
initrd /initrd-usb.img
boot


In the kernel command line above, the root=LABEL=/ parameter instructs the kernel to find the root partition by label (i.e name).  If there is no existing FC installation in the computer when FC was being installed on the USB external hard disk, the default label of the root partition would be "/".

To find the label of each partition, enter to following commands at the command prompt of the rescue screen:

mkdir /mnt/sda2
mount /dev/sda2 /mnt/sda2
cat /mnt/sda2/etc/fstab


Note: If the "sda2" partition has been mounted as above, the mkdir and mount commands mentioned above are not necessary.

If the root partition label on the USB external hard disk is not "/", it is necessary to change the parameter accordingly, for example:

kernel /vmlinuz ro root=LABEL=/1
kernel /vmlinuz ro root=LABEL=/12

If Fedora Linux fails to find the root partition by label, reboot the computer and try the following commands:

root (hd1,0)
kernel /vmlinuz ro root=/dev/sda2
initrd /initrd-usb.img
boot



More Information

If the USB external hard disk would be used to boot and run Fedora Linux on different computers, replace the kernel command line mentioned above by

kernel /vmlinuz ro root=LABEL=/ 3

The last parameter 3 instructs Fedora Linux to run in Level 3, which will show a text mode command shell (i.e. bash) with a login prompt.  Login as usual.

Assuming that appropriate graphical screen configurations have been specified in the "X86Config" file to suit the graphical hardware of different computers, enter the following command to start the graphical desktop with desired screen configuration:

startx -- -Screen screen-name

The screen-name is the pre-set screen name in the "X86Config" file.


Step 10b: Manually boot from CD

Using 2 floppy disks is inconvenient.  After loading Fedora Linux successfully, it is possible to make a "grub boot" CD with the "grub.conf" included.  See "grub" documentation on how to make such CD; launch a console, enter

info grub

One point to note, the "menu.lst" file mentioned in the "grub" documentation is actually the "grub.conf" file.  So just take "grub.conf" as if it is "menu.lst".

Put the "grub boot" CD in the CD drive of the computer.  When "grub" shows the command prompt, enter:

configfile /grub.conf



The above steps are for installing Fedora on and booting Fedora from a USB external hard disk.  For feedbacks, please send e-mail to [email protected] .

Last update: October 2006


Hosted by www.Geocities.ws

1