Securely Wiping a HDD/SSD

If you need to remove or upgrade your HDD/SSD you end up being left with a device that has your data on it but it needs to be securely wiped so the usual method is to put a drill though the drive or burn it or put it a magnet over it and that are also lots of other horrible "destroy the data techniques"

This is not really required these days as you have software command that can do a secure wipe, remember that the recovery of a disk is in the ability to read the old data, when you format a disk the files are still there but the "index" gets deleted.

🤖 Linux Secure Erase (HDD)

First you need to identify the disk with this command:

lsblk

That will return all the disks as you can see below and for this example we will use "sda2" as the example:


First the warnings for you all:

‼️ Warning: Data Destruction : These commands will completely erase all data on the drive. Ensure that you have backed up any important data before proceeding.

‼️ Warning : Ensure you have the correct Device:  Double-check the device identifierto avoid wiping the wrong drive.

If you are happy with the warnings above then you have 2 options, if you wish to fill this disk with zero's (0000) then run this command:

sudo dd if=/dev/zero of=/dev/sda2 bs=1M status=progress

However, if you wish to complete the same command for hexadecimal values (which is 0-9 and A-F) then run this:

sudo dd if=/dev/urandom of=/dev/sda2 bs=1M status=progress

Linux Secure Erase (SSD)

SSD use wear levelling, so it is not recommended to fill a SSD with zeros or other values instead use this command instead:

sudo blkdiscard -z /dev/sda2

If you want more this then you can complete a secure wipe on a SSD using this command:

Note : Replace nvme0nX with your NVMe SSD device ID

sudo nvme format /dev/nvme0n1 --ses=1

😳 Paranoid Options

If you are being very paranoid you can run these commands more than one if you really desire, and you can keep running them until you are happy with the results.

🔥 Check the powers of your destruction

If you wish to check your destruction you can view the contents of the drive in hexadecimal depending on the options you will see "zeros" or "random hexadecimal" values.

sudo hexdump -C /dev/sda2 | less

🪟 What about Windows ? 

HDD Drives

Well yes you can do this on Windows as well however this will only write this over the free space not the entire disk, here we have used the logical drive of E: in this example:

cipher /w:E:

You will find there are many data erasers on Windows if you want the whole drive erased.

SSD Drives

This is done with diskpart and for this you want this process:

  1. diskpart
  2. list disks



  3. select disk 2
  4. clean all

Previous Post Next Post

نموذج الاتصال