DD Commands

From INIwiki
Jump to: navigation, search

Digg this!

Contents

[edit] Use DD to copy data

Create ISO from CD

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

or

dd if=/dev/sr0 of=/dvd.iso

Raw dump... like from a CF to RAW File

From CF to HD
dd if=/dev/sda of=/tmp/image.raw

From HD to CF

dd if=/tmp/image.raw of=/dev/sda

[edit] Disk with Errors

dd a disk with errors

  • NOTE: If dumping to a file system make sure that the chosen directory (some_dir) has enough room to take the entire disk image

To find block size use

dumpe2fs /dev/sdX# | grep -i 'Block size'

Now run the dump command

  • NOTE: The bs=512 designates block size, and the if=/dev/rXX# is the UNIX path to the actual disk device.
dd bs=512 if=/dev/sdX# of=/some_dir/foo.dmg conv=noerror,sync

Dump to other attached disk

dd bs=1024 if=/dev/sda of=/dev/sdb conv=noerror,sync


Compress your dd img

dd bs=512 if=/dev/rXX# conv=noerror,sync | gzip -9 > foo.dmg.gz
  • NOTE: gzip -d can be used to uncompress

Sometimes it is possible to restore a corrupt file

dd bs=512 if=/Volumes/HD1/badfile.mpg of=/Volumes/HD2/newrecoveredfile.mpg conv=noerror,sync

[edit] Have dd report its status

you can use kill -USR1 dd_pidid# from another terminal to get dd to spit out its progress.

This could be useful for the long running dd process.

kill -USR1 dd_pidid#

*Note- To find the pid id use

ps -ax |grep dd

Look for the line running you dd command then find the id

[edit] Destroy Data

**caution- this is non-reversible** Use dd to destroy hard drive data

  • NOTE: find your hard drive (fdisk -l)
for i in 1 2; do
dd if=/dev/urandom of=/dev/hda1
done && dd if=/dev/zero of=/dev/hda1
echo "wait for a long time ..."
  • NOTE: Increase the iteration to decrease the chances of data recovery and wait for a very long time.

[edit] Destroy Data with SDD

**caution- this is non-reversible** Use sdd to destroy hard drive data Install sdd

apt-get install sdd
or 
http://public.planetmirror.com/pub/fokus-unix/sdd/

Run the command

  • NOTE: find your hard drive (fdisk -l)
for i in 1 2; do
dd -bs=1024 -noerror -pg if=/dev/urandom of=/dev/hda1
done && dd -bs=1024 -noerror -pg if=/dev/zero of=/dev/hda1

NOTES:

-bs=1024 (set block size to 1024) help increase transfer speed
-noerror  (continue when errors are encountered)
-pg  Prints to stdout a "." to represent status

wait for a long time ...
  • NOTE: Increase the iteration to decrease the chances of data recovery and wait for a very long time.


Disclaimer: I'm not responsible for the damage you cause to property belonging to yourself or anyone else with this information.

Digg this!

Personal tools