Does a bad sector indicate a failing disk?

Bad sectors are always an indication of a failing HDD, in fact the moment you see an I/O error such as this, you probably already lost/corrupted some data. Make a backup if you haven't one already, run a self test smartctl -t long /dev/disk and check SMART data smartctl -a /dev/disk. Get a replacement if you can.

Bad sectors can't be repaired, only replaced by reserve sectors, which harms HDD performance, as they require additional seeks to the reserve sectors every time they are accessed. Marking such sectors as bad on the filesystem layer helps, as they won't ever be accessed then; however it's hard to determine which sectors were already reallocated by the disk, so chances are the filesystem won't know to avoid the affected region.


To make the drive to reallocate the sectors, usually you need to write something into them. However, dd (Disk Destroyer) does not always work, and is very unsafe: if you confuse the skip and seek options, you can easily shoot yourself in the foot by skipping the N first blocks of /dev/zero and writing a block from that "offset" over the sector 0 of your hard disk.

If you really know you want to force the sector be overwritten with zeroes, you should use hdparm:

% sudo hdparm --read-sector 833192656 /dev/sda
/dev/sda:
reading sector 833192656: FAILED: Input/output error

Yes, the sector 833192656 was failing in smart-tests also. To write zeroes to it, use --write-sector:

% sudo hdparm --write-sector 833192656 /dev/sda
/dev/sda:
Use of --write-sector is VERY DANGEROUS.
You are trying to deliberately overwrite a low-level sector on the media.
This is a BAD idea, and can easily result in total data loss.
Please supply the --yes-i-know-what-i-am-doing flag if you really want this.
Program aborted.

As a safeguard, hdparm doesn't really write anything unless you pass the --yes-i-know-what-i-am-doing switch to hdparm:

% sudo hdparm --yes-i-know-what-i-am-doing --write-sector 833192656 /dev/sda
/dev/sda:
re-writing sector 833192656: succeeded
% sudo hdparm --read-sector 833192656 /dev/sda                              

/dev/sda:
reading sector 833192656: succeeded
0000 0000 0000 0000 0000 0000 0000 0000
[      ... more zeroes here...        ]
0000 0000 0000 0000 0000 0000 0000 0000

%

No, bad sectors are not always an indication of a failing drive. Sometimes if a write is in progress at the time of a power failure, the data in the sector will be corrupted, resulting in an error when you try to read it. Attempting to write new data to the sector may work just fine since there's nothing physically wrong with it.

You can run badblocks -n on the drive to read and rewrite every sector, or in your case since you already know the number of the sector in question, you can use dd to write zeros to it. You can check the SMART stats with smartctl -a. You should see the pending reallocated count indicate how many sectors have failed to read, and after attempting to write the sector, this count will go down. The reallocated sector count may go up, in which case it was physically bad and has been remapped to the spare pool, and this may be a sign that the drive is on its way out. If not, then then it was just scrambled and should be fine now.

Try reading the sector first:

dd count=1 if=/dev/sda of=/dev/null skip=nnnn

If that fails, then you have the number right, then you can zero it out with:

dd count=1 if=/dev/zero of=/dev/sda seek=nnnn

Double check that you typed the command exactly before hitting enter.