How to Set Up a USB Key to Install CentOS 6.x

The recommended approach for CentOS-6 is to use livecd-iso-to-disk from livecd-tools with DVD1. This has been tested with livecd-tools-13.4-1.el6 from EPEL. Thanks to forum user AndrewSerk for the recommendation in a forum post.

Obsolete method

Building a distribution on a USB key as of CentOS 6.2 – thanks to Mark Roth for the CentOS-6 procedure, and to Yves Bellefeuille on the CentOS-Docs list for several additions and corrections.

Recommended: An 8GB or larger USB key.

  1. Partition the USB key into two partitions: the first, FAT32, and about 250M; the second, the rest of the drive, and ext3. (An ext3 partition is required because the ISO file, that will later be copied to it, is larger than the maximum file size for a FAT32 or VFAT partition.)
  2. Mount DVD1, if it isn’t automounted (on /media, or /mnt). The following assumes /mnt/USB and /mnt/DVD.
  3. Mount the USB key on /mnt/USB/.

  4. Copy the directory and contents of /mnt/DVD/isolinux to /mnt/USB/.

  5. Rename /mnt/USB/isolinux to /mnt/USB/syslinux

  6. Rename /mnt/USB/syslinux/isolinux.cfg to /mnt/USB/syslinux/syslinux.cfg

  7. Copy the directory and contents of /mnt/DVD/images to /mnt/USB/. (A bug has been filed [ToDo – add link] because as of 11 Jan 2012, the install requires the .iso (see below), but linux rescue requires the contents of images to load and run.)

  8. Assuming that the USB key is /dev/sdb
    syslinux /dev/sdb1 
  9. Unmount the first USB partition, and mount the second
    umount /mnt/USB
    mount /dev/sdb2 /mnt/USB 
  10. Copy the .iso file to /mnt/USB. Do not use the LiveCD or LiveDVD. Use DVD1, the minimal CD ISO, or a combined DVD1/DVD2 created following CD to DVD Media. Do not copy the contents – the install now wants the .iso file itself, which it mounts during installation, and follow the upstream Installation_Guide to create an images directory on the same partition. Optionally, add DVD2 if you used DVD1, and need it for the install.

  11. Optional: On /mnt/USB, create a grub.conf. This may be required if your system wants the USB key as the first drive, so that you can later copy it to the hard disk. See HowTos/GrubInstallation section 2 for guidance.

  12. Umount the USB key, and it’s ready to use.
  13. Boot from the USB media by setting it as the first BIOS boot device, or on some BIOSs by hitting a key such as F12 to select a boot device after POST.
  14. During the installation process, the user is asked “What type of media contains the installation image?” Select the first partition on the USB key, which should appear in the menu under “Hard drive”, then /dev/sda1 or whatever device corresponds to the first USB partition.

  15. After partitioning, the user is asked whether to install the Grub boot loader and where to install it. After booting from the USB key, the BIOS may think that the USB key is the first drive. If the USB is seen as the first device, then to install the Grub boot loader on the hard drive MBR, which is the usual case, the user must change the order of the hard drives using the Grub advanced installation options.
  16. After the Grub installation options, the following error message may appear: “Missing ISO 9660 image: The installer has tried to mount image #1, but cannot find it on the hard drive”. The installation program is looking for the ISO file on the first partition of the USB key, but it’s on the second partition. Go to a terminal with a shell with Ctrl-Alt-F2, unmount the first partition of the USB

    umount /mnt/isodir

    mount the second partition on the USB device. This will be the same device used in #14 above – for example

    mount -t ext3 /dev/sda2 /mnt/isodir

    Return to the installation program (Ctrl-Alt-F6) and choose “Retry”.

  17. Finish the installation and reboot without the USB device connected. If there are problems booting then it is likely the boot record was written to the wrong device. See How to re-install bootstrap code (GRUB), and if having difficulties determining the correct device, Troubleshooting GRUB Issues.