Search This Blog

Saturday, July 27, 2019

dd

dd is a command-line utility for Unix and Unix-like operating systems, the primary purpose of which is to convert and copy files.
dd stands for copy and convert (called dd because cc is already in use by C compiler).

[Options]
bs : BYTES read and write up to BYTES bytes at a time (default: 512)
if : FILE read from FILE instead of stdin
of : FILE write to FILE instead of stdout
status : LEVEL The LEVEL of information to print to stderr; 'none' suppresses everything but error messages, 'noxfer' suppresses the final transfer statistics, 'progress' shows periodic transfer statistics

[Examples]
1 - Wipe the disk partition
# dd if=/dev/zero out=/dev/sd<?><n>

2  - Make USB stick bootable
Step 1 : Find device name of USB stick using lsblk
Step 2 : Copy ISO
# dd if=/home/user/download/arch.iso of=/dev/sd<?> status=progress

? = disk name
n = partition number

Reverse of making USB stick bootable
# dd if=/dev/sd<?> of=backup.iso status=progess

Above command can be used to create single image of stick containing all the partitions/data which then can be restored on another machine by simply mounting image using
# mount backup.iso /mnt/pd -o loop