Linux Administrator

How to Wipe Hard Drive Clean Using dd Command in Linux

Written by Santosh Prasad

If you want to wipe your hard drive to clean up partition error, bad installations, or for privacy. This tutorial will help you how to do this.

In this article I will show how to wipe hard drive clean using dd command in Linux.

Wipe Entire Disk

This will overwrite all partitions, master boot records, and data. Use the sudo command as well (sudo dd…).

1. Filling the disk with all zeros (This may take a while, as it is making every bit of data 0) :

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

Replace X with the target drive letter.

2. If you are wiping your hard drive for security, you should populate it with random data rather than zeros (This is going to take even longer than the first example.) :

dd if=/dev/urandom of=/dev/sdX bs=1M *replace X with the target drive letter.

Replace X with the target drive letter.

You need to replace sda with the device name you want to overwrite. sda is usually the first hard drive, the second drive would be sdb and so on. Use for example gparted to find the correct drive. If you replace the device name, you can also wipe USB sticks and other peripherals.

Wipe Master Boot Record (MBR)

If you messed up your master boot record (MBR) you can wipe it using this command :

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

Replace X with the target drive letter.

Wipe Partitions

You can wipe a partition using the same method than for the whole disk. Just replace the device identifier. If /dev/sda is the whole disk, then (on Linux, because the naming scheme vary from one Linux to another) /dev/sda3 is the third partition on the disk.

1. Filling the second partition on the /dev/sda disk with all zeros :

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

Replace X with the target drive letter.

2. Filling the third partition with random data :

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

Replace X with the target drive letter.

Thank you! for visiting Look Linux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author


Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment