Home > Package & System Management > dd

dd: Data Copy and Conversion (Disk Cloning/USB Creation)

A powerful tool for copying and converting files block by block. It's used for creating bootable USBs, backing up disks (image dumps), and creating files. However, it's nicknamed 'Disk Destroyer' because incorrect output targeting can lead to complete data loss.

What is dd?

dd is known as an abbreviation for 'Data Description' or 'Disk Dump'. Unlike conventional copying (`cp`), it's used to directly manipulate hardware devices (disks, USBs) or to replicate raw data bit by bit.

Core Syntax Structure

Options are used in `key=value` format without preceding hyphens (-).

  • if (Input File): The input source. (Original file, ISO image, disk device to read from, etc.)
  • of (Output File): The output destination. (Location to copy to, USB device, backup file, etc.) **This is the most critical option.**
  • bs (Block Size): The amount of data to read and write at once. (e.g., 4M, 1G). Affects speed.

⚠️ Warning: Must Check Before Use

If you accidentally specify a system hard drive for `of=` (output destination), your operating system and data will be instantly erased. Always confirm the device path (e.g., `/dev/sdb`) using the `lsblk` command.

Key Options (Shell)

The order of dd options is not critical, but typically `if` > `of` > `bs` > `status` is used.

1. Input/Output Specification (Required)

2. Size and Speed Control

3. Data Conversion and Control

Generated command:

Try combining the commands.

Description:

`dd` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Scenario Examples

Common dd command patterns used in practice.

Creating a Bootable USB

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

Burns an ISO file to a USB device (assuming `/dev/sdb`). `bs=4M` is for speed improvement.

Full Disk Backup (Image Creation)

sudo dd if=/dev/sda of=~/backup.img bs=64K status=progress

Creates an image file `backup.img` from the entire `/dev/sda` disk.

Completely Wiping a Disk

sudo dd if=/dev/urandom of=/dev/sdX bs=1M status=progress

Overwrites a disk (`/dev/sdX`) with random data, making recovery impossible.

Creating an Empty File of Specific Size

dd if=/dev/zero of=testfile_1GB bs=1G count=1

Creates a 1GB empty file (filled with zeros) for testing purposes.

Tips & Precautions

Useful Tips

  • sudo Permissions: `sudo` is absolutely necessary when dealing with hardware devices (/dev/...).
  • /dev/zero and /dev/urandom: `if=/dev/zero` outputs an infinite stream of zeros, and `if=/dev/urandom` outputs an infinite stream of random data. These are special files.
  • Finding USB Devices: Before and after plugging in a USB, use the `lsblk` command to accurately identify the newly appearing device name (e.g., sdb, sdc).

Related commands

These are commands that are functionally similar or are commonly used together.



Same category commands