Saturday, January 29, 2011

How can I tell a portable drive to ignore bad sectors on a Linux?

I have a USB harddrive, and it's old. It's fat32 formatted. It's so old that parts of it are failing. When I tell it to read or write from a certain parts, I get IO errors on my console (I'm using Ubuntu 9.10).

Is there some programme that I can run that'll scan my drive for bad parts, then 'remove' them? I'm willing for this to cost me a few GB in size (it's a 160GB drive). There's nothing on the drive that I care about, it was recently reformatted. It's currently formatted fat32, but it'll only be plugged into linux machines, so I'm willing to try ext3, or some other linux filesystem. This drive has been reformatted recently and the same thing is happening.

I know the real solution is to get a new drive, and one is on order. However I need to give a harddrive to someone in the new few days, and this (partially broken) one is the only spare. If I get get this working, that'd be great. Is there some way I can reformat or repartition this drive so I have at least some usable drive space?

  • While this question probably belongs on super user.

    Identifying the bad blocks isn't hard to do. You can use the program badblocks to do it. Getting it to ignore them is a tougher matter. If a drive is showing bad blocks then it means that the drive is out of spare blocks. It should probably just be trashed and I wouldn't pass that drive on to someone else.

    If you must use this drive there is a chance that spinrite will get the drive back to a healthy state...but only if the drive has mistakenly marked some blocks as bad. Spinrite will check all the blocks on the drive including the ones marked as bad and if it determines that a block that the drive marked as bad is really good it will return it back to the usable blocks freeing up a block in the spare block list. If it finds enough of these the drive will show 0 bad blocks when you run badblocks and hopefully have some spare blocks to spare.

    I had a laptop that had 120 badblocks and this dropped to 0 after running spinrite on the drive. Drive continues to work without any problems today 2 years later.

    Boden : I can second the use of SpinRite
    Rory McCann : To be clear, I don't care about the data on it. I can reformat it.
    3dinfluence : You indicate that the drive was recently formatted. If that's the case and it's still showing problems then the problem is at the physical drive level...not the file system. A healthy drive should never show any blocks as bad. This is b/c drives keep a pool of spare blocks that they remap to when they encounter a bad block. So reformatting it doesn't change the fact that the hard drive physically has run out of spare blocks and is now is out of spare blocks and has additional bad blocks that it can't hide.
    3dinfluence : So here's what you need to do. First run `badblocks \dev\` if that outputs any bad sectors then do this `sudo apt-get install smartmontools` then run `smartctl -A /dev/`. This should give you the over all health of the drive. Looking at the Reallocated_Sector_Ct in particular b/c I'm going to guess that this value is pretty high on this drive. This will confirm that your drive is remapping a lot of bad blocks. Otherwise you just have some file system then so reformat it to NTFS if you're using it with Windows and don't pick Quick Format.
    3dinfluence : My personal belief is that drives are so cheap these days that they aren't worth the time and effort involved in doing all this. Especially if the data on the drive is not important. Just replace it.
    Rory McCann : Yes there are almost certainly physical problems with the disk. Is there some way I can reformat/repartition it so that I can skip the bad parts? I'm trying to find a way to get some sort of usable storage space on it, even for a few weeks.
    3dinfluence : Spinrite and a bit of luck may do the trick. If all the badblocks are clustered together you may be able to partition the drive to avoid the current bad blocks. However any new bad block will result in an error that the drive can not deal with and you'll find yourself in the same or worst situation if the drive has data which is important.

0 comments:

Post a Comment