Erasing data from disk (dd, hdparm, shred) - How to erase data from disk?

| F.A.Q.

Erasing data from disk (dd, hdparm, shred) - How to erase data from disk?

dd

Deleting MBR, without partition table

dd if=/dev/null of=/dev/sdb bs=446 count=1

Deletion of MBR + partition tables

dd if=/dev/null of=/dev/sdb bs=512 count=1

Save the disk with random data

dd if=/dev/urandom of=/dev/sdb

Resetting disk sectors

dd if=/dev/zero of=/dev/sdb bs=8k

hdparm

Secure disk erase:

hdparm --user-master u --security-set-pass hasło /dev/sda
hdparm --user-master u --security-erase hasło /dev/sda
hdparm --user-master u --security-unlock hasło /dev/sdx
hdparm --user-master u --security-disable p /dev/sdx

security_password=„p”

shred

With the shred command, the contents of the file are blurred, i.e. overwritten by random characters, making the recovery of the contents a very difficult, sometimes impossible task. This command in its simplest form does not delete the file, but only blurs the contents - the file remains on the disk. You can force the deletion of a file (--remove)

Blurring the contents of the file

shred plik

Blur the contents and delete the file

shred -u plik

Blur several times -n (default is 3).

shred -n 20 plik

Related pages:

  1. Linux Tools - dd
  2. Linux tools - Hdparm - (Disk management and bandwidth testing).
  3. Bad sector removal (hdparm) - How to remove bad sectors?