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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 12 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
12 comments… add one
  • Jann Jan 28, 2009 @ 19:08

    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 Jun 25, 2009 @ 19:34

    RE: Jann…

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

    • Greg Jan 9, 2016 @ 2:01

      Jann is asking, I think, about dumping an entire disk (e.g. /dev/sdb) – can you mount the filesystems on /dev/sdb1 and /dev/sdb2 from the copy. I’m pretty sure the answer is ‘no’ – since the mount operation expects to find the filesystem at the start of the data – if you really wanted to, you could extract the partitions from the dump (again using dd) and mount those. It’s not very useful to dump an entire disk, all you can easily do is copy it back to a disk of the same size. And you’d probably be wasting time and space copying a ‘swap’ partition too.

  • Eric J Dec 16, 2010 @ 11:19

    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 @ 16:59

    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 Jun 17, 2011 @ 8:04


    Youre an idiot

  • CesarIII Jul 20, 2011 @ 5:00

    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 Nov 4, 2011 @ 18:19

    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 Feb 20, 2012 @ 10:03

    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 Feb 20, 2012 @ 13:18

    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 Feb 20, 2012 @ 16:27

    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.


  • Greg Jan 9, 2016 @ 1:53

    One thing to watch out for when doing partition backups (I found this out the hard way). Partitions have ‘uuid’ values which are intended to be unique for each partition, and that gets cloned in the dd copy. This can be a problem if you leave the backup partition on the machine, since many systems use the uuids in the /etc/fstab

    For instance my laptop has this line in /etc/fstab:

    UUID=893f11f2-d032-45a9-8f34-bae72858dd11 / ext4 errors=remount-ro 0

    … which specifies that the partition with that UUID should be mounted on ‘/’. So, what happens if you copy that to another partition and then reboot? It may be unpredictable which of the two gets mounted. I had a machine set up for months, two 1 TB drives, and a 50 GB root partition at the start of each; one was a real root and the other a backup. But sometimes when I rebooted the machine without switching it off, it would act strange, e.g. ask for updates I’d already done … turned out that under those conditions it was actually mounting the backup as the root partition…

    To avoid this, there’s a way to change the uuid after you do the copy so that this won’t happen, it should be done right after you make the image copy, using tune2fs, as described here:

    The use of UUIDs was intended to avoid problems using e.g. /dev/sdb, since the assignment of sda, sdb etc could change at a later reboot due to other drives being attached.
    Another approach to avoid this: the system creates symlinks in /dev/disk/by-id to /dev/sda1 etc, which are built from drive model # and serial #’s. for instance I have this

    ata-WDC_WD7500BPKX-22HPJT0_WD-WX41A93N9898-part1 -> ../../sda1 if I use /dev/disk/by-id/ata-WDC_WD7500BPKX-22HPJT0_WD-WX41A93N9898-part1 to identify the partition, that will find the same partition even the particular drive is at sdb or sdc. That string includes both the drive model and serial #, so it will work even I have two drives of the same model.

    A mount specified by UUID, on the other hand, will keep working if I replicate the partition to a new drive (including the UUID) and replace the old drive with the new one; whereas a mount using the drive identity would need to be updated. So the choice of one or the other depends on what problem you want to avoid.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum