Compdigitec Labs

« | Home | »

How to use dd to copy, move and erase disks

By admin | August 14, 2008

Often, you may encounter the need to move a partition, copy a partition or copy a CD/DVD. The easiest and most user-friendly way to do this is with GParted. However, in a server environment or a command line environment where the GUI is not available, GNU dd is an good way to perform these simple tasks. Here are easy tips on how to use dd for disk manipulation. Most of these commands require you to be part of the “disk” group.

If you are on the Windows platform, you will need a copy of rawwrite dd for Windows in your %PATH%. To list the disks with rawwrite dd, use dd –list and use the devices listed there; for example, use “\\?\Device\HarddiskVolume1” instead of “/dev/sda1”. For CD drives, replace /dev/cdrom with “\\?\Device\CdRom0”.

  1. dd if=/dev/partition of=/dev/destination – Copy the partition partition to the partition destination.
  2. dd if=/dev/cdrom of=filename.iso – Make an ISO image of the disc in your CD drive as filename.iso. Then you can use in Virtual Machines such as VMWare, mount it in Windows with DaemonTools or mount it as an file system in Linux.
  3. dd something bs=speed – Performs the action something at the speed of speed bytes per second. Can be used to copy CDs and disks faster.
  4. dd if=/dev/zero of=/dev/pdest – Wipes the filesystem from the partition pdest, which can you can then make a new filesystem with mkfs.ext3 /dev/pdest.
  5. dd if=/dev/part of=filename.disk – Makes a intact backup of everything on the partition part into the file filename.disk.
  6. dd if=filename.disk of=/dev/part – Copies from intact backup filename.disk into the partition part. Make sure that the partition part is big enough to hold filename.disk.
  7. dd if=/dev/cdrom of=/dev/part bs=10M – Copies the CD filesystem on your CD to the partition part.
  8. dd if=/dev/fd0 of=filename.img – Copies the floppy in your floppy drive to filename.img. Then the image can be used in Virtual Machines.
  9. dd if=filename.img of=/dev/fd0 – Copies the image filename.img to the floppy in your floppy drive.
  10. dd if=/dev/disk of=bootsect.bin bs=512 count=1 – Copies the boot sector of disk disk to the file bootsect.bin.
  11. dd if=/dev/disk of=/dev/null – The best way to waste your CPU power; copies disk to NULL.

So as you can see, dd is a very useful tool to manipulate partitions and images. If you found this article interesting or helpful, please help us spread the word or please leave a comment!

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: Linux, Windows | 3 Comments »

3 Responses to “How to use dd to copy, move and erase disks”

  1. David Rankin Says:
    May 16th, 2009 at 04:06

    Umm,

    bs doesn’t have anything to do with ‘byte speed’, it is simply ‘bytes’:

    bs=BYTES
    read and write BYTES bytes at a time (also see ibs=,obs=)

  2. Animal X Says:
    August 18th, 2009 at 04:36

    Thank you. I found this page very useful, including the comment by Mr. Rankin.

  3. สีทนไฟ Says:
    April 18th, 2024 at 19:14

    … [Trackback]

    […] Info to that Topic: compdigitec.com/labs/2008/08/14/how-to-use-dd-to-copy-move-and-erase-disks/ […]

Comments