≡ Menu

Linux Create A Bootable USB Pen

How do I create a bootable USB pen drive to start my CentOS / Fedora Linux? How do I create a bootable USB flash pen for installation of Linux, and for creation of rescue and other special-purpose boot disks using command line options?

You need to format your USP pen device as Win FAT32. Once formatted type the following commands to make it bootable.

Our Device Names

  1. USB Pen Device Name : /dev/sdb1
  2. DVD Mount : /media/cdrom0
  3. USB Mount Point : /media/usb
  4. USB File System : Win FAT32
  5. ISO or DVD Image : Fedora / CentOS / RHEL
WARNING! These examples may crash your computer or result in data loss if not executed properly. You must understand device names, file systems and required to use fdisk partition table manipulator for Linux. This howto intended to simplify first-time installation of Linux, and for creation of rescue and other special-purpose boot disks.

To find information about your devices and current partitions run:
# dmesg | less
# dmesg | egrep -i 'cd|dvd'
# fdisk -l

Use the first command to identify the USB device name.

Mount CD/DVD ISO or DVD ITSELF

Type the following command to mount Fedora 12 iso image:
# mount Fedora-12-x86_64-netinst.iso -o loop /media/cdrom0/
# DVD=/media/cdrom0
# ls -l $DVD

Sample outputs:

total 6
dr-xr-xr-x 3 root root 2048 2009-11-09 05:37 EFI
drwxr-sr-x 3 root  499 2048 2009-11-09 05:37 images
drwxr-sr-x 2 root  499 2048 2009-11-09 05:36 isolinux

You need to use files stored in isolinux directory to create a bootable usb pen.

Format Usb

Create the fdisk partition:
# fdisk /dev/sdb
You need to create only 1 partition. Next format the partition:
# USB=/media/usb
# mkdosfs /dev/sdb1

Finally mount the partition:
# mkdir -p /media/usb
# mount /dev/sdb1 /media/usb
# USB=/media/usb

Copy Required Files

Type the following commands:
# cp -av $DVD/isolinux/* $USB
# cd $USB
# rm isolinux.bin boot.cat TRANS.TBL
# mv isolinux.cfg syslinux.cfg

Also copy the installer's initial RAM disk $DVD/images/pxeboot/initrd.img (for CentOS / RHEL Linux use $DVD/RedHat/images/pxeboot/initrd.img file) CD/DVD onto the usb drive:
# cp -v $DVD/images/pxeboot/initrd.img $USB

Unmount the USB drive

# umount /dev/sdb1

Make the USB Bootable

Type the following command to make the USB drive bootable
# syslinux /dev/sdb1
# mount /dev/sdb1 $USB

syslinux is a boot loader for the Linux operating system which operates off an MS-DOS/Windows FAT filesystem.

Install Grub

Type the following command to install GRUB on the USB device:
# grub-install --root-directory=$USB /dev/sdb
Create grub.conf:
# cd $USB
# mkdir -p boot/grub

Edit the grub.conf file

default=0
timeout=5
root (hd1,0)
title Fedora Linux
kernel /vmlinuz
initrd /initrd.img

Finally, unmount the USB pen drive, enter:
# umount /dev/sdb1
Your USB pen is ready and should be bootable from the USB device. This can be used to install Fedora or CentOS or RHEL. You can also copy other required tools (such as sniffers or data recovery tools) on this pen. This is left as exercise for the reader.

Unetbootin Installer of Linux/BSD Distributions (GUI Tools)

If command line options are too complicated to follow. Try UNetbootin, which allows you to create bootable Live USB drives for a variety of Linux distributions from Windows or Linux, without requiring you to burn a CD. To install to a partition or USB drive type the following command:
$ sudo apt-get install unetbootin
Sample outputs:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  lsb-desktop m4 aggregate lsb pax lsb-graphics lsb-core ncurses-term lsb-cxx
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  unetbootin-translations
The following NEW packages will be installed:
  unetbootin unetbootin-translations
0 upgraded, 2 newly installed, 0 to remove and 9 not upgraded.
Need to get 428kB of archives.
After this operation, 1,843kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://archive.ubuntu.com karmic/universe unetbootin 356-1 [223kB]
Get:2 http://archive.ubuntu.com karmic/universe unetbootin-translations 356-1 [205kB]
Fetched 428kB in 2s (156kB/s)
Selecting previously deselected package unetbootin.
(Reading database ... 254825 files and directories currently installed.)
Unpacking unetbootin (from .../unetbootin_356-1_amd64.deb) ...
Selecting previously deselected package unetbootin-translations.
Unpacking unetbootin-translations (from .../unetbootin-translations_356-1_all.deb) ...
Processing triggers for desktop-file-utils ...
Processing triggers for man-db ...
Setting up unetbootin (356-1) ...
Setting up unetbootin-translations (356-1) ...

Type the following command to start unetbootin:
$ unetbootin

Fig.01: UNetbootin install Linux/BSD distributions to a partition or USB drive

Fig.01: UNetbootin install Linux/BSD distributions to a partition or USB drive

Say Hello To "USB Startup Disk Creator"

You can also use "USB Startup Disk Creator" utility in Ubuntu that creates a persistent Ubuntu image on a USB disk. This is called a "Live USB". You can use the Live USB to install Ubuntu on your computer or to run Ubuntu without affecting your system hardware. You need USB disk 1 GB (2GB is suggested) or larger in size and Ubuntu systems 8.10 or later. You also need Ubuntu ISO Image which can be downloaded from the official website. To start USB Startup Disk Creator visit
System > Administration > USB Startup Disk Creator

Fig.02: Ubuntu - USB Startup Disk Creator

