Uses of DD command[Linux]

Linux provides a DD command which is the powerful UNIX utility. It makes use of Linux kernel makefiles to make boot images. DD can be used to copy data from one device to another or from one location to another. Administrator is the only person having rights to execute DD command. You can use the below DD command in Linux operating system which will help you in various ways.

The uses of DD command are as follows:

1. If you want to take the backup data from one hard disk to another hard disk within the same system. The command is given below:

Code:
# dd if=/dev/sda of=/dev/sdb

In this “if” specifies input file name and “of” specifies the file where the data has to be copied. If you mention source device in target device and vice versa then you might loss all your data.
If you want to restore the hard disk with the image file of another hard disk then use the following command:

Code:
# dd if=hdadisk.img of=/dev/hdb

To copy the data from the floppy into the image format you need to type the following command:

Code:
# dd if=/dev/fd0 of=myfloppy.img


In the input file specify the name of floppy location and in output give the name of floppy image file.
Type the below command to read data from one location and write it to another location. The command is given below:

Code:
dd if=<source> of=<target> bs=<byte size> ("USUALLY" some power of 2, and usually not less than 512 bytes (ie, 512, 1024, 2048, 4096, 8192, 16384, but can be any reasonable whole integer value.) skip= seek= conv=<conversion>

If you want to remove CD, DVD or USB from the system then type the below command. This command will rescue it from the system.

Code:
ddrescue -b 2048 -d -e 20 -r 300 -v /dev/hdc /home/sam/dvd.iso log.txt

You can backup a partition. For taking the backup you need to specify the partition name in input file and then specify the path or image file where you want to take backup. The dd command for taking backup is given below:

Code:
# dd if=/dev/hda1 of=~/partition1.img

You can create an iso file from the source file. So we can enter the CD or DVD and create an iso file from the data contained in them. The dd command for creating iso is given below:

Code:
# dd if=/dev/cdrom of=tgsservice.iso bs=2048

Thus dd command reads one block at time, executes it and writes to the targeted output file.
 
Back
Top