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

Advertisements

6 thoughts on “How to write a disk image on Linux”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s