How to run dd-command on Linux?- Part-I

dd stands for "Data Descriptor".It is a low-level copying and conversion of raw data. It is an application that will "convert and copy a file".  DD is used to copy a specified number of bytes or blocks, performing byte-order conversions.

Lets start with the basic understanding of dd-command with examples.


In the above syntax, source is the data being read, target is where the data gets written. if stands for input file and of for output file.
bs stands for blocksize.It is important to know the concept of blocksize.

Typically, a hard disk cannot read less than 512 bytes, if you want to read less, read 512 bytes and discard the rest. This is why dd reads one block à 512 bytes in the following example:

Every filesystem needs to split up a patition into blocks to store files and file parts. This is why there is a different block size for a file system as you can see here:

So, if you store a file in this file system, it will be stored in a 4096-byte-block, that means, even if your file only contains 5 bytes, it will take away 4096 bytes from your disk's capacity: 

Lets start with few basic examples before we dive deep into the ocean of dd-command.


Say we have a harddisk /dev/sda that we want to backup entirely (sector-by-sector) to a USB volume /dev/sdc1, mounted on /mnt/sdc1. We call this a dump or an image of /dev/sda. The dump shall be named backup.img. Here is the dd command:



To restore this backup, we boot from a live CD and do the command vice versa.



To clone a disk C to D, both disks need to have the same capacity. It is very convenient for USB disks. Say our USB disk source is called /dev/sdc and the target is called /dev/sdd.


To transfer a disk image over the network to a computer named recipient, use this command



To create an iso image of a CD, read it block-by-block and save the blocks to a file:

dd if=/dev/cdrom of=cdimage.iso


If your movie is no longer working due to corrupted file, you can use dd to ignore the corrupt part:


There are further several examples of dd-command which we will cover in the next part. Till then, play safe with dd.

No comments:

Post a Comment