Write random bytes to disk using shred
Sometimes you need to wipe out the entire disk with random bytes. This could be
due to metadata used by your filesystem such as zfs where formatting or wiping
the parition table and disk may not be enough. We can use shred to securely delete a file or disk.
- First get the disk name using
lsblkorfdisk -l. - Then use
shredto write random bytes to the disk.
shred -v -n 1 --random-source=/dev/urandom /dev/sdX
-venables verbose mode displyaing the progress.-n 1specifies the number of passes to write random bytes.--random-source=/dev/urandomspecifies the source of random bytes./dev/sdXis the disk name.
To securely delete a file use filename instead of the disk name.
shred -v -n 10 --random-source=/dev/urandom filename.txt