Bad Block Howto
Your hard disk fails on Linux - now what?
I happened to me a few times in the last few weeks. A filesystem check for a hard disk would take for ever - my system won't boot. One of the harddisks was reporting errors. At this time i have four different hard disks that are giving me this kind of trouble. All broken harddisks have been taken out of the system and I am analyzing the problem using a virtual machine and a USB-SATA bridge.
First step: remove harddisk from system and put into SATA USB docking station
Hopefully your disk is not needed to boot or fully operate your system. In that case you might want to boot of a USB stick or other media. In any case my procedure is to remove the disk from the original system and use a different system for analysis. In my case i am using an Ubuntu based virtual machine and connect the drive via a USB-SATA bridge. With USB 2 devices the performance is poor. I am not using my old Logilink QP002 Sata Docking Station anymore for this reason.
The USB 3 device i bought in 2015: still serves me well.
Second step - check problems
Tools needed
- A Linux virtual machine
- smartctl
- hdparam
- debugfs
Links
- https://www.smartmontools.org/wiki/BadBlockHowto
- https://github.com/hradec/fix_smart_last_bad_sector
- http://dcere.com/hardware/2016/09/18/hard-disk.html
- https://serverfault.com/questions/461203/how-to-use-hdparm-to-fix-a-pending-sector
- https://serverfault.com/a/641135/162693
- https://linux.die.net/man/8/smartctl