Creating bootable disk using “dd” linux command

Source: Google Image

There are many ways to make a USB flashdisk bootable for many purpose. One of those purpose maybe to run a live OS from flashdisk or maybe to do a fresh install for a certain OS. In this article I would like to share my little knowledge for using one of the linux command to do such thing. That command is dd, abbreviation for disk dump. But I must warn you that this command is very dangerous, although this command is also powerful.

Requirements for this tutorial:

  1. terminal
  2. run as root (for simple command execution)
  3. disk to be written (USB flashdisk or SD card or any storage disk, larger than the size of the ISO file)
  4. ISO image for OS that you want (*.iso or *.img)

Note: All commands below are executed as root

Okay, let’s begin the instructions then!

First, you must know which device you would like to write into. To know this you may want to run command:

root@linux:~# fdisk -l

It will show you the list of disk(s) and their partition(s) that recognized by your linux system. Your harddisk maybe located at /dev/sda and (assume) your USB flashdisk is at /dev/sdb. Their partitions will be shown by number, for example /dev/sda1, /dev/sda2, /dev/sdb1, etc. If your disk doesn’t have any partitions, they won’t have partition block such as /dev/sdb1 or /dev/sdb2 but it will show only the disk location, /dev/sdb for example. Make sure you remember where is the location of disk that you want to write the ISO image into. You don’t want to wipe out your harddisk, right?

Second, make sure you know the location of your ISO image. In this tutorial I am using an 64-bit Ubuntu LTS 16.04 ISO image and is located at /home/ubuntu_1604_x64.iso. Now go to the terminal, and type:

root@linux:~# dd if=/path/to/your/file.iso of=/dev/sdX

The if switch tells the system to write the specified file, into the path that specified by the of switch. Remember that /dev/sdX is your disk location to be written into. In my case, it should be like this:

root@linux:~# dd if=/home/ubuntu_1604_x64.iso of=/dev/sdb

Notice that I wrote the ISO image into the whole disk (/dev/sdb), not into particular partition like /dev/sdb1 or /dev/sdb2 or anything. This will make the disk bootable since we write an OS image. Be careful for what path you write in the of switch, because if you wrong specify the path to your harddisk (at /dev/sda), it will cause you lose y0ur data (wipe out your main harddisk). This is why I call them very dangerous command.

Next, wait until the command finished.

After that, now check for the partitions of that disk. You may want to run this command:

root@linux:~# fdisk -l

Now notice that your disk partitions differ from the early partitions. And if I true, your disk may get unallocated space. This is natural since we write the ISO image smaller than the total size of our disk. You can reclaim back those unallocated space using GParted or any partitioning software.

And finally, our USB flashdisk is ready to use! Enjoy!

Note: You can check if the flashdisk is working by restarting your computer and see what happen.

Note: I’m using Lubuntu 16.04 when I wrote this post