Linux dd Operations

I recently was helping a friend with some computer trouble which resulting in me first creating a full disk Image backup using “dd”. I’ve done this before years ago, but I wanted to add some of the common dd backup/restore methods to my notepad. There are so many articles online on how to use dd to do a Full disk backup and restore it. I will be using similar methods.

dd Terms

  • if — input device (file,hardware,CD,etc).
  • of — output device (file,hardware,CD,etc).
  • bs — sets “dd” read and write size.
  • noerror — continues after read errors.
  • readom — CD to ISO utility.
  • mount — Linux command to mount file-systems
  • gz — gunzip is a compression utility which helps to reduce the size of images created with dd.
  • md5sum — a checksum utility to ensure integrity when moving large image files.

Direct Hard Drive to Hard Drive clone:

Hard Drive to Image

Partition to Image

NOTICE: This is the same command as the above example except it specifies the sda1 partition..

Get dd Status

This will monitor the status of the running dd process every 5 seconds.


NOTICE: Read this page as to why readom is better than using dd for reading CDs.

Zero a Drive

NOTICE: This will write zeros to each block on the drive. Using /dev/random is safer to ensure data cannot be recovered ,however it is more CPU and time intensive.
**notrunc — Does not truncate the output file. This is important as you want the entire drive zero’d


  • First part tests the write performance of the drive by growing a file of “zeros” to a file size of 1GB. The bs=1024 will use a block size of 1024bytes. This is really a cool utility, I remember using it to perform a benchmark test of my home RAID server when I completed the RAID set up.
  • Second part tests the read performance of the drvie by re-reading the file we just created.

NOTICE: The differences in read/write is to be expected as performance benefits of RAID.

Mounting Single Partition Image File

NOTICE: Replace vfat with the filesystem type.

Mounting Full Disk Image Partition

**If the image to be restored contains multiple partitions, you will need to offset the image file to single out a partition to mount.
First use fdisk to read the image file and get the starting sector of the partition you want to mount.

x = sector size (usually 1024)
y = starting sector (from fdisk -l)

For my case:


Assuming image file name is hd.img, get md5sum of uncompressed Image. This will ensure integrity when compressing/decompressing.

This may take a while depending on how large a file, and will generate a checksum string. I would save this string with the image file.

Compress the image file.

NOTICE: This will compress the hd.img file using best compression. Time of compression will vary based on file size and bit complexity.



Leave a Reply