Linux

Shred: Completely erase a hard disk

Shred is a command-line tool that allows you to completely erase a hard disk by folding the disk zones by values of 0. It’s strongly recommend that you use this tool before selling your PC, to make data recovery difficult (photos, documents, videos, etc.).

In this guide I’ll show you how to install on RHEL/CentOS and use shred commands to erase your hard disk.

Display your disk :

Let’s start by displaying your current disks and selecting the one you want to delete :

[root@srv ~]# fdisk -l

Disque /dev/sda : 17.2 Go, 17179869184 octets, 33554432 secteurs
Unités = secteur de 1 × 512 = 512 octets
Taille de secteur (logique / physique) : 512 octets / 512 octets
taille d'E/S (minimale / optimale) : 512 octets / 512 octets
Type d'étiquette de disque : dos
Identifiant de disque : 0x000cde7c

Périphérique Amorçage Début Fin Blocs Id. Système
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 33554431 15727616 8e Linux LVM

Disque /dev/sdb : 20 Go, 17179869184 octets, 45556598 secteurs
Unités = secteur de 1 × 512 = 512 octets
Taille de secteur (logique / physique) : 512 octets / 512 octets
taille d'E/S (minimale / optimale) : 512 octets / 512 octets
Type d'étiquette de disque : dos
Identifiant de disque : 0x000ece7d

Périphérique Amorçage Début Fin Blocs Id. Système
/dev/sdb1 * 2048 2099199 1048576 83 Linux
/dev/sdb2 2099200 33554431 15727616 83 Linux

In my case, I have two disks (sda and sdb) and I want to delete the sdb disk.

Deleting a hard disk with shred:

To use shred you need to install the coreutils package with dnf :

[root@srv ~]# dnf install coreutils

Now let’s erase our sdb disk with the shred command :

[root@srv ~]# shred -z -v /dev/sdb

-z: add a final rewrite with zeros to disguise file shredding.

By default, the command performs the operation 3 times, but you can specify the desired number of operations with the -n option :

[root@srv ~]# shred -z -v -n 20 /dev/sdb

And Now you can sell you PC and no one can recover your d

You might also like

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *