When I needed to make a USB key (aka. USB pen drive, USB memory stick, whatever) bootable under Linux I found there was a number of pages on the Internet that listed the steps needed. Some of these pages required you to do some steps from DOS and/or used the syslinux command.
I did not want to boot DOS in order to get the job done. I wanted to do everything from Linux. I tried the procedures which made use of the syslinux command but I didn’t get consistent results. Sometimes my USB key was bootable and sometimes it wasn’t.
I felt there had to be a better way to do this that used the same commands one would normally use to make a standard hard drive bootable. After a bit of experimentation and testing, I came up with the procedure which follows.
The information below provides an overview of the steps you need to follow in order to create a bootable ext2 based file system partition on a USB key. It is not an exact command by command set of instructions. You are expected to have some familiarity with Linux and the commands that will be used.
The information below is based on the assumptions that your USB key is /dev/sda and that it can be mounted to /media/usbdisk.
Run fdisk /dev/sda and create at least one partition. Remember to mark it as bootable. The following steps will assume the bootable partition is the first one (ie. /dev/sda1).
Now that you have a bootable partition, run the following commands:
mount /dev/sda1 /media/usbdisk
grub-install --no-floppy --root-directory=/media/usbdisk /dev/sda
rm fat_stage1_5 ffs_stage_1_5 iso9660_stage_1_5
rm jfs_stage_1_5 minix_stage_1_5 reiserfs_stage_1_5
rm ufs2_stage_1_5 vstatfs_stage_1_5 xfs_stage_1_5
At this point, the only remaining stage1_5 file in /media/usbdisk/boot/grub should be the one named ‘e2fs_stage1_5′.
The remaining information is for use when remastering a CD-ROM image for use on a USB key.
Delete (or don’t copy) the stage1, stage2, and *stage1_5 files from the /boot/grub directory of the ISO being remastered for a USB key prior to copying the ISO files over to the USB key.
In the grub directory, create a symlink called menu.1st which points to grub.conf. Add bootusb1 or bootusb2 to the kernel command line of the grub.conf file in /boot/grub.
Related Posts: On this day...
- Undercover TSA Agent smuggles gun through scanners multiple times - 2011
- Epic Beard Man interview - Thomas Bruso - 2010
- URL redirection service makes innocent URLs look sinister - 2010
- Buying movies vs pirating movies - 2010
- Google Maps face-blurring technology in action - 2009
- OpenX: More Than Just an Ad Server - 2009
- How fanboys see their respective worlds - 2009
- How Many Linux Users Are There (Really)? - 2009
- Time Magazine from 1999 - 2009
- Body scanners replace metal detectors in tryout - 2009