< Browse > Home / Linux / Blog article: Create Bootable USB Drive For Centos Installation

| RSS

Create Bootable USB Drive For Centos Installation

July 23rd, 2010 | 12 Comments | Posted in Linux

Due to budget constraint, my new device doesn’t come with any CD/DVD ROM and PXE compliant NIC. Therefore, I need to rely on the USB hard disk to make it as a boot media to start the OS installation process.

Prerequisite:

  1. You must have a USB storage device like flash/pen drive or hard disk. In my scenario, I only have a USB hard disk and I’m gonna make it as a boot disk to kick start the network installation.
  2. You should have the Centos installation CD/image.
  3. Running Webserver for Kick Start (unattended) OS installation.
  4. Running Linux/Unix OS to create the USB boot disk.

Create USB boot disk:

  1. Connect you USB device to a running Linux machine and run “dmesg” to identify the device name.

    My USB hard disk being recognized as /dev/sdb

    USB_boot_disk_1

  2. Use “fdisk” to partition /dev/sdb

    USB_boot_disk_2

    1. Create 2 partitions
      1. 100 MB for boot image, boot image partition is Primary 1
      2. Remaining for storage, storage image partition is Primary 2
      3. Tag boot image partition as bootable
      4. Set boot image partition type to FAT32 (type number 1)
      5. Save & Exit
      6. USB_boot_disk_3
        USB_boot_disk_4
        USB_boot_disk_5
        USB_boot_disk_6

    2. Format the partition
      1. Format boot image partition as FAT32
      2. USB_boot_disk_7

      3. Format storage partition as EXT3
      4. USB_boot_disk_8

  3. Copy required files from Centos CD to /dev/sdb1
    1. Mount /dev/sdb1 to /mnt

      [root@localhost ~]# mount /dev/sdb1 /mnt
    2. Copy the contents of /Centos/isolinux to /mnt from the 1st CD
      (p/s: isolinux.bin, boot.cat and TRANS.TBL are note needed)

      [root@localhost ~]# cp -R /root/Desktop/isolinux/* /mnt/

      [root@localhost ~]# cd /mnt

      [root@localhost mnt]# rm -rf isolinux.bin boot.cat TRANS.TBL

    3. Rename isolinux configuration file to syslinux.cfg

      [root@localhost mnt]# mv isolinux.cfg syslinux.cfg
    4. Copy the installer’s initial RAM disk /Centos/images/pxeboot/initrd.img from the 1st CD to /mnt

      [root@localhost mnt]# cp -R /root/Desktop/initrd.img /mnt/

  4. Make the USB hard disk bootable. The flash drive must be unmounted in order to work properly.
    1. Umount /dev/sdb1

      [root@localhost isolinux]# cd

      [root@localhost ~]# umount /dev/sdb1

    2. Install the SYSLINUX bootloader on a FAT filesystem

      [root@localhost ~]# syslinux /dev/sdb1
    3. Mount /dev/sdb1 & install Grub

      [root@localhost ~]# mount /dev/sdb1 /mnt

      [root@localhost ~]# grub-install –root-directory=/mnt /dev/sdb

      Probing devices to guess BIOS drives. This may take a long time.

      Installation finished. No error reported.

      This is the contents of the device map /mnt/boot/grub/device.map.

      Check if this is correct or not. If any of the lines is incorrect,

      fix it and re-run the script `grub-install’.

      (fd0) /dev/fd0

      (hd0) /dev/sda

      (hd1) /dev/sdb

    4. Verify that the USB hard disk has a /boot/grub directory, if no, create it manually.

      [root@localhost ~]# cd /mnt/boot/grub/
    5. Create grub.conf in /boot/grub. Below is a sample config for ‘grub.conf’

      default=0

      timeout=5

      root (hd1,0)

      title Centos 5.5 Linux Installer

      kernel /vmlinuz

      initrd /initrd.img

    6. Umount /dev/sdb1

      [root@localhost boot]# cd

      [root@localhost ~]# umount /dev/sdb1

  5. USB hard disk should be bootable by now.
  6. Remember to change the BIOS setting to give priority to boot removable device 1st
Related Posts
  • No Related Posts
Leave a Reply 4800 views, 2 so far today |
Related Posts
  • No Related Posts