Smartctl retest bad sectors

hard-disksmartctl

I got a notification today that my drive was going to fail in 24 hours. The 'Reallocated_Sector_Ct' was already around 3000 and it has since risen to over the last few hours 4004. However, I turn my case on its side a few weeks ago, and tried turning it back upright. Since then, the 'Reallocated_Sector_Ct' hasn't risen, even though currently there's a lot of disk activity as I'm tar/zipping my important data to another drive.

I know having a hard disk not being able to read on it's side is a concern, but if placing the hard drive upright seems to fix the issue for the moment, at least I don't have to panic as much.

Is there a way I can run a retest on those "bad sectors", and remark them as good if they pass the test? I'd like to see how many "really" bad sectors there are after a retest with the box upright (of course I'll do this after my backup is complete).

I'm using Debian if that makes any difference.

Best Answer

I can only second the answer from vonbrand. I've seen at least two HDDs die in the past month after going to pre-fail in SMART.

However, your best bet is probably not SMART itself but instead the badblocks utility.

You can let badblocks read and rewrite the whole disk, thereby forcing your HDD to reallocate pending sectors. This usally works quite well.

If you don't have the time for running badblocks (It can take days on bigger disks) you can try to read out the SMART error log (smartctl -x /dev/<hdd> and get a list of broken sectors.

You can then use hdparm to read the sector:

hdparm --read-sector <sector> /dev/<hdd>` 

If that fails you force a remap using

hdparm --yes-i-know-what-i-am-doing --write-sector <sector> /dev/<hdd>` 

This works quite well (at least for WD-Green drives, can't you tell anything about other drives)

If you have dmesg log messages for failed sectors it's even easier.

sectors=$(dmesg | grep <hdd> | grep sector | awk '{print $8}')

for s in $sectors; do <hdparm stuff>; done

Before mounting the volume again do a forced fsck

fsck -f -y /dev/<hdd> 

And assume to have the drive dying on you yesterday!

Good Luck :)

Related Question