Linux Tools - dd
| F.A.Q.dd (short for "data description") is a Unix tool for low-level copying and conversion of raw data. It is used to copy a specified number of bytes or data blocks, along with optional data conversion (e.g., byte order change, EBCDIC to ASCII conversion). DD is commonly used for creating copies of disk boot sectors, reading data from special files like /dev/zero or /dev/random, and working with block devices such as magnetic tapes.
Example Command:
Creating an ISO image of a partition while simultaneously compressing it:
dd if=/dev/sdb2 | gzip > /home/user/image_sdb2.gz
Where:
- if=source means the source of the data to be copied.
- gzip lossless data compression tool
- > copy storage path
Throughput Test
- Throughput Test 1GB
dd if=/dev/zero of=/dev/sdX bs=1G count=1 oflag=direct
- Throughput Test 1GB (zapis)
dd if=/dev/zero of=./largefile bs=1M count=1024
- Cleaning the cache
sh -c "sync && echo 3 > /proc/sys/vm/drop_caches"
- Throughput test 1GB (odczyt)
dd if=./largefile of=/dev/null bs=4k
dd Progress Bar
- Copying with progress bar:
pkill -USR1 dd
watch -n 10 pkill -USR1 dd
- Copying with PV progress bar:
pv /dev/urandom | dd of=file.img bs=4KB count=1234
dd if=/dev/urandom | pv | dd of=/dev/null
Save data with skip errors
- Writing data with skipping errors and adding 0 to blank spaces:
dd bs=4k if=/dev/sdb1 of=/home/user/image.iso conv=noerror,sync
- Image Mounting:
mount -o loop disk1.iso /mnt/disk
Related Pages: