Go Back   The macosxhints Forums > OS X Help Requests > System



Reply
 
Thread Tools Rate Thread Display Modes
Old 01-05-2010, 08:04 PM   #1
phKU
Prospect
 
Join Date: Jan 2010
Posts: 3
Exclamation Locate and fix HD bad blocks without formatting

Usually, when you encounter a bad blocks problem on a hd, the only given solution is to do a thorough reformatting of the hd by overwriting every blocks (zeroing or writing scrambled data). The reason for this is that the hd remap its bad blocks to spare ones only at write request.

This is very annoying since when there is any bad block on a hd, you can't do any more block level backup or a complete file backup, or even mount any more the hd (if the bad block is located in the file structure). Obviously, having to do an emergency backup, overwrite the whole disk and finally restore the disk from backup, all this tralala just for a couple of bad blocks seems to be really counterproductive.

Since at writing time, I found no os x app available for fixing bad blocks, I looked then for tools permitting to do manually the requested steps: Locate every bad block, 2° Overwrite each bad block (only!), Determine to which file(s) belongs the missing data, Restore, repair or erase the affected file(s).
  1. Locate every bad block
    Whole disk block scan for building a bad block list.
    You can use Drive Genius 2 which do this very well (though it wrongly pretend fixing the bad blocks himself). iBored offer also a bad block scan function which I didn't try yet.

  2. Overwrite each bad block
    Write zeros over the bad blocks
    iBored is a low level disk editor, and AFAIK the only one available for os x (what a shame!!!). It notably allows to display and modify any disk sector. You should be very careful at this step to be sure not to overwrite valid data. You have also to add the partition block starting address to the bad blocks volume address. A way to check you're on the right block is to attempt a read at the calculated block address. If it matches, iBored will hang for 3 minutes or so and finally report a I/O read error (you may have to disconnect-reconnect the drive to access it again).

  3. Determine to which file(s) belongs the missing data
    Given a block number, find the file owner (if it's not free space)
    iDefrag will do the trick, though not very easily. You can use it to scan a volume in the defragmenting procedure without actually defragmenting (What of course would be not recommended at all at this stage). Then you have to show the info panel and move/click the mouse in the color graph to see the files info. The app doesn't provide a way to jump to a specific block. You have rather to click here and there till you reach the right block.
    3 important point:
    1. iDefrag treat allocation block, a multiple of low level disk block (512 bytes). You will find the allocation block size with iBored by displaying the HFSPlusVolumeHeader at block partition offset + 2 and read the blockSize field at byte $028. The multiplier factor is blockSize/512(sector size) e.g. for a blockSize of 4096: 4096 / 512 = 8, thus iDefrag file block address would be 8 * bad block volume offset.
    2. iDefrag treat volumes so no need to add the partition(volume) offset.
    3. The target allocation block may belong to a fragmented file and if it's the case, you will have a bit harder job to find the right file because of the mixed fragments of different files.

  4. Restore, repair or erase the affected file(s)
    Refresh or cancel the missing data
    Restore from backup corrupted file if needed and available. Repair when it's possible, in particular the file structure if it was broken. For this, I use DiskWarrior, a must have app, and stay carefully away from disk utility and fsck since the Apple utilities could only get the situation worse where DW do perfectly the job.
Et voilà! enjoy your fast and efficient drive bad blocks repair. Even so, I would strongly suggest to backup your disk and replace it by a fresh one. Bad blocks is usually sign of a soon very worst failure…

Thank you for reading, hmm… was it really readable?
Any other apps suggestion or so is of course welcome.


The apps:

Drive Genius 2 $99
iDefrag $29.95
iBored Free
DiskWarrior $99.95
.
phKU is offline   Reply With Quote
Old 04-27-2010, 12:44 PM   #2
dmitri
Prospect
 
Join Date: Apr 2010
Posts: 10
Hi
That's what I need to do
Did not understand really the way
but, my question would be, what if hard drive formatted FAT32, then Disk Warrior does not do the job?
dmitri is offline   Reply With Quote
Old 04-27-2010, 08:15 PM   #3
phKU
Prospect
 
Join Date: Jan 2010
Posts: 3
Quote:
Originally Posted by dmitri
Did not understand really the way
but, my question would be, what if hard drive formatted FAT32, then Disk Warrior does not do the job?

I would use similar windoz utilities with a pc emulator or box.
phKU is offline   Reply With Quote
Old 04-28-2010, 01:26 AM   #4
SirDice
MVP
 
Join Date: Aug 2009
Posts: 1,119
Quote:
Originally Posted by phKU
The reason for this is that the hd remap its bad blocks to spare ones only at write request.

True, bad blocks will get remapped during a write action. However, if your drive is showing bad blocks it usually means that spare section on the drive is full. You're better off replacing the drive completely.
SirDice is offline   Reply With Quote
Old 05-01-2010, 08:01 PM   #5
phKU
Prospect
 
Join Date: Jan 2010
Posts: 3
Quote:
Originally Posted by phKU
Even so, I would strongly suggest to backup your disk and replace it by a fresh one. Bad blocks is usually sign of a soon very worst failure…

Again, this is only a temporary workaround which allows you for example to do a full disk backup before replacing it. With bad blocks, this type of backup would only fail.

Bad blocks doesn't mean necessarily that spare section of the drive is full because usually blocks turn to be bad later after a write action, not at write time. To be sure, you can use SMART Utility to check drive internal status before operation.

I wrote this tutorial because these steps allowed me to fix a couple of boot disks and then save their content + whole directory structure via full disk backup. This saved me the time of reinstalling OS, folder hierarchy and tons of apps + docus. Also it allowed me to almost totally rescue corrupted data files which would have been otherwise badly recoverable, e.g. audio/video.
phKU is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 02:52 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.