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.

17 thoughts on “Fixing FreeNAS Currently unreadable (pending) sectors error

  1. That dd command looks dangerously wrong, unless you really want to write a block as big as 850MiB. Once smartctl told you the LBA_of_first_error, and assuming your device has 512 byte sector blocks, you should then use something like:
    dd if=/dev/zero of=/dev/yourdevice bs=512 count=1 seek=892134344

  2. Johnrezzo is correct. bs=sector. However, even though my sectors were 512, nothing was fixed after 40+ tries. It only worked once I went above what the sector number was and did 2048, so my bs=2048. Only then did the SMART get reset to 0. After scrubbing, everything was 100% healthy.
    so my shell command was: dd if=/dev/zero of=/dev/ada2 bs=2048 count=1 seek=27945554

    • In reply to “Oooof” lol, One would think Freenas whould have a simple web ui point and click way of dealing with this common problem but No Freenas Failed us massively, when your one and only job is to handle storage drives how could you not handle something as simple as smart errors hum, anyway the safest simplest noob way to handle this if you care about your data is to download and burn a cd seatools for dos, run the long test on the drive then repair the bad sectors / blocks then boot freenas and do a scrub all done all is well till next time pain in the but it works good and is easy here is a link to the download seatools for dos http://www.seagate.com/support/downloads/item/seatools-dos-master/

      and yes it works on any drive brand and any file system for me anyway have fun

  3. Instead of increasing sector number, you can just increase count, since total bytes written = sector size * count. And if the part of the disk that is failing is more than a few bytes large, it might pay to set count=something higher than 1, maybe even, say, 10, to force that number of sectors to remap.

    In my case I also used /dev/random instead of /dev/zero.

    Due to not reading the comments first, I unfortunately (what was I thinking? Oh yeah, I was not) executed the original command listed in the blog with bs= and seek=0. Then waited some seconds before realizing it was wrong and trying to stop it with control-C which seemed nonresponsive. Basically I zeroed out my drive lol. This caused ZFS to take it completely offline and put my pool in a DEGRADED state. I’m currently dealing with that, considering just physically removing the drive at this point, chalking it up as a loss and replacing it with a spare I have and resilvering.

    Original Poster: PLEASE edit your post to fix the commands! Your advice will cause people to zero out their disks! lol

    Since drives (as I understand it) already have some capacity set aside for automatic sector remapping as the drive is used, it’s my opinion that if these actually start showing up in userland, things are already f***ed and it may pay to just remove the drive entirely. Seems a waste since the rest of the drive is still theoretically readwriteable, but whatever, capacity is cheap these days.

  4. Ah, I see what the problem here is. WordPress is filtering out anything in between less-than and greater-than signs, period. That’s lame. SO my command above that said bs= should have said bs=[some large number]. And I bet the OP had the same thing happen for the seek= parameter.

  5. Error in the information given. It should be;

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

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

    Note: 4096 is the stripesize found by using command: diskinfo -v /dev/ada(your disk number)

    eg; for me my disk is 1 and hence ada1 is used for this example;

    —–
    [root@freenas ~]# diskinfo -v /dev/ada1
    /dev/ada1
    512 # sectorsize
    2000398934016 # mediasize in bytes (1.8T)
    3907029168 # mediasize in sectors
    4096 # stripesize
    0 # stripeoffset
    3876021 # Cylinders according to firmware.
    16 # Heads according to firmware.
    63 # Sectors according to firmware.
    WD-WCAVY6679527 # Disk ident.
    ———

    The seek is the sector eg shown below;

    So in my case the seek would equal = 887447520

    ——–
    No Errors Logged

    SMART Self-test log structure revision number 1
    Num Test_Description Status Remaining LifeTime(hours) LBA
    _of_first_error
    # 1 Extended offline Completed: read failure 80% 23265 887
    447520
    # 2 Short offline Completed without error 00% 18175 –
    # 3 Short offline Completed without error 00% 13959 –
    # 4 Short offline Completed without error 00% 12206 –
    # 5 Short offline Completed without error 00% 2308 –

    SMART Selective self-test log data structure revision number 1
    SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
    1 0 0 Not_testing
    2 0 0 Not_testing
    3 0 0 Not_testing
    4 0 0 Not_testing
    5 0 0 Not_testing
    Selective self-test flags (0x0):
    After scanning selected spans, do NOT read-scan remainder of disk.
    If Selective self-test is pending on power-up, resume after 0 minute delay.

    [root@freenas ~]# c
    ———-

    hence the command i would use is;

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

    key bs= stripesize
    seek= sector

    I hope this helps because although the above text is useful it did have an error in it and took me some time to resolve after reading a number of other article.

    All the best if fixing your bad sectors.

  6. Is it like this?

    Sector Sizes: 512 bytes logical, 4096 bytes physical

    #18 Extended offline Completed: read failure 90% 22622 337288648

    Corrected:
    sysctl kern.geom.debugflags=16
    dd if=/dev/zero of=/dev/sda bs=4096 count=18 seek=892134344 conv=noerror,sync

  7. Thank you OP and Ash. In my case the drive required bs=512 despite what diskinfo -v indicated.

    HOw come comments don’t have a date alongside them?

  8. Thank you OP and Ash. In my case the drive required bs=512 despite what diskinfo -v reported.

    HOw come comments don’t have a date alongside them?

Leave a comment