How to write a disk image on Linux

You may sometimes need to write a disk image to a USB thumbdrive or a SD card. This is typically done to create a system that you can use to boot a device. The image file typically has the .img file extension, though its not necessary and does not matter. Writing the disk image can be easily done on Ubuntu or any other Linux distribution.

  • Insert the USB thumbdrive or SD or microSD card to your computer. It should be detected and Ubuntu might mount it automatically. If it does not, that is okay as long as it is detected.

  • We need to find out what is the device file which represents the inserted USB thumbdrive or SD card as described here.

  • Before we write the disk image, we need to unmount the device. This can be done by passing the device name to the umount command:

$ umount /dev/sdb
  • To write the disk image we can use the dd command. Provide the disk image file as the input file and the device file as the output file with a suitable block size:
$ sudo dd if=/blah/foo.img of=/dev/sdb bs=1M
  • Finally, we flush the disk buffers to ensure that the writing is finished:
$ sync

That is it! The disk image is written and you can take out your USB thumbdrive or SD card to use it.

Related: How to write a disk image on Windows using Win32 Disk Imager

Tried with: Ubuntu 12.04

How to write a disk image using Win32 Disk Imager

You are sometimes given a disk image that needs to be written to a USB thumbdrive or a SD card. This is typically used to create something that you can use to boot a device. The image file typically has the .img file extension, though its not necessary and does not matter.

  1. One way to write a disk image on Windows is using Win32 Disk Imager. Download it and unzip the contents.
  2. Plug in the USB thumbdrive or SD or microSD card to your computer. It should be detected and appear as a drive in Windows.
  3. Open Win32 Disk Imager, choose the .img or image file you want to write as Image File and choose the USB or SD drive as Device and press Write.
  4. The write may take a while. Once it is done, remove the USB thumbdrive or SD card and insert it into the device you want to use with.

Also see: How to write a disk image on Linux

Tried with: Win32 Disk Imager 0.8 and Windows 8 x64