How To Use DD to Wipe Hard Drive

Helpful to know which device is which

fdisk -l

Will write zeros to sda

dd if=/dev/zero of=/dev/sda bs=1M

Write random numbers to sda

dd if=/dev/urandom of=/dev/sda bs=1M

Wipe the MBR

dd if=/dev/zero of=/dev/sda bs=446 count=1

or just add the partition number to sda to wipe certain partitions

Creates an ISO disk image from a CD-ROM; in some cases the created ISO image may not be the same as the one which was used to burn the CD-ROM

dd if=/dev/sr0 of=myCD.iso bs=2048 conv=noerror,sync

Clones one partition to another partition

dd if=/dev/sda2 of=/dev/sdb2 bs=4096 conv=noerror

Clones a hard disk “ad0” to “ad1”

dd if=/dev/ad0 of=/dev/ad1 bs=1M conv=noerror

create an image of the entire x86 master boot record (including a MS-DOS partition table and MBR magic bytes):

dd if=/dev/sda of=MBR.img bs=512 count=1

create an image of only the boot code of the master boot record (without the partition table and without the magic bytes required for booting):

dd if=/dev/sda of=MBR_boot.img bs=446 count=1

modify data in place. For example, this overwrites the first 512 bytes of a file with null bytes:

dd if=/dev/zero of=path/to/file bs=512 count=1 conv=notrunc

duplicate a disk partition as a disk image file on a different partition:

dd if=/dev/sdb2 of=partition.image bs=4096 conv=noerror

You may also like...