Creating a Fedora 9 Pre-release boot USB key

I’ve got a new backup server at home. I want to boot it from a USB key or compact flash so that I may spin down the hard drives when they’re not in use. This saves me an extra 6W per disk in power consumption. Given that I want my backup server running 24/7 (and I invested in a low power mini-ITX solution) any power saving is of monetary consequence.

Update: Rahul Sundaram suggested I try using livecd-iso-to-disk. If I were to create a LiveCD using revisor, and then use livecd-iso-to-disk the process would be much easier. Thanks Rahul. The method I was using is below. And it’s missing a step, before dd’ing to the flash drive you need to rebuild the initrd to include usb-storage. Rahul’s method begins to look even better after the addition of that step. End Update.

There are many ways to create a Fedora 9 boot USB device. I tried several, but because Fedora is still in pre-release there are some issues with using tools such as revisor (I fixed all the bugs I came accross, so it’ll be ok in the release). I have the added complication that when I’m in work there’s a http proxy. This shouldn’t be an issue, but kickstart (one of the tools I used) doesn’t suport http proxies. Anyway, on to the solution.

I’m creating a USB boot disk. USB disks are good for about 100,000 write operations (or so the folk wisdom has it). They’re less reliable than hard drives so I expect to repeat my installation every year or so. Kickstart is an excellent tool which allows me to both (a) repeat the same installation multiple times, and (b) more importantly (for me in this case) provides simple documentation of what was on the system and the configuration of the install. (b) is important as I won’t remember my install configuration next year when I have to replace the USB drive.

I used the graphical “system-config-kickstart” as the root user, to create a ks.cfg file. I wanted the kickstart file on a floppt disk so I downloaded a FreeDOS floppy image. This saved me having to create a 1.44Mb formatted floppy :) I mounted the floppy image “sudo mount floppy.img -o loop /mnt” and copied the ks.cfg file to /mnt. Unmount the floppy drive.

Rather than second guess the geometry of the USB disk, I cheated. I dumped the current contents as a binary image “sudo dd if=/dev/sdb of=USB-disk.img”. It’s important to dump the entire device (generally /dev/sdb or /dev/sdc) rather than a partition on the device (/dev/sdb1). Oh, and I downloaded the Fedora 9 pre-release DVD.

So with the floppy image containing my kickstart file, the Fedora DVD and my new USB disk image I launched qemu, a virtual machine. i told qemu where the floppy disk was (-fd0 floppy.img) and where the dvd was (-cdrom Fedora-9-Preview-i386-DVD.iso) and told it that my USB disk image was the systems first hard drive (-hda USB-disk.img). Most importantly, I told qemu to use 256Mb of RAM. The default 128Mb is too little for the Fedora installer to run (note: it’s not too little to run Fedora in, if you don’t run a GUI). So use the -m 256 option.

When qemu boots the DVD and presents the GRUB bootloader screen you have to edit the boot options to include “ks=hd:fd0:/ks.cfg”. This can be done by presssing the Tab button. This magical incantation tells the Fedora installer (called anaconda) to pick up the configuration from the floppy disk in the file ks.cfg. This allows the install to complete without any manual interference by me.

When the install is finished you have a brand new Fedora install on a USB disk image. It’s then necessary to write that image to the USB key itself. This is the reverse of the above operation so “sudo dd if=USB-image.img of=/dev/sdb”. This time the input to the dd tool is the USB image and the output file is the USB device itself.

Have fun.

2 Responses to “Creating a Fedora 9 Pre-release boot USB key”

  1. balor says:

    Hmmm….that’s much easier :) However I wanted only the Base packages and an Apache server on a stripped down install. Still though, using Revisor to create a LiveCD with my package list and then using livecd-iso-to-disk is a better way than the way I’ve done it.

Leave a Reply