search
top

OS X Bad Blocks…

I “switched” to Mac about two years ago and  recently upgraded to a shiny new unibody Macbook Pro – although I’m quite experienced with Windows troubleshooting and repair (oh yes, many years of practice…) this is the first time I’ve ever had to do it on Mac, and although it was hard work and a lot of trial and error, I’ve learned a great deal.

So, you’ve had to hard reboot Os X, but when you restart everything runs slowly… the spinning beachball appears every few minutes (or seconds!), the finder hangs when you browse, applications bounce indefinately… basically you find yourself with an unusable system. My “Downloads” folder had even turned into a “package”, which would crash the system when I viewed the contents – and since I had connected an ISO in that folder to my Parallels Virtual Machine I began to suspect that files used by Parallels at the time of the crash had become corrupt (or maybe more correctly the sector on which they were located was trashed…).

Normally, so the forums say, you would run ONYX (if you can get that far), repair permissions, clean the caches etc… if that fails you’d Boot into safe mode (without the extensions) and see if all is OK – if not you’d probably end up booting from the Apple install DVD to run the Disk Utility, or use firewire and Target mode to repair from another Mac or boot from an external drive, and if all else fails you’d go to an Apple service center, buy Disk Warrior, or “Archive and Install” Os X.

I recently found myself in this situation after a system freeze when using Parallel Desktops 5 (although I think the freeze was caused by Fireworks CS4).  However, I was in China at the time and hadn’t brought my Apple DVD, my original receipt (required at Chinese Apple Service Centers) or a firewire cable.  It turns out that firewire disks and even cables are nearly impossible to find in China, and my receipt was at home in a box somewhere, so I was left trying to fix things on my own with none of the tools usually recommended… Downloading a Disk Warrior DVD was not going to work on a chinese DSL connection, so here’s how I finally did it (minus all the failures!):

After much playing around I finally figured that I had bad blocks on the hard drive or corrupt files (or both?) that were giving multiple I/O Error entries in the console logs. It seems that everytime the OS tried to access these files/sectors the system would freeze, apart from the mouse pointer.  Trashing preference files didn’t help, and the freezes continued even after booting in safe mode… FSCK -fy  repaired things and finally showed the disk OK, as did Disk Utility, but Tech Tool Deluxe showed I did have errors during the surface scan.  The internet forums all said that with bad blocks and I/O Errors my disk was probably going to fail soon, and that my only hope was to reformat my hard disk, write 0′s to the whole disk, then reinstall – which in this case was not an option.

First of all, I managed to create a new user account in Safe mode, booted into that user, and uninstalled Parallel Desktops . It seems that you also need to use ONYX to clear the bootcache and kernel cache etc then reboot, then reinstall Parallels for this to work.

I still had I/O Errors in the Console though, so I went through all the software that I was running at the time of the crash, and did the same thing: uninstall, onxy clean and reboot.  I managed to salvage on of my Virtual Machines by copying it over to my new user account (Parallels was the first to point me to the I/O Disk Error when I had tried to open the VM), but another refused to copy at all and I ended up trashing it.

I looked hard on Google for a tool that could show me which files were corrupt on OS X, and ended up using the following trick:

If you suspect corrupt data in a given folder (such as Library/preferences), copy it to another location. If the copy goes OK then you can delete the copy – if it fails it will usually tell you which file caused the error, and you can then delete it.  Sometimes you will be unable to delete it, but you can still delete the parent folder ;-)

After much detective work I finally had all my software working again in the new user, and even my original user account was now working well again – I had used the above “copy” trick to worm out several corrupt system files and folders, but the I/O Disk Error message kept coming up at random intervals…

I finally noticed that running “System Info” and “Log” would take about 8 minutes to display the various log files and give exactly 7 I/O Disk Error messages, whichever user account I used… so I opened up Path Finder (to display invisible files and folders) and copied the var/log folder – no problem :-( Then I tried fseventer and saw that while running the System Info tool there were calls to Macintosh HD:Library:Logs:DiagnosticReports folder.  So I did the same “Copy” trick, and hey presto, a file in the ASL folder called 2010.01.01 refused to copy – I couldn’t delete it so just deleted the whole folder.

Finally I copied my VM back to the orginal user account (you have to put it in the Documents/Paralles folder and double click it – “Import” didn’t work for me, and it didn’t show in the VM list until I did this), and as if by magic my system is back to normal – all my software is working smoothly, no more I/O Disk errors, no beachballs, no bouncing app icons :-) And I managed to do it with only the following tools:

FSCK -fy in Single User Mode (Apple Key + S) to repair the filesystem category hierarchy etc
Verbose Mode Boot (Apple Key +V on start up) to see which apps bypass user login preferences.
Safe Boot (Shift key after chime until spinning wheel)
Onyx – to clear all caches and run maintenance scripts.
Fseventer – for the detective work.
Finder Copy/Paste – to detect corrupt files/sectors
Console – on “All messages” with filter set to “I/O” to see when I/O Disk Errors occur.
System Info – to force access to all system logs.

Reblog this post [with Zemanta]

Leave a Reply

Spam Protection by WP-SpamFree

top