$linuxjunkies
>

dd(1)

Copy and convert data at the block level, useful for disk imaging, cloning, and low-level data manipulation.

UbuntuDebianFedoraArch

Synopsis

dd if=FILE of=FILE [OPTION]...

Description

dd reads from an input file (or device) and writes to an output file (or device), with optional data conversion. It operates on fixed-size blocks, making it ideal for raw disk operations, creating backups, and wiping data. Unlike cp, dd works directly with block devices and allows precise control over block size and data transformation.

Common uses include cloning entire disks, creating bootable USB drives from ISO images, backing up partitions, and securely erasing drives. Always verify the of= parameter carefully—mistakes can destroy data.

Common options

FlagWhat it does
if=FILEInput file (default: stdin); use /dev/sdX for disk devices
of=FILEOutput file (default: stdout); use /dev/sdX for disk devices
bs=BYTESBlock size in bytes (e.g., 4096, 1M); default 512
count=NCopy only N input blocks, then stop
skip=NSkip N blocks from input before starting
seek=NSkip N blocks in output file before writing
conv=CONVERSIONConvert data: notrunc (no truncate), sync (pad), noerror (continue on error)
status=progressShow live transfer rate and progress (GNU dd)
iflag=directUse O_DIRECT for input (bypass cache)
oflag=directUse O_DIRECT for output (bypass cache)

Examples

Backup entire /dev/sda disk to an image file with 4MB blocks and progress display

sudo dd if=/dev/sda of=disk_backup.img bs=4M status=progress

Write Ubuntu ISO to USB drive (/dev/sdb), syncing data to ensure reliability

sudo dd if=ubuntu.iso of=/dev/sdb bs=4M conv=fsync status=progress

Clone entire disk /dev/sda to /dev/sdb (both must exist; sdb will be overwritten)

sudo dd if=/dev/sda of=/dev/sdb bs=1M status=progress

Create a 1GB file filled with zeros (useful for testing or sparse file creation)

dd if=/dev/zero of=large_file bs=1M count=1000

Securely wipe /dev/sda by filling with random data, bypassing cache

sudo dd if=/dev/urandom of=/dev/sda bs=1M iflag=direct oflag=direct

Copy 1MB from source.bin starting at offset 512KB to dest.bin

dd if=source.bin of=dest.bin skip=512 count=1024 bs=1024

Back up a single partition (/dev/sda1) to an image file

sudo dd if=/dev/sda1 of=partition_backup.img status=progress

Pipe zeros through dd to write to /dev/sdb (alternative wipe method)

dd if=/dev/zero bs=1M | dd of=/dev/sdb bs=1M

Related commands