Installing CentOS from USB


Nowadays almost every system/server can boot from a USB thumb drive. I find it much more practical (and handy) to install my CentOS systems from a USB drive. I can carry multiple versions of the OS on different USB sticks and easy to wipe/recreate. It also serves as a great tool in the event of an emergency where you need to reinstall a system. Below are the steps involved:

Assumptions:

  1. You are installing CentOS 5/6 on the USB stick
  2. You are setting up the USB drive on a Linux system (syslinux has to be installed)
  3. The ISO files for CentOS (CentOS-5.6-x86_64-bin-DVD-1of2.iso and CentOS-5.6-x86_64-bin-DVD-2of2.iso, for example) reside on the CentOS host system you are setting up the USB drive on
  4. You have the following utilities: mkdosfs, syslinux, grub-install
  5. Note: I setup my USB stick on a Mac running a VirtualBox CentOS 5 virtual machine. So keep in mind, when you plugin a thumb drive in a Mac, the Mac will “grab” the USB drive first. You need to unmount it, then mount in your VM
    1. Command to mount the USB:
      # mount /dev/sdd1 /mnt/usb
    2. To find out which device file is associated with the USB drive, checkout the output of “dmesg” after you plug in the USB drive

Steps to create USB boot and installation disk:

  1. Plug-in the USB drive into your system (or virtual system)
  2. fdisk /dev/sdd      This is to create an sdd1 partition on this USB drive (formatted in MS-DOS Win FAT32 – id type “c”)
  3. mkdosfs /dev/sdd1
  4. mkdir /mnt/usb
  5. mount /dev/sdd1 /mnt/usb
  6. mount CentOS-5.6-x86_64-bin-DVD-1of2.iso -o loop /mnt/centos1
  7. cp -av /mnt/centos1/isolinux/* /mnt/usb/
  8. cd /mnt/usb/
  9. rm isolinux.bin boot.cat TRANS.TBL     (or trans.tbl)
  10. mv isolinux.cfg syslinux.cfg
  11. cp -v /mnt/centos1/images/pxeboot/initrd.img /mnt/usb/
  12. umount /dev/sdd1
  13. syslinux /dev/sdb1
  14. mount /dev/sdd1 /mnt/usb
  15. grub-install –root-directory=/mnt/usb /dev/sdd
  16. cd /mnt/usb
  17. mkdir -p boot/grub    <- it will likely already exist
  18. cd /mnt/usb/boot/grub
  19. Create the grub.conf file in this dir:
    default=0
    timeout=5
    root (hd0,0)
    title CentOS 5.6 Linux
    kernel /vmlinuz
    initrd /initrd.img
  20. cp CentOS-5.6-x86_64-bin-DVD-* /mnt/usb/     <- Need to actually copy over the actual iso CentOS files as well.
  21. umount /mnt/usb
Installing system (Dell R410) from USB:
  1. Plug USB drive in server and boot it up. For Dell, you have to hit F11 to get the BIOS boot manager
  2. Select the USB thumb drive to boot from
  3. Select language, keyboard, etc and then when it asks for installation media source, select “Hard Drive”
  4. You will be prompted for where the ISO images are located (/dev/sda, /dev/sdb, /dev/sdc, etc), select the one corresponding to the USB drive (which will likely be the last one). It will search the root of the USB drive for the ISO files (the ones you copied in Step 20 above)
  5. When asked for drives to use for installation, make sure to unselect the USB drive
  6. Now here is where it gets a little tricky, you’ll see it states “The GRUB boot loader will be installed on /dev/sdc”. Not good, since that’s the USB drive. So make sure to select “Configure advanced boot loader options” so we can correct that in the next screen.
  7. So here you’ll see that the MBR (Master Boot Record) is set to install on /dev/sdc. All you need to do is change the order by clicking on “Change Drive Order” and move /dev/sda all the way to the top. First pic is the incorrect setting and second pic is the correct one


  8. And that’s it! Just follow the rest of the installation setup as you see fit.

 

-H

References:

http://www.cyberciti.biz/faq/linux-create-a-bootable-usb-pen/

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: