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.
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
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
Note : Replace nvme0nX with your NVMe SSD device ID
sudo nvme format /dev/nvme0n1 --ses=1
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:
- diskpart
- list disks
- select disk 2
- clean all