Tips Linux Explorers   All Things Linux Forum   Great Linux Links   Hometown   Email 


This is one of the more complex Linux commands and actually not really suited for new Linux users. But still I would like to give you a little taste of it.

The dd command copies an amount of data block by block. The most basic syntax is:

# dd if=xxxxx of=yyyyy bs=zzzzzz

( Where if=xxxxx is the source, of=yyyyy is the target and bs= both read and write zzzzz bytes at a time )
But as you might have guessed, the dd command it is much more than that, it can optionally convert data ( ASCII to EBCDIC ), skip blocks, continue after read errors, change uppercase letters to lowercase, etc, etc. ( type "info dd" in a terminal to get the full list of options )

I will now give you a few examples of what dd can do, but I do urge you to have a look at the links posted below to get more detailed information before you really start experimenting with the dd command.

Copy a hard disk partition to another hard disk:

# dd if=/dev/hda2 of=/dev/hdb2 bs=4096 conv=notrunc,noerror

Cloning an entire hard disk:

# dd if=/dev/hda of=/dev/hdb conv=notrunc,noerror

Copy a disk partition to a file on a different partition. ( Do not copy a partition to the same partition ! ):

# dd if=/dev/hdb2 of=/home/bruno/partition.image bs=4096 conv=notrunc,noerror

Restore a disk partition from an image file:

# dd if=/home/bruno/partition.image of=/dev/hdb2 bs=4096 conv=notrunc,noerror

Copy MBR only of a hard drive:

# dd if=/dev/hda of=/home/bruno/MBR.image bs=446 count=1


# dd if=/home/bruno/MBR.image of=/dev/hda bs=446 count=1

Wipe a hard drive of all data ( you would want to boot from a cd to do this ):

# dd if=/dev/zero of=/dev/hda conv=notrunc

Make an iso image of a CD:

# dd if=/dev/hdc of=/home/bruno/TEST.iso bs=2048 conv=notrunc

( CD sectors are 2048 bytes, so this copies sector for sector. )

Copy a floppy disk:

# dd if=/dev/fd0 of=/home/bruno/floppy.image conv=notrunc

You can back up your MBR ( including partition table ):

# dd if=/dev/hda of=mbr.bin count=1

Put this on a floppy you make with:

# dd if=boot.img of=/dev/fd0

Boot from the floppy and restore the MBR:

# dd if=mbr.bin of=/dev/hda count=1

Again, I urge you to be very careful with the DD command . . . switching if= with of= can have catastrophic results.

An extensive how-to of the dd command can be found here: Learn The DD Command   Please read it before you start typing "dd" !!
Maybe also read: Codecoffee


-- Apr 22 2007 --

Tips Linux Explorers   All Things Linux Forum   Great Linux Links   Hometown   Email