Using dd to create disk images

Never mind Acronis True Image – you can use the command line to work with disk images and backups, without any extra software.

Create a hard disk image:

dd if=/dev/hda1 of=/home/hda1.bin

Create a compressed disk image

dd if=/dev/hda1 | gzip > /home/hda1.bin.gz

Back up the MBR

dd if=/dev/hda of=/home/hda.boot.mbr bs=512 count=1

Restore MBR (from a Live CD)

dd if=/mnt/hda1/home/hda.boot.mbr of=/dev/hda bs=512 count=1

Backup a drive to another drive

dd if=/dev/hda of=/dev/hdb conv=noerror,sync bs=4k

6 Replies to “Using dd to create disk images”

  1. Thank you for this Dougie.

    I want to clone my whole ubuntu hdd installation onto a smaller hdd. Could you advise which command will do this?

    Thank you for your time.

    Best wishes,

  2. You would need to use the last command but would have to compress the image if the available space on the drive to be backed up is larger than the backup drive.

    However as easier solution is to install partimage (sudo apt-get install partimage) which is designed for this purpose.

  3. quick question: would this last command (for backing up to another disk) create a partition of identical size?
    i ran out of space and am looking for ways to move the entire system to a bigger drive…

  4. dd and dd_rescue are great, I use them all the time.

    The advantage for file system aware tools like Acronis or Clonezilla is that they are MUCH faster than dd. dd and dd_rescue are fantastic, especially where the drive has issues (bad sectors, etc) and other imaging tools fail.

    However, if you just need to quickly mirror a drive, dd is pretty slow. That is where Acronis and even better Clonezilla come in. Clonezilla will let you do disk to disk and disk to image transfers, will place the image over the network using SSHFS, SMB etc. Acronis is perfect for going from different size drives as it dynamically resizes the partitions, save a lot of time and steps.

    Of course you can get fancy and just pipe dd through netcat to a listening port on a receiving server too – but it is still painfully slow. Clonezille let’s you dump to a remote server considerably faster.

    Generally, I say use Acronis or Clonezilla if the drive health is good, and fall back to dd_rescue if not.

    If you are interested I have an article on Clonezilla here:

    It’s very easy to set this up on a PXE server so you can save / restore images over a network – very slick!


Comments are closed.