2023-01-01 04:34:56 +00:00
|
|
|
# dd
|
|
|
|
|
|
|
|
> Convert and copy a file.
|
|
|
|
> More information: <https://www.gnu.org/software/coreutils/dd>.
|
|
|
|
|
2024-03-03 21:00:11 +00:00
|
|
|
- Make a bootable USB drive from an isohybrid file (such as `archlinux-xxx.iso`) and show the progress:
|
2023-01-01 04:34:56 +00:00
|
|
|
|
2024-03-03 21:00:11 +00:00
|
|
|
`dd status=progress if={{path/to/file.iso}} of={{/dev/usb_drive}}`
|
2023-01-01 04:34:56 +00:00
|
|
|
|
2024-03-03 21:00:11 +00:00
|
|
|
- Clone a drive to another drive with 4 MiB block size and flush writes before the command terminates:
|
2023-01-01 04:34:56 +00:00
|
|
|
|
2024-03-03 21:00:11 +00:00
|
|
|
`dd bs={{4M}} conv={{fsync}} if={{/dev/source_drive}} of={{/dev/dest_drive}}`
|
2023-01-01 04:34:56 +00:00
|
|
|
|
2024-03-03 21:00:11 +00:00
|
|
|
- Generate a file with a specific number of random bytes by using kernel random driver:
|
2023-01-01 04:34:56 +00:00
|
|
|
|
2024-03-03 21:00:11 +00:00
|
|
|
`dd bs={{100}} count={{1}} if=/dev/urandom of={{path/to/random_file}}`
|
2023-01-01 04:34:56 +00:00
|
|
|
|
|
|
|
- Benchmark the write performance of a disk:
|
|
|
|
|
2024-03-03 21:00:11 +00:00
|
|
|
`dd bs={{1M}} count={{1000000}} if=/dev/zero of={{path/to/file_1GB}}`
|
2023-01-01 04:34:56 +00:00
|
|
|
|
2024-03-03 21:00:11 +00:00
|
|
|
- Create a system backup and save it into an IMG file (can be restored later by swapping `if` and `of`):
|
2023-01-01 04:34:56 +00:00
|
|
|
|
2024-03-03 21:00:11 +00:00
|
|
|
`dd if={{/dev/drive_device}} of={{path/to/file.img}}`
|
2023-01-01 04:34:56 +00:00
|
|
|
|
|
|
|
- Check the progress of an ongoing dd operation (run this command from another shell):
|
|
|
|
|
2024-02-13 13:01:41 +00:00
|
|
|
`kill -USR1 $(pgrep -x dd)`
|