Some Bits: Nelson's log

Diagnosing a failing Linux disk

My datacenter server failed, bad power supply, and when it came back it’s sort of working but is very very slow. I poked around and got the impression the problem is a failing disk. How to be sure? These notes are for a spinning SATA disk, not an SSD.

iostat

The main thing I noticed is everything writing to disk was taking a long time (ie many seconds instead of 100ms). Also a lot of processes in device wait. Here’s how I quantified the problem

# iostat -d 1 --human -xs /dev/sda
Device             tps      kB/s    rqm/s   await  areq-sz  aqu-sz  %util
sda               7.94    415.3k     8.93  380.72    52.3k    3.01  90.8%

sda             111.00    444.0k     0.00    7.36     4.0k    0.80  83.2%
sda              31.00    660.0k   134.00   55.77    21.3k    1.70 127.6%
sda             240.00      1.1M    30.00    4.31     4.5k    0.99  87.6%
sda              13.00     96.0k    12.00  189.85     7.4k    2.45 102.8%
sda               9.00     44.0k    55.00  340.44     4.9k    3.04  97.6%

Note with iostat -d 1 the very first row is since system start, then it’s a continuous report for the last second. The alarming thing here is the “await” column. That’s milliseconds waiting for a single read or write; 380ms average since system boot! Something’s not right. The throughput numbers are also a clue, disks should be doing 30 MB/second, although that does depend on what the programs using the disks are doing. The 100% utilization is a very bad sign too. You can get more details from iostat if you remove the -s flag, but it gets a little confusing.

hdparm

hdparm can be used to test read rates on a disk. Here’s what I got

# hdparm -t /dev/sda
/dev/sda:
 Timing buffered disk reads:  30 MB in  4.27 seconds =   7.02 MB/sec

That’s 7 Mbytes/second. That’s awful. Even a slower spinning disk should be in the range of 100 MB/sec. Something is wrong.

smartctl

smartctl -x /dev/sda is also important, using SMART diagnostics on the disk itself. -x means “all, no really all”. Unfortunately its output is still really hard to understand, the confusing “VALUE WORST THRESH” stuff. I have previous notes on understanding smartctl output that are helpful. This weird Maxtor drive I have has confusing numbers and doesn’t report the Raw_Read_Error_Rate I’d most like to see.

I do have an error log with lots of entries like

Error 46140 [11] occurred at disk power-on lifetime: 36305 hours (1512 days + 17 hours)

There’s no easy way to tell how old those errors are or exactly what they meant. But their presence and the number “46140” sure gives me concern.

smartd displayed this helpful error in the syslog, also suggesting a problem.

Jul 4 17:05:56 wl smartd[3197]: Device: /dev/sda [SAT], 1 Currently unreadable (pending) sectors

Remapping bad blocks

Modern spinning hard drives have the ability to remap bad blocks and avoid them in the future. Linux has historically been bad at letting the disk do this, I think on the theory that destroying data is bad and it should be a manual process (or better, avoided). Here’s some recent notes on the topic. I think manually remapping a known bad block is still really awkward and difficult. Reading that makes me think the disk should itself eventually recover if the block is re-written. But if it’s a read only file that’s corrupted that won’t ever happen!

SSDs change how all this works.