Linux command line bootable startup disk creator

Creating a bootable USB drive from the Linux command line

When you need to (re)install a (new) host with Linux, Windows or other kind of operating system provided with an ISO file, burning a CD or DVD is not always an option. Therefore, a USB disk drive may come in handy.

Unfortunately, using a GUI program on Windows or Linux will not always work as you expect. Also, a GUI will not always be available (like on a production server). A solution to this, which always works in my experience, is dd: a command line tool which make you able to convert and copy a file. This should be available by default on the most common Linux distributions. Using ‘dd’, you are actually ‘burning’ the ISO to the USB drive, like you are burning a CD or DVD, except that the USB drive can be rewritten over and over again.

Creating the disk

Download your favorite operating system or anything you want to ‘burn’ to your USB drive (as long as it is a ISO file).

First, check which device you need to write your ISO file to (in most cases it will be /dev/sdb):

cat /proc/partitions

This should show you a list with the sizes of the available devices and partitions. For the next steps, I will use /dev/sdb as the device name to write the ISO file to, replace /dev/sdb for the device name which is applicable for you.

You don’t need to format the USB drive first, since ‘dd’ will do that automatically. Make sure that there are no important files on the USB drive you want to keep, since the drive will be overwritten completely in the next step.

Make sure that the device is unmounted:

sudo umount /dev/sdb

Replace ‘/dev/sdb’ with the device name which is applicable for you.

Second, use ‘dd’ to copy the files from the ISO to the USB drive:

sudo dd if=/home/user/Downloads/CentOS-6.5-x86_64-minimal.iso of=/dev/sdb

This may take some time, depending on the size of your ISO file and the writing speed of your USB drive.

Optionally, you can also set the block size with the ‘bs‘ parameter to 4MB (default) or 1MB, if you like:

sudo dd bs=4M if=/home/user/Downloads/CentOS-6.5-x86_64-minimal.iso of=/dev/sdb

Third, use ‘sync’ to apply the changes:

sudo sync

Done! Now, put your USB drive in the host you want to install and boot it.

Leave a Reply

Your email address will not be published.