There are many web sites which have somewhat or even widely differing instructions for creating bootable USB thumb drives for the installation of Fedora and CentOS distributions. I have found many of these to be out of date or incomplete.
Many of the documents I have found are intended for the creation of a Live-boot image on the USB device. That is different from my intent in this document which is to create a bootable USB device from the installation ISO images of Fedora and CentOS. These USB thumb drives will act the same as the DVD installation media, but they are much faster and, I think, more reliable on hosts that support booting from removable USB devices.
It has taken hours of experimentation using the available documentation to arrive at a set of procedures that work reliably. I have put together here a sequence of steps that work consistently for me but, as always, YMMV.
There are three major steps that need to be completed for this to work.
- Download the appropriate installation image from the trusted web site for the desired distribution. This should be a DVD ISO installation image.
- Optionally, preparing the USB device if it is not brand new or already prepared.
- Copying the ISO image to the partition on the device.
Steps one needs to be done whichever procedure is used. Sometimes step two is already completed, such as for a new and unused USB thumb drive.
I have links for the three primary Red Hat related distributions in the “Distributions” links on the right sidebar.
Downloading the ISO image
Simply use your browser and navigate to the download page for Fedora or CentOS and download the desired ISO image to your local host and place it in a accessible location. You can also use the wget command if you prefer the command line and know the URL for the image. I store my ISO images in directories that are only accessible to root. I usually set up a directory tree for my downloaded ISO images and keep older images for as long as they might be required.
Preparing the USB device
Usually after using a USB thumb drive for this purpose as a bootable installation image once, just copying a new image to the bootable partition on the USB device does not work. In such a case it is necessary to delete the existing partitions and create new ones, making the device bootable in the process.
Insert the USB memory stick into a USB port. Use the dmesg command to determine the device name assigned to the memory stick. For this example this is /dev/sdh.
Use the fdisk command to delete all existing partitions on the USB device. Create one new primary partition as partition 1. Set it to type “b”, “Win95 FAT32”. Use the fdisk “a” command to make partition 1 bootable.
Write the changed partition table to the USB device. If you get an error indicating that the partition table was not re-read and that the kernel is using the old partition table, use the following command to force the kernel to re-read the partition table for just the /dev/sdh device.
Create the VFAT filesystem on partition 1 of the USB device.
mkfs -t vfat /dev/sdh1
At this point your USB device is ready to have the installation ISO image copied to it as if it were new.
Installing the ISO image
If you have just purchased a new USB device and it has never been used in this manner before there is nothing that needs to be done to prepare the USB device. New USB thumb drives already have partition 1 set up as VFAT and bootable. Simply copying the ISO image to the bootable partition is all that needs to be done.
This procedure works very well for new USB devices and for used ones that have been prepared as described in the section above.
Change directory (cd) into the directory in which the image is stored.
Insert the USB memory stick into a USB port. Use the dmesg command to determine the device name assigned to the memory stick.
Insert the USB drive and use the dmesg command to determine which device your system sees the USB drive at. The output from the dmesg command will look similar to the following:
[174156.598656] usb 3-220.127.116.11:new high-speed USB device number 34using xhci_hcd [174156.618484] usb 3-18.104.22.168:New USB device found, idVendor=058f, idProduct=6387 [174156.618487] usb 3-22.214.171.124:New USB device strings:Mfr=1,Product=2,SerialNumber=3 [174156.618489] usb 3-126.96.36.199:Product:MassStorage [174156.618490] usb 3-188.8.131.52:Manufacturer:Generic [174156.618492] usb 3-184.108.40.206:SerialNumber: F24CDC58 [174156.618828] usb-storage 3-220.127.116.11:1.0: USB MassStorage device detected [174156.618977] scsi24 : usb-storage 3-18.104.22.168:1.0 [174157.622885] scsi 24:0:0:0:Direct-AccessGenericFlashDisk8.07 PQ:0 ANSI:4 [174157.623102] sd 24:0:0:0:Attached scsi generic sg10 type 0 [174157.623798] sd 24:0:0:0:[sdh]7884800512-byte logical blocks:(4.03 GB/3.75GiB) [174157.624458] sd 24:0:0:0:[sdh]WriteProtectis off [174157.624461] sd 24:0:0:0:[sdh]ModeSense:23000000 [174157.625130] sd 24:0:0:0:[sdh]Write cache: disabled, read cache: enabled, doesn't support DPO or FUA [174157.628636] sdh: sdh1 [174157.630612] sd 24:0:0:0: [sdh] Attached SCSI removable disk
For this example assume that USB device is identified as /dev/sdh as shown above.
To create the image on the USB device, use the following dd command, being sure to use the correct name of the ISO image and USB device path:
dd if=Fedora-20-x86_64-DVD.iso of=/dev/sdh
The name of the ISO image in this example is Fedora-20-x86_64-DVD.iso where 20 is the Fedora release number, and the path to the device is /dev/sdh. You should be sure to use the correct ISO image name and path, as well as the correct device path for your circumstances. This procedure will work for any current or recent release of Fedora or CentOS.
Note that we use the device name and not that of any existing partitions on the device, which would look like /dev/sdh1 or /dev/sdh2, for example.
Warning!!: Be certain that you enter the command correctly. An incorrectly entered dd command could destroy the entire contents of your hard drive. The dd commend is nicknamed “disk destroyer” for a reason.
An alternate method for installing the ISO image to the USB device
It is also possible to use the livecd-iso-to-disk command to copy the image to the partition of a new or prepared USB memory stick.
livecd-iso-to-disk Fedora-20-x86_64-DVD.iso /dev/sdh1
The livecd-iso-to-disk command also has options to create the required partition and install a boot record all in a single operation. I have found this method to be useful although it is a bit less reliable.
livecd-iso-to-disk --format --reset-mbr Fedora20-Live-X64-KDE.iso /dev/sdh
Note that the Red Hat related Linux documentation for Fedora, Red Hat and CentOS all recommend using the dd command as shown in the previous section.
For additional information on making USB stick bootable, the following URL may be helpful.