Can a disk be made to identify specific pending sectors

hard-diskraidsatasmart

smartd will happily log messages like this:

Sep  2 12:33:59 Watt smartd[438]: Device: /dev/sda, 2 Offline uncorrectable sectors
Sep  2 12:34:01 Watt smartd[438]: Device: /dev/sdc, 16 Currently unreadable (pending) sectors
Sep  2 12:34:01 Watt smartd[438]: Device: /dev/sdc, 16 Offline uncorrectable sectors

These are all used for mdraid arrays, so it's easily fixable by having mdraid scrub the array. But that takes a good long while (and hurts performance while its going). It'd be much quicker to selectively scrub only the parts that need it.

Is there some way to get the list of pending sectors from the disk? I didn't see anything in smartctl -x, but here is sda and sdc in case it helps. (And yes, sdc is destined for replacement soon.) If I could get a list of sectors, I could feed that to mdraid to scrub only those portions.

These are all SATA disks. The machine is running Debian testing/unstable, if it matters. But I'd love to solve this on machines running Debian stable and oldstable as well.

Best Answer

I think this should be provided by the defects log, if it is supported:

smartctl -l defects /dev/sdX

However, I'm unable to confirm, because the message I get from my drive is Pending Defects log (GP Log 0x0c) not supported. From the smartctl man page:

defects[,NUM] - [ATA only] prints LBA and hours values from the ATA Pending Defects log (General Purpose Log address 0x0c). Only the 31 entries from first log page are printed by default. This number can be changed by the optional parameter NUM. The size of the log and the order of the entries are vendor specific. The Pending Defects log was introduced in ACS-4 Revision 01 (Mar 2014).

Alternative

If the defects log is unsupported on your drive, you may find that a short self-test will check the pending sector and immediately abort with a read error, giving you the LBA in the process:

smartctl -t short /dev/sdX

# then wait ~ 1 minute for the test to complete, and check the log:

smartctl -l selftest /dev/sdX

Then you can follow the steps from the smartmontools Docs to deal with the bad sector/block.