dd(1)
Copy and convert data at the block level, useful for disk imaging, cloning, and low-level data manipulation.
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
| Flag | What it does |
|---|---|
if=FILE | Input file (default: stdin); use /dev/sdX for disk devices |
of=FILE | Output file (default: stdout); use /dev/sdX for disk devices |
bs=BYTES | Block size in bytes (e.g., 4096, 1M); default 512 |
count=N | Copy only N input blocks, then stop |
skip=N | Skip N blocks from input before starting |
seek=N | Skip N blocks in output file before writing |
conv=CONVERSION | Convert data: notrunc (no truncate), sync (pad), noerror (continue on error) |
status=progress | Show live transfer rate and progress (GNU dd) |
iflag=direct | Use O_DIRECT for input (bypass cache) |
oflag=direct | Use 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=progressWrite 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=progressClone 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=progressCreate a 1GB file filled with zeros (useful for testing or sparse file creation)
dd if=/dev/zero of=large_file bs=1M count=1000Securely wipe /dev/sda by filling with random data, bypassing cache
sudo dd if=/dev/urandom of=/dev/sda bs=1M iflag=direct oflag=directCopy 1MB from source.bin starting at offset 512KB to dest.bin
dd if=source.bin of=dest.bin skip=512 count=1024 bs=1024Back up a single partition (/dev/sda1) to an image file
sudo dd if=/dev/sda1 of=partition_backup.img status=progressPipe zeros through dd to write to /dev/sdb (alternative wipe method)
dd if=/dev/zero bs=1M | dd of=/dev/sdb bs=1M