12 Linux dd, ddrescue and dcfldd command examples

Posted by linuxnix on Mar 9, 2016 12:01 PM EDT
www.linuxnix.com; By Imran Ashraf
Mail this story
Print this story

The dd command stands for “data duplicator” and used for copying and converting data. It is very powerful low level utility of Linux which can do much more like ...

• Backup and restore the entire hard disk or partition.

• Backup of MBR (Master Boot Record)

• It can copy and convert magnetic tape format, convert between ASCII and EBCDIC formats, swap bytes and can also convert lower case to upper case.

• It can also be used by Linux kernel make files to make boot images.

Only superuser can run this command because you can face a big data loss due to its improper usage, so you should be very careful while working with this utility. At that moment data loss can convert the dd utility as a “data destroyer” for you. That’s why it is recommended that beginners should not use this command on a production machine until they get familiarity on this. You must make sure that target location must have sufficient space while running this command.

Syntax of dd command

Before we start with some practical work we need to talk about its syntax.

dd if=<source file name> of=<target file name> [Options]

We normally do not explain about syntax but this command syntax require some explanation. The syntax is totally different when compared to many Linux commands we know. In this syntax dd is followed by two things

if=<source>

–This is a source from where you want to copy data and ‘if’ stands for input-file.

of=<destination>

–This is a source from where you want to write/paste data and ‘of’ stands for output-file.

[options] –These options include, how fast data should be written, what format etc.

Input(source file name) and Output(target file name) in syntax are disks, partitions, files and devices to which you want to write and read data from. There are many options which we will discuss in examples.

Learn Linux dd command with examples

Example 1: Clone one hard disk to another hard disk. This is useful when we are building many machines with same configuration. We no need to install OS on all the machines. Just install OS and required software on machine then clone with below example.

dd if=/dev/sda of=/dev/sdb

Example 2: We can take backup of a partition/complete HDD for future restoration.

Backing up a partition to a file (to my home directory as hdadisk.img)

dd if =/dev/sda2 of=~/hdadisk.img

Restoring this image file in to other machine

dd if=hdadisk.img of=/dev/sdb3

Example 3: Do you feel hdadisk.img is bit big? Use gzip or bzip2 to compress when creating image.

...

Full Story

  Nav
» Read more about: Story Type: Tutorial; Groups: Linux

« Return to the newswire homepage

This topic does not have any threads posted yet!

You cannot post until you login.