≡ Menu

How Do I Make Linux / UNIX Filesystem Backup With dd?

dd command is all in one tool to Copy a file, converting and formatting according to the options. Since Linux (and other UNIX versions) understand everything as a file dd works like wonders. Please note dd is not created specifically for a backup purpose but it is real handy tool. Few months back I was new to HP-UX and I was unable to understand the HP-UX tape devices then I used dd to create backup. Later when I got information of tape device name I switched to age old tar and other dump commands

dd command syntax

The syntax of dd is as follows:


dd command examples

So to backup /dev/hda3 under Linux command should be as follows i.e. linux filesystem backup with dd:
# dd if=/dev/hda3 of=/backup/myhostname-15-nov-05-hda3.bak.dd
However if you are running planning to run dd in background and if you wish to kill it or want to sending a SIGUSR1 single to a running dd process then you need to start dd as follows (this is really useful stuff):
# dd if=/dev/hda3 of=/backup/myhostname-15-nov-05-hda3.bak.dd; dpid=$!
Now use kill command as follows:
# kill -USR1 $dpid; sleep 5; kill $dpid

dd command to backup boot loader / MBR

dd can be use to backup your boot loader too (if you install a Windows after Linux it will destroy grub/lilo boot loader):
# dd if=/dev/hdX of=/backup/mbr.bak bs=512 count=1
You can restore MBR with the following dd command:
# dd if=/backup/mbr.bak of=/dev/hdX bs=512 count=1
Note replace hdX with your actual device name. However I prefer to use grub-install.

Please note that dd is also capable of reading tapes that were created on other UNIX or written in a format other than Unix (like Windows 2000 server).

Here is one more practical example for Solaris UNIX:

To copy all but the label from disk to tape i.e. copy data in 512 KiB blocks between a disk and a tape, but do not save or restore:
# (dd bs=4k skip=1 count=0 && dd bs=512k) </dev/rdsk/c0t1d0s2 >/dev/rmt/0
Copy from tape back to disk, but leave the disk label alone (restore):
# (dd bs=4k seek=1 count=0 && dd bs=512k) < /dev/rmt/0 >/dev/rdsk/c0t1d0s2

Backing up entire disk/partition with dd command

Backup /dev/hda to /dev/hdb:
# dd if=/dev/hda of=/dev/hdb conv=noerror,sync

  • /dev/hda: Source disk
  • /dev/hdb: Target disk
  • sync: Use synchronized I/O for data and metadata
  • noerror: Continue copy operation after read errors

Above command will only work if the both disks are the same size and C/H/S geometry. I strongly suggest using partition level backup. dd is an easy to use (real life saver) command. Read the man page of dd for more information.
$ man dd

Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

Comments on this entry are closed.

  • Jann January 28, 2009, 7:08 pm

    I know that you can later on mount partition-level dd dumps. Can you also somehow mount the dump of an entire disk?

  • A person June 25, 2009, 7:34 pm

    RE: Jann…

    dunno, give it a try. In unixland, you’d do something like:
    mkdir /mnt/mountpoint
    mount -t ext3 /somepath/ /mnt/mountpoint

  • Eric J December 16, 2010, 11:19 am

    I never knew about this tool. I was only recently exposed to it while reading how one man managed to boot ubuntu on the CR-48. He dd’ed the ubuntu rootfs to the CR-48 over ssh. SO. COOL.

  • Dave May 19, 2011, 4:59 pm

    I would like to use dd to make a backup of my USB flash drive to my HDD, I’m using a Live CD, both are unmounted.
    I tried:
    dd if=/dev/usbflashdrive of=/dev/sda1>usbdiskdate.img
    This destroyed the ext3 partition.

    Any suggestions for improvement?

  • robert June 17, 2011, 8:04 am


    Youre an idiot

  • CesarIII July 20, 2011, 5:00 am

    Hi there,

    If you are trying tu backup an USB you can try “dd” + “gzip” so you can compress your backed-up-data. You can improve compression ratio, and even more, If you create a file filled with “0” an then delete it, you’ll obtain a smallest file:

    To create a file with “0” so we erase the free area:

    dd if=/dev/zero of=DELETE.ME

    Once created, delete it.
    Once deleted, backup:

    dd if=/dev/usbflashdrive | gzip –best > backup.img.gz

    You can improve reading/writing by adding “bs” or “obs” on dd… check “man dd”

    dd obs=100MB if=/dev/usbflashdrive | gzip –best > backup.img.gz

    Make tests… eh!… to restore just do a:

    gunzip -c backup.img.gz | dd bs=100MB of=/dev/usbflashdrive


  • Oran November 4, 2011, 6:19 pm

    Thank you for the tutorial. I want to buy an identically sized drive for performing a dd backup, but am concerned about the ability to accomplish this. The drive that I currently have lists the capacity as 251.0 gb (using fdisk). Hard drives that I find advertised only list 250.0 gb. If I get a 250.0 gb hard drive, then the backup could potentially be corrupted due to losing 1.0 gb of space, right? How is this handled? Is there a way to find 251.0 gb hard drives?


  • JIEM February 20, 2012, 10:03 am

    I want to clone a 500GB hard drive (sda) to new hard drive (sdb)
    is it possible if using command, dd if=/dev/hda of=/dev/hdb conv=noerror,sync

  • Eric J February 20, 2012, 1:18 pm

    I believe you can. It wouldn’t hurt anything if you did, but the new drive would need to be at least or larger than the old one.

  • CesarIII February 20, 2012, 4:27 pm

    It is possible, if both hard drives are the same manufacturer, model.
    If not, you may have a partition table with wrong disk description.
    Try something like:

    dd bs=100MB if=/dev/hda of=/dev/hdb

    to make it in less time.