Cleaning up disks in Fedora

OS: Fedora 34

As shown in the lsblk output below, I have 3 NVME SSDs and 4 Mechanical drives attached to my desktop.
My OS (Fedora WS 34) is installed in /dev/sdd which is a 250GB Samsung SSD.

I want to clean up /dev/sda, /dev/sdb, /dev/sdc, /dev/nvme0n1, /dev/nvme1n1, /dev/nvme2n1 drives as if it came out of the factory :slight_smile:
i.e I want to remove partitions, LVM related stuff, filesystems,… everything in these disks. Wipe out everything !
What is the recommended and ‘neat’ way to do this?

[herve@enigma ~]$ lsblk
sda          8:0    0  12.7T  0 disk /u02/herve/S1
sdb          8:16   0  12.7T  0 disk /u02/herve/S2
sdc          8:32   0  12.7T  0 disk /u02/herve/S3
sdd          8:48   0 232.9G  0 disk 
├─sdd1       8:49   0   700M  0 part /boot/efi
├─sdd2       8:50   0   1.5G  0 part /boot
├─sdd3       8:51   0   130G  0 part /home
└─sdd4       8:52   0   100G  0 part /
sde          8:64   0  12.7T  0 disk /u02/herve/S4
sdf          8:80   1  57.6G  0 disk /run/u02/herve/usbtest3
zram0      252:0    0     8G  0 disk [SWAP]
nvme1n1    259:0    0   1.8T  0 disk 
├─vg1-lv10 253:5    0   370G  0 lvm  /u02/herve/F10
├─vg1-lv11 253:6    0   370G  0 lvm  /u02/herve/F11
├─vg1-lv12 253:7    0   370G  0 lvm  /u02/herve/F12
├─vg1-lv1  253:8    0   370G  0 lvm  /u02/herve/F1
└─vg1-lv2  253:9    0   370G  0 lvm  /u02/herve/F2
nvme2n1    259:1    0   1.8T  0 disk 
├─vg1-lv3  253:10   0   370G  0 lvm  /u02/herve/F3
└─vg1-lv4  253:11   0   370G  0 lvm  /u02/herve/F4
nvme0n1    259:2    0   1.8T  0 disk 
├─vg1-lv5  253:0    0   370G  0 lvm  /u02/herve/F5
├─vg1-lv6  253:1    0   370G  0 lvm  /u02/herve/F6
├─vg1-lv7  253:2    0   370G  0 lvm  /u02/herve/F7
├─vg1-lv8  253:3    0   370G  0 lvm  /u02/herve/F8
└─vg1-lv9  253:4    0   370G  0 lvm  /u02/herve/F9

Do you need secure erase? (So that no one can recover any data from your drives)

1 Like

Not very keen on secure erase as it may take long, I guess. Plus, it does not contain sensitive data.
I just to wipe out everything in these disks.

This will remove the partition table of a drive:

dd if=/dev/zero of=/dev/sda bs=512 count=1
wipefs -a /dev/sda


Ok. Thanks Sampson.

If I increase the bs (Bytes) to, say 8192 which is 8kb, that will speed up the cleaning up process. RIght ?

What are the acceptable values for bs clause ? man page only show the following

              read and write up to BYTES bytes at a time (default: 512); overrides ibs and obs

To overwrite the partition, only the first 512bytes are needed to be zeroed.

We do not need to zero out the whole disk.


Oh ok. Thank You Sampson
Which option would you use : dd utility or wipefs ?

1 Like

dd is almost available on all Linux installation.

Sometimes wipefs might not be installed.

There are lots of other batch mode paritioning tools like sgdisk can also be used.

Their end results are the same. Just use the one you are comfortable with.

Please be careful not to have typing mistakes - or your active disk might got erased.

1 Like

no, it lasts some few seconds/minutes only (from my observations)

for hdd’s:

write down or print the relevant commands and how to trick the “frozen state”

get an bootable linux on an usb stick, e.g. sysrecuecd:

for ssd’s/nvme’s:
you’re better off with the vendor tools, they usually have tools to build an “secure erase usb stick”.
secure erase on samsung nvme (ssd) lasts some seconds only

for samsung ssd’s (and nvme’s)

you need an windows box or VM, tough.

cit: “…as if it came out of the factory”:
all the smartctl data survive a secure erase.
secure erase reset’s ssd’s/nvme’s to nearly initial speed (again)

1 Like

I got it wrong, so I moved my/this comment => /dev/null

Yes, we can use smartctl or hdparm to do secure erase, no Disk vendor tools are needed.

anyway, I would prefer vendor tool regarding ssd’s/nvme’s, cause vendor usually (should) know the internals of their devices (better).

And if secure erase really erases all data from ssd’s/nvme’s is -AFAIK- still under discussion.
I guess with vendor tools one is better off, even in an warranty case, if something went wrong.

ATA secure erase is using the onboard logic of the device, not from the host OS.

Unless the vendor tools are using undocumented commands, I guess their effect is the same.

It seems enhanced secure erase is better than secure erase.

1 Like

I want to remove partitions, LVM related stuff, filesystems,… everything in these disks. Wipe out everything

When I need to wipe a disk, I usually use Ultimate Boot CD (UBCD). It is free software and has several HDD wiping utilities.

UBCD has an option to wipe disks. Scroll down on the page and see the tools listed under “HDD/Disk Wiping.” I know one of the tools also wipes SCSI disks that are part of an array.

1 Like