Fig.02: Ubuntu - USB Startup Disk Creator

  • Click the Other... button and specify the Ubuntu image you downloaded in the previous step.
  • Under USB Disk to use your USB disk is highlighted.
  • To make the Live USB a writeable disk, indicate how much memory to use for extra storage. If you don’t want the Live USB to be modifiable, select the second option, Discarded on Shutdown.
  • Finally click Make Startup Disk to make a Live USB.

Finally, you can always use LiveCDs to recover or fix Linux system issues.

References:

  • See man pages - fdisk, mkfs, syslinux, and usb-creator-gtk (Ubuntu specific tool)

{ 19 comments… add one }

  • Johan March 12, 2010, 8:20 am

    The “USB Startup Disk Creator” utility in Ubuntu could also create an OpenSuse startup usb pen for me from the OpenSuse iso and the great thing is, you don’t have to format the pen for a new setup.

  • andy March 12, 2010, 8:27 am

    HI,

    Could you give the link or make an article how to make bootable usb on linux (ubuntu) for XP or vista.

  • Dariusz March 12, 2010, 2:26 pm

    why use windowz if there is a Linux?

  • Telvin April 5, 2010, 5:39 pm

    hey dude who is using windows now . common wake up this is 2010 . u can get anything and more in Linux .so throw away windows and have the fun with Linux

    • amarjeet August 12, 2011, 1:08 pm

      hey dude u r right yar .. i feel very good after using the linux

  • ADAM July 17, 2010, 4:23 pm

    any idea on getting this working with lilo rather than grub?

  • Sushant Chawla September 27, 2010, 7:01 am

    Hi

    The tutorial seems to have the right steps but it is not compatible with CentOS if you have configured your USB drive on Redhat & vice versa.

    I tried to install CentOS with my USB stick on which I followed the above steps for creating it as USB bootable drive. I created it on RHEL 5.3 but when I started installation for CentOS it said install media not matching with the boot media.

  • sundar_ima April 30, 2011, 10:12 am

    link to automated MultiBootUSB script to install multiple linux distros at a time is given below.
    http://multibootusb.sourceforge.net/
    and the forum link is here
    http://ubuntuforums.org/showthread.php?t=1518273

  • Paul W May 3, 2011, 3:36 am

    I’ve tried to load an ISO image of Ubuntu 10.10 using usb-creator.exe and clicking on “other”. When I choose the ISO image it doesn’t come up in the box on top. Nothing happens and the “create Startup Disk” button is still greyed out. What could be wrong here?

  • barrenaedu June 23, 2011, 3:08 am

    Instead using “#dmesg” I would rather use “#sudo fdisk -l”. It’s safer and avoid confusions.

  • raman jangir August 29, 2011, 4:54 am

    HI,

    Could you give the link or make an article how to make bootable usb on linux (ubuntu) for XP or vista..

  • Paul August 30, 2011, 9:17 am

    Two questions:
    1) What does the option called “indicate how much memory to use for extra storage” do, exactly? If I leave it at zero (the way it comes preset), is that the same as checking “discard on shutdown”?

    2) Are there any advantages to Startup Disk Creator vs. UNetBootin, or vice versa?

  • Rahul Agnihotri December 24, 2011, 5:33 pm

    My two cents –
    I was using the above steps to create a F15 x86_64 bootable pen drive for doing a from the corresponding dvd .iso. The objective is to use it for installation since the CD / DVD drive on the target machine is not working.

    However, after doing each step as directed, found that the space used on the pen drive was only around 100 megs.Since the .iso is around 3.5 gigs, was suspecting that the substantial set of files have not been transferred so ran the Unetbootin and could immediately see what was missing – the package files!

    Not sure if I missed something here but might be worth considering an update to the article to cover this aspect :)

  • Lake August 26, 2012, 4:02 am

    I didn’t get too far into this tutorial because there are a lot of missing steps. For example, what commands do I execute in fdisk? fdisking the USB drive doesn’t do anything but ask for more commands. I assumed I had to delete the old partition and create a new one, so I did that. Then I tried mkdosfs but it wouldn’t do it because the drive was mounted. So I had to unmount the drive. Then the computer didn’t know what to do with /media/usb in the next step, so I finally just gave up. Thanks for the guide, but I think there are a lot of holes that need to be filled in. Also, it would be nice if it was a little more general, since this seemed to be based on the assumption that there are certain files in the ISO image.

  • Marcin September 7, 2012, 9:35 pm

    Brilliant Tutorial – worked flawlessly.
    If I would like to use URL installation, what syntax is to append Kickstart file to the installation?
    Lets assume my install dir is:
    http://10.0.0.3/centos
    How would syntax looked liked if I had ks.cfg file located on:
    http://10.0.0.4/ks.cfg

    Thanks a lot in advance

  • saurabh singh March 8, 2013, 7:43 am

    getting the following message wile grub installation:-
    #grub-install –recheck –root-directory=/mnt /dev/sdd
    Probing devices to guess BIOS drives. This may take a long time.
    The file /mnt/boot/grub/stage1 not read correctly.

    Any Clue what it can be.

  • Robert England April 15, 2013, 3:32 pm

    Hey,

    how do I make a bootable windows usb stick? I installed ubuntu to test it but after a week I found a lot of problems:

    – no properly printer drivers
    – on skype I sound like shit (no noise cancelation)
    – not really a gaming OS.
    – my cpu fan is constantly running, it is very loud.

    .. now I want to coe back to windows but don’t know how, I don’t have a empty dvd right now..

  • sachin kate September 16, 2013, 2:34 am

    i am using ubantu 12.04 so give me about it;

  • ibcbet January 22, 2015, 9:40 am

    Hurrah! In the end I got a website from where I know how to genuinely obtain helpful facts regarding my study and knowledge.

Leave a Comment