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.
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.
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:
Thanks, I didn’t know this command. In fact I’ve just discovered blkdeactivate, blkdiscard, blkid, blkmapd, blkpr, blkzone commands with your message…
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.
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.)