dd
LINUXLPIC1-101
3/4/2026


dd
The dd command (often jokingly called "Disk Destroyer" because a small typo can wipe a drive) is a low-level utility used for copying and converting raw data. It works block-by-block, ignoring filesystems and focusing on the underlying bits.
The Command: dd if=/dev/sda of=/dev/null
This specific command is essentially a read-speed test for your hard drive.
if=/dev/sda: Input File. It reads the raw data from your first physical hard drive (sda).
of=/dev/null: Output File. It sends all that data to the "bit bucket"—a virtual device that discards everything sent to it.
The result: You aren't saving any data, but when the command finishes, dd will report how much data was processed and the average transfer speed. It tells you how fast your disk can read data.
1. Backing up the MBR (Master Boot Record)
The MBR sits in the first 512 bytes of a disk. If it gets corrupted, the system won't boot.
dd if=/dev/sda of=mbr_backup.bin bs=512 count=1
bs=512: Set the Block Size to 512 bytes.
count=1: Only copy one block.
2. Cloning a Whole Drive
You can mirror an entire drive to another identical drive.
dd if=/dev/sda of=/dev/sdb
Warning: This will overwrite everything on /dev/sdb.
3. Wiping a Disk (Security)
If you are throwing away a computer, you can fill the drive with zeros or random data so the old files can't be recovered.
dd if=/dev/zero of=/dev/sda # Fills with zeros # OR dd if=/dev/urandom of=/dev/sda # Fills with random noise
4. Creating a Swap File
If you run out of RAM and need more swap space quickly, you can use dd to create a large empty file.
dd if=/dev/zero of=/swapfile bs=1M count=1024 # Creates a 1GB file
Flags to Memorize
Flag Meaning
if= Input source (file or device).
of= Output destination.
bs= Block Size (e.g., 512, 1M, 4k). Crucial for speed performance.
count= Number of blocks to copy.
status=progress Shows a live progress bar (very helpful for large disks).
Contact
hello@unixtips.eu
© 2025. All rights reserved.