Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I got errors like this in my syslog, but there's no bad block or sector defined in kernel report, I can't just replace the HDD right now and I prefer to reallocate the bad blocks for now, so I need the number of bad sectors.

Any suggestion on how to find the number of sectors as fast as possible?

In other server that I have, kernel always reports sector number but on this server no sector reported.

res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
sd 0:0:0:0: [sda] Add. Sense: Unrecovered read error - auto reallocate failed
res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
sd 0:0:0:0: [sda] Add. Sense: Unrecovered read error - auto reallocate failed
res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
res 41/40:08:a0:11:76/00:00:53:00:00/00 Emask 0x409 (media error) <F> ata1.00: error: { UNC }
sd 0:0:0:0: [sda] Add. Sense: Unrecovered read error - auto reallocate failed

My question is just why this server's kernel is not reporting the number of bad sector? like the other one does?

share|improve this question
    
You have read errors. You can't recover from read errors by reallocating sectors: that won't make the unreadable sectors readable. You'll have to recover that part of your data from backups anyway. Better retire the disk as soon as possible. –  Gilles Sep 21 '12 at 0:08
add comment

1 Answer

You may be able to get some of that information from the SMART log on the disk (smartctl -x /dev/sda).

Otherwise, that's what the badblock command does. That can also be used to tell which blocks are dead (in case reallocating fails) to feed e2fsck (if an extx FS is on that disk, but some other FSes have a similar feature) and specify that those sectors should not be used. Or e2fsck can call badblocks directly.

In any case, it will put a strain on the disk and may cause it to fail any further.

I would look at the SMART status (smartctl -x /dev/sda) to see what shape it is in first (how many pending, failing, reallocated sectors, errors... and the overall SMART status) as if it's on the verge of failing altogether, the best thing to do is backup the data onto a new drive (see various implementations of ddrescue for that).

share|improve this answer
    
If you plan to feed the list to e2fsck, its far easier to just use e2fsck's -c option. That way, you don't have to worry about making sure you pass the right block size, etc. to badblocks. –  derobert Sep 20 '12 at 18:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.