dnf install smartmontools hdparm sysstat testdisk
Connect drive on SATA/SCSI directly (do not use USB adapters).
smartctl -a /dev/sdX
We disable standby, acoustics and APM. Then we enable fast error recovery (7 sec; only Enterprise and NAS drives support this).
hdparm -S 0 -M 254 -B 255 /dev/sdy
smartctl -l scterc,70,70 /dev/sdx
fdisk -xu /dev/sdx > part_sdx.log
ddrescue -f -n /dev/sdx /dev/sdy rescue_sdx.map
We disable fast error recovery to try to read as much of the data as possible.
smartctl -l scterc,0,0 /dev/sdx
ddrescue -f -d r3 -W /dev/sdx /dev/sdy rescue_sdx.map
We leave it try some more.
ddrescue -f -d r100 -W /dev/sdx /dev/sdy rescue_sdx.map
If data is important, then manually test with -i.
- Check capability for sanitize
hdparm --sanitize-status /dev/sdx && hdparm -I /dev/sdX
- If disk supports it (Enterprise), then
hdparm --sanitize-crypto-scramble /dev/sdX
. Go to step 9. - Otherwise, if SSD, then
hdparm --sanitize-block-erase /dev/sdX
- Otherwise, if HDD, then
hdparm --sanitize-overwrite --sanitize-overwrite-passes 1 hex:DEADBEEF /dev/sdX
- If santize is not supported at all, then unlock the drive (if frozen only; suspend computer or enable Hotplug in BIOS and remove ATA cable).
- Enter high security mode
hdparm --user-master u --security-set-pass YOURPASS /dev/sdX
- If drive supports it, use enhanced security erase
hdparm --user-master u --security-erase-enhanced YOURPASS /dev/sdX
- Otherwise, use normal security erase
hdparm --user-master u --security-erase YOURPASS /dev/sdX
- For HDD,
cryptsetup -c aes-xts-plain64 open /dev/sdX --type plain -d /dev/urandom --sector-size=4096 to_be_wiped
. Otherwise go to 12. - Run wipe
dd if=/dev/zero of=/dev/mapper/to_be_wiped status=progress bs=1M conv=sync,noerror oflag=direct
. - Finish up
cryptsetup close to_be_wiped
. - For SSD,
blkdiscard /dev/sdX
.
smartctl -a /dev/sdX
Pending sector count increase/decrease. Relocated sector count increase/decrease. Offline irrecoverable errors increase/decrease.