How to remove bad sectors from a hard disk drive

fedorahard drive

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

Best Answer

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).

Related Topic