dd
Archives
Usage
dd if=<source> of=<target> bs=4M status=progressCopies block for block, which is how an installer image gets written to a device; whatever you name in `of=` is overwritten from block zero with no confirmation and no way back, so confirm the device with lsblk immediately before pressing Enter, use `bs=4M` for speed and `status=progress` (Ctrl+T on macOS) to watch it.
Common flags
| Flag | Meaning |
|---|---|
| if=<file> | Input file or device. Leaving it out reads stdin. |
| of=<file> | Output. Whatever this names is overwritten from block zero, with no confirmation. |
| bs=4M | Block size. Too small and the copy crawls. |
| count=<n> | Copy only n blocks. |
| status=progress | Show progress (GNU). On macOS press Ctrl+T instead. |
| conv=fsync | Flush to the device before exiting, so the numbers mean something. |
| conv=notrunc | Write in place without truncating the output file. |
Examples
lsblkAlways confirm the device name immediately before the next command.
sudo dd if=ubuntu.iso of=/dev/sdb bs=4M status=progress conv=fsyncWrite an installer image to a whole USB device (Linux).
diskutil unmountDisk /dev/disk4 && sudo dd if=ubuntu.iso of=/dev/rdisk4 bs=4mOn macOS the disk must be unmounted first, or dd fails with Resource busy; rdiskN is the fast raw path.
Bundling and compressing are separate jobs: tar bundles, gzip shrinks, and .tar.gz is both.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does dd do?
Copies block for block, which is how an installer image gets written to a device; whatever you name in `of=` is overwritten from block zero with no confirmation and no way back, so confirm the device with lsblk immediately before pressing Enter, use `bs=4M` for speed and `status=progress` (Ctrl+T on macOS) to watch it.
Q. How do I type it?
dd if=<source> of=<target> bs=4M status=progress — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
7 are listed here; the full set is in man dd. This command sits under Archives.
Related commands
man page: man dd