Securely Erase Data from a Drive Using ‘shred’ on Linux: A Step-by-Step Guide

Chinmay Roy
2 min readJul 29, 2023

--

To erase all data from a drive, you can use a disk wiping tool that is specifically designed for secure data deletion. One such tool is “shred,” which comes pre-installed on many Linux distributions. “shred” overwrites the data on the drive multiple times, making it extremely difficult for anyone to recover the original data. Here’s how you can use “shred” to erase all data from a drive:

Important Note: Before proceeding, ensure you have selected the correct drive to be erased. Data erased using this method will be unrecoverable. Double-check the drive name to avoid accidental data loss.

  1. Identify the Drive: Use the lsblk or fdisk -l command to list all available drives and their partitions.
lsblk
  1. Unmount the Drive: Ensure that the drive is unmounted before proceeding with the erasing process. If it’s currently mounted, unmount it using:
sudo umount /dev/sdX

Replace sdX with the appropriate drive identifier (e.g., /dev/sda, /dev/sdb, etc.).

  1. Erase the Drive with “shred”: Now, use the shred command to erase all data on the drive:
sudo shred -vzn 0 /dev/sdX

Replace sdX with the correct drive identifier (e.g., /dev/sda, /dev/sdb, etc.).

The options used with shred are as follows:

  • -v: Verbose mode. It will display progress.
  • -z: Add a final overwrite with zeros to hide shredding.
  • -n 0: Perform zero passes, meaning it will overwrite the data with zeros.

This command will overwrite the entire drive with zeros, making it extremely difficult for anyone to recover the original data.

  1. Wait for Completion: The process may take some time, depending on the size of the drive. Once the shred command finishes executing, the drive will be completely wiped.

Please be patient and allow the process to complete. Afterward, the entire drive will be filled with zeros, making it challenging to recover any previous data. The drive will essentially be “erased” in a secure manner.

--

--