Any one have any idea how to remove bad sector from hdd using fedora 11


Do you know which blocks are bad? Is there already a filesystem?

If there's no filesystem yet, and you don't know which blocks are bad:

mkfs -c # rest of normal options, like -t ext3 /dev/sda4

If you have a filesystem and you don't know which blocks are bad:

e2fsck -c /dev/sda4

If you know which blocks are bad, you can list them in a file and run -- however, this option is tricky since you have to refer to the blocks exactly right:

e2fsck -l BADBLOCKSFILENAME /dev/sda4
mkfs -l BADBLOCKSFILENAME -t ext3 /dev/sda4

It's generally recommended to go with the -c option which scans for badblocks.

And if you mean a totally unused hdd, you could possibly just avoid the bad sectors when partitioning with fdisk (and use LVM to preserve flexibility about the size of your various filesystems).

  • You can generate the list using the badblocks program, which iirc, is all that the -c option does anyway. Jun 11 '09 at 18:33
  • David: yes, but you have to get the block size option to badblocks just right, and it's not obvious how. The manpage for badblocks specifically warns "it is strongly recommended that users not run badblocks directly".
    – freiheit
    Jun 11 '09 at 18:57

SpinRite, but you will need a Windows machine to make the boot disk. It is OS agnostic and Steve will give you your money back if it doesn't work.


  • +1 for SpinRite. It is really great!
    – Bob
    Jun 11 '09 at 18:32
  • I've used SpinRite to repair many hard drives. One laptop had a hard drive that was starting to chirp and the system would just hang for 30 seconds. It showed 130 bad blocks when running badblocks on it. After SpinRite badblocks returns 0 bad blocks on the hard drive. System has been working for about 18 months since then without problems. Jun 11 '09 at 19:13
  • 1
    You can run the exe and generate the ISO using wine on Linux btw. Jun 11 '09 at 20:06

You could replace your drive under the manufacturer's warranty.


If you mean flag bad blocks as such, and not actually fix them, check out the badblocks utility. It supports both destructive and nondestructive tests. It's available in most recent distos.

If you mean repair a bad block, then I second SpinRite.


If you're seeing any bad blocks on a hard drive this is normally not a good sign. When a hard drive runs into a bad block it remaps that block to one of it's spare blocks that it has just for this reason. So the number of bad blocks exposed at the level that your OS accesses the drive should always be 0. Any number higher than this means that the drive has remapped all it's spare blocks and it can no longer handle bad blocks gracefully.

Linux's tool badblock for identifying and working around these problems were created and used in the time when hard drives were expensive. Similar to the kernels ability to pre-allocate bad memory addresses in ram so that applications don't use them. But these tools have really been made obsolete due to the low cost of hard drives and ram.

Spinrite run on level 5 will double check all blocks on a hard drive. It will unmap any blocks previously marked as bad that were not really bad. Freeing up spare blocks for blocks that are truly bad.

So I would either use Spinrite to get the drive back to a healthy state with spare blocks or replace the drive. Remember that Spinrite is not going to repair all drives and if your drive just happens to have a lot of truly bad blocks there's nothing that Spinrite can do. But Spinrite is well worth the small cost.

  • If a sector is determined to be bad on a read, it cannot be mapped out. It will be marked as some pending state and on the next WRITE will be mapped out. Thus, it IS possible to see bad sectors on a drive without something catastrophic having happened first.
    – Eddie
    Jun 12 '09 at 0:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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