Create Bootable USB Using dd
This page discusses on creating a live USB disk using dd command line tool. There are some other alternatives too on creating a live USB, but this method is preferred due to its simplicity. If you get into trouble while creating a bootable disk, start a discussion or switch to alternative methods. It is assumed that you have a working Linux system. To use dd on windows, one may use Cygwin or dd for windows (not recommended). For mac users some minor changes are required in the following steps to get a functional live disk. Those are not discussed here.
dd is a command line tool that comes pre-installed with UNIX and UNIX like operating systems. dd is commonly used to convert and copy files. dd can also read or write directly to or from special device files like /dev/sdb1. To learn more about dd refer to man dd.
Using dd to create a bootable USB disk
Warning: This method deletes all the data from the disk, and the USB disk cannot be used further till it is formatted.
dd uses an ISO file for creating a live disk. Place your desired ISO to a known location. Assuming the location to be /home/user/xyz_os.iso. Plugin the USB device. To find the USB device name, type:
usually the device's name is sdb or sdc.
If the device is automatically mounted, unmount it by typing:
sudo umount /dev/sdxy
Now, use dd as:
dd bs=4M if=/home/user/xyz_os.iso of=/dev/sdx && sync
here, bs is block size. if should be assigned the path of iso in your system. of is assigned the path of USB device.
Note: Do not append the partition number with device path. It is usually sdb or sdc. So do not do something like of=/dev/sdb1.
It takes a few minutes before your device is ready to boot from. After completion, the USB disk is ready to serve as a live disk. After the disk has served its purpose, one may want to restore the USB drive to use normally.
Recovering the USB drive
The ISO image is hybrid and does not includes any standard partition table. In order to make the disk usable for other purpose, a standard partion To restore the drive to its full capacity, zero out the first 512 bytes from the USB which includes the non standard partition table and boot code:
dd count=1 bs=512 if=/dev/zero of=/dev/sdx && sync
After this step, you need to create a standard partition table. You can use gparted for this. First select the USB drive from rightmost corner. Then, select create new partition table from the menu, and then format the drive to desired type.
To format the drive from command line, one can use parted or cfdisk to create the partition table and mkfs to format the drive:
cfdisk /dev/sdx mkfs.vfat -F32 /dev/sdx1
Now, you can use your drive normally.