Remove All Partitions and Create Empty Disk

How do I remove all partitions, data and create clean empty hard disk under Linux operating systems?

The simplest command to remove everything from Linux hard drive is as follows. Please note that this will remove all data so be careful:
dd if=/dev/zero of=/dev/hdX  bs=512  count=1
OR for sata disk, use the following syntax:
dd if=/dev/zero of=/dev/sdX  bs=512  count=1
In this example, empty sata disk /dev/sdb, enter (you must be login as the root user):
fdisk /dev/sdb
dd if=/dev/zero of=/dev/sdb  bs=512  count=1
fdisk -l /dev/sdb

Securely Wipe Hard Disk

You can use the shred command to securely remove everything so that no one recover any data:
shred -n 5 -vz /dev/sda

Erase disk permanently under Linux

Step # 1: First, download knoppix Live CD.
Step #2 : Boot from CD.
Step #3: How do I use shred command?
Shred originally designed to delete file securely. It deletes a file securely, first overwriting it to hide its contents. However same can be used to erase hard disk. For example your hard disk name is /dev/sda (SCSI hard disk) then type following command:
# shred -n 5 -vz /dev/sda
Where,
  • -n 5: Overwrite 5 times instead of the default (25 times)
  • -v : Show progress
  • -z : Add a final overwrite with zeros to hide shredding
Command is same for IDE hard disk hda (PC/Windows first hard disk connected to IDE) :
# shred -n 5 -vz /dev/hda
Other options or Live CDs
Darik's Boot and Nuke CD is highly recommended for permanently erasing hard disk
Darik's Boot and Nuke ("DBAN") is a self-contained boot floppy (CD ISO also available) that securely wipes the hard disks of most computers. DBAN will automatically and completely delete the contents of any hard disk that it can detect, which makes it an appropriate utility for bulk or emergency data destruction.

Comments