Erase/format all

I’ve got an old machine running manjaro xfce, I want to completely reset it. I want to erase and delete everything on it, format the partitions - whatever is possible, as I’ll be selling it.

What’s the best way or software to do this?

Thanks in advance!

Write over the whole disk to make sure no data is recoverable.
Do low-level format.
Use the shred command.

Do I need to run shred from a live USB, or I can run it by just normally being on the system?

from the outside, since you will be writing to the very disk the system is on you can’t use the system itself

How to Securely Erase a Disk and File using the Linux shred Command

I’d opt for a fresh installation, encrypt the whole disk and set an easy password, so that the potential buyer has got a working and usable system, can see that everything works.

To be sure you can fill up the (now encrypted) disk with random data, for example:
sudo su
cat /dev/urandom > ~/fillerfile
or even just:
cat /dev/zero > ~/fillerfile
the command will run until the disk is full, then you can remove the file …

If the disk is not a spinning disk, the process is a different one.

1 Like

I would use

sudo dd if=/dev/urandom of=/dev/{here enter the right block device name} bs=1M status=progress

It will fill the whole disk with random data. If you want to make it more safe, add afterwards:

sudo dd if=/dev/zero of=/dev/{here enter the right block device name} bs=1M status=progress

“Normal users” won’t be able to get access to previously stored data in this case.

If you need a more thorough erase, as always have a look into Arch wiki:

https://wiki.archlinux.org/title/Solid_state_drive/Memory_cell_clearing

1 Like

If you want to erase a HDD, fill the disk with DD or use DBAN (free):

SSDs are different, they reserve some space (overprovisioning) that may have data and it’s not erased if you overwrite the full disk. And have a “wear levelling” system that you aren’t sure if it’s overwriting what you want or where he wants to avoid SSD wearing.

So the best way is not erasing but resetting all the cells using the manufacturers own application, or Parted Magic (paid software) or even Windows Diskpart. It’s far better explained here:

man blkdiscard

:wink:

3 Likes

Thanks, I didn’t know this command. In fact I’ve just discovered blkdeactivate, blkdiscard, blkid, blkmapd, blkpr, blkzone commands with your message… :grinning:

There should be a “Big index of Linux commands” somewhere… when I see the number of files in /usr/bin and /usr/sbin I realize that I would need two lifetimes to know them all. :smile:

1 Like

So is it an HDD or SSD? Assuming NVMe SSD…

Recovering deleted and TRIM’d blocks, I’d like to think this is still next to impossible to do, even for a really tech savvy user. (It requires access to very expensive hardware to read past states of NVMe chips, let alone the logic just to get to that point.) So if you do not care about this, it is much easier.

@Aragorn brought up the perfect command for NVMe drives for this: blkdiscard. Partitions, filesystems, and all: Delete everything and TRIM. There is even a -s, --secure option, if the drive supports it. Just run that anytime before (or right at the start of) the new install.

(I’ve been using dd if=/dev/zero | if=/dev/urandom on HDDs for over 3 decades, It’s nice not having to wait up to 2 days.)

2 Likes