Installing Fedora with a USB: Step by Step

I had a 2950 without a DVD drive that needed a fresh install of Fedora on it. To further complicate things, I also didn't have any blank CDR's to burn the traditional boot.iso, and only had a small 128MB vendor give away USB disk. Also it was dark and I was blindfolded.

Here are the steps taken to overcome at least the first part of this problem: Making a USB boot disk with a small USB drive.

First off, make sure your BIOS supports USB booting. Most do now days, but you can run in to some very old BIOS versions that just don't know what to do with the USB ports on bootup. Oftentimes a new BIOS will fix this issue. I needed this one for my Dell PowerEdge 2950's.

Using my trusty VMWare appliance FC9 image from VMPlanet.net and the free VMWare player (My company supports FC9 for our product currently, but these methods will work for lots of distributions), I plugged in the USB and mounted it using the "Connect (Disconnect from Host)" menu option under the VMWare Player "Devices" menu. I had an ISO image of the distribution I needed already downloaded, but it can be found here if necessary.

Once all these pieces are in place (USB, DVD .iso file, etc) I loopback mount the boot.iso
[vmplanet@fedora-vm ~]$ mount|grep "Fedora"
[vmplanet@fedora-vm ~]$ /dev/sr0 om /media/Fedora 9 x86_64 DVD type iso9660 (ro,nosuid,nodev,uhleper=hal,uid=500)
[vmplanet@fedora-vm ~]$ mkdir /mnt/fc9
[vmplanet@fedora-vm ~]$ mount /media/Fedora\ 9\ x86_64\ DVD/images/boot.iso /mnt/fc9 -0 loop,ro
Basically the above finds where the heck my DVD is, then I create a directory called "fc9" in my /mnt directory which I will use to mount the .iso image. The only tricky part to the mount command is the fact that the DVD name has spaces in it. The handy "\" backtick takes care of that (or just hit tab and let the shell fill in the blanks). This iso file is mounted as a loopback and is read only. You may find, due to permissions issues, that you need to "sudo" some of these commands.

You can check to make sure the iso is mounted if you can see images and isolinux in that directory.
[vmplanet@fedora-vm ~]$ cd /mnt/fc9
[vmplanet@fedora-vm ~]$ ls
images isolinux
Great. Now we make a blank file. Of course there is a command for this in Linux:
[root@fedora-vm tmp]# mkdir usbdrive
[root@fedora-vm tmp]# cd usbdrive
[root@fedora-vm usbdrive]# dd if=/dev/zero of=diskboot.img bs=1M count=12
12+0 records in
12+0 records out
12582912 bytes (13 MB) copied, 0.0844282 s, 149 MB/s
The dd command is one of the most surprisingly useful commands in Linux. It can be used for so many things. In this case we have used it to create a blank file in the /tmp/usbdrive directory that is ~12M in size.

The next step is to format that file with a FAT filesystem using the mkdosfs command.
[root@fedora-vm usbdrive]# mkdosfs diskboot.img
mkdosfs 2.11 (12 Mar 2005)
Now we make the file bootable with the syslinux command.
[root@fedora-vm usbdrive]# syslinux diskboot.img
Loopback mount that diskboot.img file the same way you did the .iso file above (only leave of the ",ro" because we don't want it read only).
[root@fedora-vm usbdrive]# mkdir /mnt/diskboot
[root@fedora-vm usbdrive]# mount diskboot.img /mnt/diskboot/ -o loop
Copy the files from the /isolinux directory to your diskboot "disk"
[root@fedora-vm usbdrive]# cp -r /mnt/fc9/isolinux/* /mnt/diskboot/

You should see some files on the diskboot image now
[root@fedora-vm usbdrive]# ls /mnt/diskboot/
boot.cat general.msg initrd.img isolinux.cfg memtest param.msg splash.jpg vesamenu.c32 boot.msg grub.conf isolinux.bin ldlinux.sys options.msg rescue.msg trans.tbl vmlinuz
We need to copy the contents of the isolinux.cfg file to the diskboot image now (but name the file syslinux.cfg)
[root@fedora-vm isolinux]# grep -v local /mnt/fc9/isolinux/isolinux.cfg > /mnt/diskboot/syslinux.cfg
A little housecleaning on the diskboot image and then we unmount it:
[root@fedora-vm isolinux]# rm -f /mnt/diskboot/isolinux.*
[root@fedora-vm isolinux]# umount -f /mnt/diskboot/
[root@fedora-vm isolinux]# rm -rf /mnt/diskboot/
The last rm command just cleans up that directory we used to mount the filesystem (rm -rf deletes whole folders, use cautiously). No point in keeping it around.

Now comes the only dangerous part to the whole process. Writing the diskboot.img file to your USB drive. The only reason this is dangerous is because you can accidentally overwrite your hard disk, and this would be very bad (though you could just download your VMWare appliance if you are using a similar setup to mine). Just make sure that you can see your USB stick and you know what /dev it is with the mount command
[root@fedora-vm /]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
gvfs-fuse-daemon on /home/vmplanet/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=vmplanet)
sesm01:/auraria_tmp/export on /mnt/sesm01 type nfs (rw,addr=172.31.240.10)
/dev/sr0 on /media/Fedora 9 x86_64 DVD type iso9660 (ro,nosuid,nodev,uhelper=hal,uid=500)
/dev/sdb1 on /media/USB type vfat (rw,nosuid,nodev,uhelper=hal,shortname=lower,uid=500)
Some people prefer the DF command because the output is cleaner:
[root@fedora-vm /]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
6966792 2494604 4472188 36% /
/dev/sda1 194442 12502 171901 7% /boot
tmpfs 257532 48 257484 1% /dev/shm
sesm01:/auraria_tmp/export
108231680 38167552 64566272 38% /mnt/sesm01
/dev/sr0 4066110 4066110 0 100% /media/Fedora 9 x86_64 DVD
/dev/sdb1 120204 120190 14 100% /media/USB
In my case, my USB drive is located on /dev/sdb1. I can now use the dd command to write my diskboot.img file to that device
/dev/sdb1 120204 120190 14 100% /media/USB
[root@fedora-vm /]# dd if=/tmp/usbdrive/diskboot.img of=/dev/sdb1
24576+0 records in
24576+0 records out
12582912 bytes (13 MB) copied, 0.257696 s, 48.8 MB/s
There you go, you have made a bootable USB disk with the Fedora Core 9 install files necessary to do a kickstart install over the network (provided your BIOS supports USB Booting)

Michael B. McClelland

Comments

Popular posts from this blog

Creating a Free PDF Printer in Windows 7 using Ghostscript and Redmon that is one tenth the size of a full Adobe install