Create Bootable USB Drive For Centos Installation

Create Bootable USB Drive For Centos Installation
July 23rd, 2010 | 8 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:
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.
You should have the Centos installation CD/image.
Running Webserver for Kick Start (unattended) OS installation.
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

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

Create 2 partitions
100 MB for boot image, boot image partition is Primary 1
Remaining for storage, storage image partition is Primary 2
Tag boot image partition as bootable
Set boot image partition type to FAT32 (type number 1)
Save & Exit

 

 

 

Format the partition
Format boot image partition as FAT32

Format storage partition as EXT3

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

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

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

Rename isolinux configuration file to syslinux.cfg

[root@localhost mnt]# mv isolinux.cfg syslinux.cfg

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.

Umount /dev/sdb1
[root@localhost isolinux]# cd

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

Install the SYSLINUX bootloader on a FAT filesystem
[root@localhost ~]# syslinux /dev/sdb1

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

Verify that the USB hard disk has a /boot/grub directory, if no, create it manually.
[root@localhost ~]# cd /mnt/boot/grub/

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

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