u know that old ssd sitting around? wanna know if its healthy before using it?
today were gonna do the full check-up and then the full reset on it using the fedora terminal!
checking health with smartmontools
first, lets see if the ssd is healthy or dying...
we use a program called smartmontools:
sudo dnf install smartmontools
now u need to know the "name" of ur disk. run lsblk to see. mine was /dev/sda.
with the name, run the health test:
sudo smartctl -a /dev/sda
what to look for in the result? the most important line is this one:
SMART overall-health self-assessment test result: PASSED
its also good to check Reallocated_Sector_Ct (ID 5). if the RAW_VALUE is 0 (zero), its perfect!
cleaning the ssd with blkdiscard
ok, my ssd was PASSED.
but it was an extra disk (my fedora was on another one) and i wanted to erase everything and leave it clean.
the command below will erase everything on the disk. no going back. no undo. make sure its the right disk! (in my case, /dev/sda)
sudo blkdiscard /dev/sda
if it works, it says something like:
/dev/sda: Discarded 512110190592 bytes from the offset 0
all clean.
"but did it really erase? can it be recovered?"
and the answer is: no, it cant be recovered.
blkdiscard uses trim. its different from formatting an old hdd.
- it doesnt write zeros over the data, like secure formatting an hdd does.
- it talks directly to the controller (the ssd boss): "hey, u can throw away the 'map' that leads to this data. i dont need it anymore."
the physical data (the electrons) might stay in the chip for a bit, but the controller wont let anyone read it! if any program tries to read, the controller just returns zero.
so for us, the data disappeared 100% the second blkdiscard ran.
formatting
now the ssd is clean, but it has no "drawers" (partitions) to store stuff.
creating the partition (fdisk)
to create the partition, we use fdisk:
sudo fdisk /dev/sda
inside fdisk, u just need to press keys and hit enter (in order):
g(to make a new gpt table)n(for a new partition)enter(to accept the partition number)enter(to accept the first sector)enter(to accept the last sector, using the whole disk)w(to save and exit)
formatting the partition (mkfs.ext4)
lets use ext4 which is perfect for linux, its the standard and super stable.
now we use sda1 (the partition), not sda (the disk) anymore!
sudo mkfs.ext4 /dev/sda1
done!