Definition: dd stand for copy and convert, it's a utility of Unix and Unix-like operating system that used for convert or copying files and folder.
Function: Copy a file, converting and formatting according to the operands
dd syntax:
dd [if=FILE] [of=FILE] [ibs=N] [obs=N] [bs=N] [count=N] [skip=N] [seek=N] [conv=notrunc|noerror|sync|fsync]
if= input file
of= output file
sync=copy everything
conv=noerror : continue to copy if there are read errors
help ! you can type command :
dd --help
Example 1:
Backup one disk to another :
We have 2 disks ( sdb & sdc) & we want a full backup of disk 2 ( sdb ) to disk 3 ( sdc ) so a command is :
dd if=/dev/sda of=/dev/sdb conv=noerror, sync
Example 2:
Create bootable media, in this example we creating centos 7 bootable Pendrive
dd if=/tmp/CentOS-7-x86_64-Minimal-1511.iso of=/dev/sdb bs=1M oflag=sync
bs=1M: read and write up in BYTES bytes at a time
oflag=FLAGS : write as per the comma separated symbol list
Example 3:
Clone Disk / Create disk image
dd if=fulldiskclone.img of=/dev/sdb1 bs=2048
Restore Disk/Image
dd of=/dev/sdb1 of=fulldiskclone.img bs=2048
Example 4:
write zeros in disk / partition
dd if=/dev/zero of=/dev/sdb1 status=progress
Example 5:
Generate 100MB file
dd if=/dev/urandom of=/tmp/file.txt bs=1024K count=100