Fixing FreeNAS Currently unreadable (pending) sectors error

If you have redundancy, one or two bad sectors can be fixed even without any downtime.

The error message might look something like this:

10-06-2014 16:25:20 Daemon.Critical storage2 Oct  6 16:25:21 smartd[1560]: Device: /dev/ada2, 2 Currently unreadable (pending) sectors

You can see that the faulty device is /dev/ada2. Now, login to console and run long SMART test:

smartctl -t long /dev/ada2

It should tell you that the test is started and when it will finish. After it finishes, check test results:

smartctl -a /dev/ada2

The output will tell you two important things. In information section there is sector size:

Sector Size:      512 bytes logical/physical

Near the end there is SMART Self-test log which tells you whether it failed and what’s the faulty sector number (LBA_of_first_error column)

# 1  Extended offline    Completed: read failure       90%     25166         892134344

Now we have all the info we need to fix it. We will directly write to this sector to force it to reallocate. The important parameters are ‘of’ which is your faulty device name, ‘bs’ which is sector size and ‘seek’ which is sector number.

sysctl kern.geom.debugflags=16
dd if=/dev/zero of=/dev/ada2 bs=892134344 count=1 seek= conv=noerror,sync

Then check if the ‘Current_Pending_Sector’ in ‘SMART Attributes Data Structure’ table went to 0:

smartctl -a /dev/ada2

If not, repeat the long test and write to all sectors until they reallocate. Then run a scrub, replace ‘poolname’ with your poolname:

zpool scrub poolname

Finally check scrub status

zpool status -v poolname

That should do it.