Pages

Monday, June 27, 2016

Create Bootable USB Disk For Linux With "dd" Command

Create Bootable USB Disk For Linux With "dd" Command


Bootable USB Disk creation is one of the common thing that Linux users will do often in their Linux Life..
There's a several ways are available to create bootable USB Disk for Linux (such as UNetbootin, Linux live usb.. etc..).
"dd" command is one of the simple way to create bootable USB disk for Linux through Linux Command Line..and also, The most Linux distros comes with "dd" tool pre-installed.
Today i am going to show how to create bootable USB with "dd" command..

Note : dd is very powerful tool. dd stands for "Data Duplicator" which is make copy using block by block from one device into another device. So we can also use dd tool for data backup and restore from one device into another device. at the same time be careful wile using dd tool. because improper use may make your target device/memory stick unusable..

Now see how to create one with dd command....

The first thing you have to do is , identifying your USB device label.. it's very important, Because if we identify it wrongly.. we will end up with data loss.. So be careful with while identifying which one is your intended USB disk for this operation.. Just see following example..

Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk identifier: 0x000d5d58 Device Boot Start End Blocks Id System /dev/sda1 * 2048 52002815 26000384 83 Linux /dev/sda2 52004862 312580095 130287617 5 Extended Partition 2 does not start on physical sector boundary. /dev/sda5 262002688 312580095 25288704 7 HPFS/NTFS/exFAT /dev/sda6 52004864 60002303 3998720 82 Linux swap / Solaris /dev/sda7 60004352 261988351 100992000 83 Linux Partition table entries are not in disk order Disk /dev/sdb: 15.6 GB, 15631122432 bytes 255 heads, 63 sectors/track, 1900 cylinders, total 30529536 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sdb1 32 30529535 15264752 c W95 FAT32 (LBA) shivaraj@shivaraj-A14RM0E:~$

Just note that... sdb is my pen drive/device (sdb1 is partition present in my pendrive /dev/sdb). That is assigned by Linux operating system automatically while inserting pen drive into our system. You can identify it by typing following command

sudo fdisk -l

After identifying our intended device to create bootable USB disk, we need to format our pen drive/device..
Before formatting the device/pen drive , we have to unmount all of its mounted partitions ..

So , unmount it first with following command..

sudo umount /dev/sdb1

Now format the pen drive to FAT32 disk format..

sudo mkfs.vfat -I /dev/sdb

The above command will format the pen drive and makes FAT filesystem.
After that use dd command to create bootable USB disk..

sudo dd if=/path to iso/name_of_the_iso.iso of=/dev/sdb bs=1M; sync

For example, here i am going to create bootable USB disk from ubuntu-16.04-desktop-amd64.iso which is stored at ~/Downloads/os/.

sudo dd if=~/Downloads/os/ubuntu-16.04-desktop-amd64.iso of=/dev/sdb bs=1M; sync

Here,
If stands for input file. It is used to specify the location of the ISO file.
Of stands for output file. It specifies where to write the ISO file. In our case, it's /dev/sdb

It takes some time to copy one disk to another disk. dd tool does not show progressing status.

That’s all. You can use the same procedure to make any OS to make bootable USB drive.

Note that..While creating bootable USB by using above method, dd tool will make several partition on that pen drive. So after using bootable USB, It is best to format and use the pen drive for making another bootable ISO.

Don't forget to unmount the USB ... after unmounting the usb drive, run the following command to format it..

sudo mkfs.vfat -I /dev/sdb

That's all for now... and guys, Don't forget to share it with fellow Linux friends..

Happy Linux..