How to use dd for disk imaging and cloning

· Category: Linux

Short answer

dd copies data at the block level, making it ideal for disk images, backups, and cloning.

Steps

  1. Create a disk image:
sudo dd if=/dev/sda of=/backup/sda.img bs=4M status=progress
  1. Clone a disk:
sudo dd if=/dev/sda of=/dev/sdb bs=4M status=progress
  1. Restore from image:
sudo dd if=/backup/sda.img of=/dev/sda bs=4M status=progress
  1. Create a compressed image:
sudo dd if=/dev/sda bs=4M | gzip > /backup/sda.img.gz

Tips

  • status=progress shows transfer statistics (GNU dd).
  • bs=4M improves speed over the default 512 bytes.
  • Use fdisk -l or lsblk to identify correct devices.

Common issues

  • Wrong of device overwrites the wrong disk irreversibly.
  • Very large images: ensure destination has enough free space.