I know I have a hardware problem and it will get worse - and a replacement drive is arriving in 2-3 days.
However, I desperately need to use my computer again for tonight. Most things seem to work fine, but Firefox invariably crashes after being on for a couple of minutes. I am guessing it's stuck in one of the bad sectors? How do I get my computer to just avoid those sectors temporarily?
If there isn't a targeted way to avoid those sectors, should I just reinstall Firefox and hope for the best?
I was assuming the computer would automatically flag bad sectors and avoid using them - but that doesn't explain why the computer keeps crashing (and only when I use Firefox).
62 Answers
This is supported by badblocks (for Ext2, in Linux). In DOS and OS/2, it was CheckDsk/F (or Chkdsk/F depending on the version) (for FAT16, in DOS)... Surely ScanDisk can also do that (for Microsoft Windows). In newer versions of Microsoft Windows, you can add /r to that (Chkdsk /F /R or Checkdsk /F /R) for more thorough checking/marking/fixing. In newer versions of Microsoft Windows, to use the GUI, go to My Computer, access the Properties of a drive, go to Tools tab, and "Check now". Check the box that says "Sca_n_ for and attempt recovery of bad sectors". Those directions are for Win7; XP and other operating systems are presumably close.
So, to summarize, the exact method of how this gets done will depend on what operating system is being used. That is presuming that you use default filesystem types. If you're using other filesystem types, then the software you use may also depend on what filesystem types you use.
So, there's the answer to your question, if you're wanting to use standard disk utilities that are bundled with the operating system. Other specialized software may also have the ability to do this.
Note: This should not be relied upon. As noted in some of the question's comments, continuing to use the disk is likely to spread damage. If you're lucky now, you can read data from the bad sectors, but not write data to them. That would be fortunate, because you could still get a backup. It is not only possible, but actually quite likely, that continuing to use the drive may lose the ability to even read from additional sectors. People who have experience with losing data will recommend that you use the drive absolutely minimally. Ideally, don't even let the computer swap to the drive. How do you prevent the computer from swapping to the drive? Leave it off as much as possible. So, even though I am providing the answer to the requested question, I feel obligated to re-iterate the warnings that have already been given. Relying on any of the software that has been mentioned, or any other software, is not recommended because it is not suitably safe.
If this is a home computer, make sure to back up the data that is most valuable. That usually means backing up ~ and/or /home and/or /users in Unix, and C:\Documents and Settings and/or C:\Users in modern Microsoft Windows. Just a copy to a USB drive, or an upload to a remote system, may give you peace of mind that is justified, because it could save you. I suggest taking care of that before making your web browser visit any other web pages, and before doing anything else. Even if you have another hard drive coming so that you can back up all your big data. For the time being, find a USB stick and copy that usually-valuable data. This is advice I would give for any drive with just one bad sector. Since you're already encountering problems, you're further down the path of problems, so this advice is even more critical. Things may work just as good/bad, without change, for days or weeks. But odds are fairly high that you'll have more thorough and instant disaster. This could easily happen anytime now without any further warning. Sure, that's always a possibility. In this case, it seems extremely likely. So, get paranoid quick.
An operating system can only operate on "logical" blocks and sectors that the firmware of a hard drive provides an API to access. A simple number of blocks from 0 to N.
Only the firmware has R/W visibility of the physical blocks, identify if a block is not working or is about to fail, etc.
When the firmware is unable to read or write content, then it returns an error to the o/s. If and when the firmware is able to retrieve data or identify a physical block is going bad, then it can "move the data".
Sometimes rebooting many times can allow you to survive a failure.
But for almost 20 years I have recovered usability of failing hard drives using a product called SpinRite, from
After recovering data it is a good idea to replace the drive or use it as backup only (have a pool of backup disks to rotate).
In the basic recover mode SpinRite forces the firmware to Read over-and-over (for possibly hours) a bad logical sector with different "approach" techniques which works well on spinning drives, until the firmware finds a way to read a "marginal or damaged" block.
It may take a bit of skill to create a bootable drive with the SpinRite software, and quite a few hours of work. And this may not be quick enough; but a little project to recover data from drives.
For about $90, once you have that s/w, you will save yourself days and days of work otherwise spent re-constructing your data from backups or "re-writing it".