OpenBSD - handling bad sectors


What is the problem?

Modern IDE hard disks handle automatically bad sectors. They have "hidden" spare sectors that are used to reallocate bad sectors. In principle this is transparent to the operating system since bad sector reallocation is done by the disk it-self. So if you get "uncorrectable data error" messages in your log that means that the disk failed to reallocate a bad sector. Example:

May 12 22:09:37 moule /bsd: wd0h:  uncorrectable data error reading fsbn 3042224
0 of 30422240-30422367 (wd0 bn 39785552; cn 39469 tn 12 sn 44), retrying
May 12 22:09:37 moule /bsd: wd0h:  uncorrectable data error reading fsbn 3042224
0 of 30422240-30422367 (wd0 bn 39785552; cn 39469 tn 12 sn 44), retrying
May 12 22:09:37 moule /bsd: wd0h:  uncorrectable data error reading fsbn 3042224
0 of 30422240-30422367 (wd0 bn 39785552; cn 39469 tn 12 sn 44), retrying
May 12 22:09:37 moule /bsd: wd0: transfer error, downgrading to Ultra-DMA mode 1
May 12 22:09:37 moule /bsd: wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 1
May 12 22:09:37 moule /bsd: wd1(pciide0:0:1): using PIO mode 4, Ultra-DMA mode 2
May 12 22:09:37 moule /bsd: wd0h:  uncorrectable data error reading fsbn 3042224
0 of 30422240-30422367 (wd0 bn 39785552; cn 39469 tn 12 sn 44), retrying
May 12 22:09:37 moule /bsd: wd0h:  uncorrectable data error reading fsbn 3042225
7 of 30422240-30422367 (wd0 bn 39785569; cn 39469 tn 12 sn 61), retrying
May 12 22:09:37 moule /bsd: wd0h:  uncorrectable data error reading fsbn 3042225
7 of 30422240-30422367 (wd0 bn 39785569; cn 39469 tn 12 sn 61)
The IDE disk (at least mine) doesn't reallocate any bad sector unless it is overwritten. Any attempt to read it will fail with an "uncorrectable data error" message. Thus, if fsck fail on system startup (because of the bad sector), the partition will not be mounted, the bad sector will not be overwritten and the disk will not try to reallocate it, (even if there are spare sectors left on it).

Make the disk reallocate the bad sector

Obviously the solution is to overwrite the bad sector by hand. This is very risky, so do it very carefully and backup everything you can from the partition where the bad sector is located. Feedback appreciated: alex[at]caoua[dot]org.


Copyright © 2005 Alexandre Ratchov
Last updated: may 13, 2005