| Thursday November 20th 2014

Feedburner

Subscribe by email:

We promise not to spam/sell you.


Search Amazon deals:

HOWTO: Making a USB Key Bootable in Linux


tux-linux-penguin.jpgWhen 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 procedure
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:

mke2fs /dev/sda1
mount /dev/sda1 /media/usbdisk
grub-install --no-floppy --root-directory=/media/usbdisk /dev/sda
cd /media/usbdisk/boot/grub
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
cd -

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...

Reader Feedback

2 Responses to “HOWTO: Making a USB Key Bootable in Linux”

  1. Jerry Geis says:

    I have been a long time linux user and would appreciate
    a little clarification on using usbboot1 and usbboot2.

    I looked at my debian netinst.iso and I see no suck files.

    Can you send me a little more details about the last steps
    when using usbboot1 and usbboot2.

    Thanks,

    Jerry

  2. Mike says:

    Great weblog right here! Also your site a lot up very fast! What host are you the usage of? Can I get your affiliate hyperlink to your host? I desire my website loaded up as fast as yours lol

Leave a Reply

You must be logged in to post a comment.