I’ll be writing some technical posts at times. I really try to do my best at explaining everything in detail so that non-technical readers can understand what I’m talking about. So if you’re wondering why there’s so much technical explanation (and at times, lack of depth), it’s because I’m assuming the majority of MOAR PLOX’s audience is not technical. I apologize?

Background:

So yesterday I took on the task of trying out some new stuff in OS X. (For those of you who don’t know what I’m talking about, I’m referring to Mac OS X [pronounced 'Mac OH-ESS TEN'] — the operating system used in desktops and laptops manufactured by Apple. It’s commonly regarded as the prime competitor of Microsoft Windows. But enough explaining; I’ve already left out more caveats than I wish to include. Essentially, I’m talking about this)

I’ve never really gotten into OS X on account of being against Apple products for so long. To this day I still think Apple products are overpriced and overhyped. I can see why people like OS X for its ease of use and potentially powerful UNIX core. But anyway, I just wanted to give it a try so that I could maybe become a little more familiar with it. Then I’d actually be able to navigate a Mac without 1) getting frustrated or 2) looking like a complete ass. I figured it was time to get familiar.

Initially, I’d planned to boot both OS X and Windows 7 on my Thinkpad. Problem with that was that the process of successfully booting OS X on an x86 machine (non-Apple hardware) is pretty involved and required things I didn’t have. For instance, I only had a ripped image of OS X Leopard (because I knew my brother would lose the disc) and I didn’t have dual-layer discs to burn the nearly 7GB image. So right away, I couldn’t boot from a disc anytime soon. As a result, I was forced to go the way of creating a bootable USB flash drive. This was a problem in itself. It’s much easier to edit an image and burn it to a bootable disc than it is to parition a bootable USB. You might disagree, but the circumstances might sway your opinion: I was limited to Windows. I didn’t have a Mac available to format and partition the USB, and I couldn’t easily manage the image because it was a .dmg (I REALLY should have ripped it as an .iso — don’t know what I was thinking). And it’s a bitch to deal with .dmg’s outside of OS X. There are ways, but they’re very tedious. In short, after spending a solid 3 days trying to get it to work, the Hackintosh project fell through and I said screw it for a while. I usually work on these types of things until I get them working, but I just didn’t want to deal with it anymore. It wasn’t that important. I had already spent more time on it than I wanted. So the hackintosh was a no go for the time being. Much to my dismay, my frustration with OS X wasn’t over just yet.

As I said at the beginning of this post, yesterday I decided to dabble in OS X once again. I borrowed my brother’s MacBook Pro and tried my hand at getting used to common tasks. I eventually decided to install a trial of Photoshop CS4 and restarted. Here’s where the trouble begins.

The MacBook started up, and I thought everything would be fine. It was then that I realized that the gray boot screen lacked the normal Apple logo and replaced it with a blinking folder labeled with a question mark. The MacBook wouldn’t start up. All I’d done is install a Photoshop trial.

Looking further into it, I found that this icon meant that either 1) the OS couldn’t find the boot volume or 2) the hard drive failed. The latter didn’t seem too viable, as I hadn’t done anything to cause that, so I assumed the former. But of course, the solution to this problem was to boot from an OS X install disc — something I didn’t have — and run some diagnostics. Being a long-time Windows user, I was seasoned in this type of troubleshooting. However, I had always had an install disc — and even if I didn’t, there were other bootable recovery CDs out there (UBCD, DiskInternal Boot CD). So I didn’t have an install disc for OS X. What now? Look for a free recovery CD image, of course. Well, I tried that and let me tell you that it was not pleasant. My first discovery was Carbon Copy Cloner. The idea behind this solution was to back up everything on the MacBook by cloning the hard drive, then booting externally. I didn’t really know how it would work, but I didn’t have to worry about it — the image provided on CCC’s website was a .dmg (and remember, I have NO macs to use now and .dmg management on Windows is hell). So CCC was out of the question. Then I looked into some other recovery options: TechTool Pro and DiskWarrior. Awesome. But then I realized that these programs were FOR OS X and I had to install them in order to create a bootable recovery disc. I didn’t have a mac onto which install them!!! So toss those off to the side; they won’t work. Finally, I tried making a bootable OS X install USB again in GParted. This just didn’t work out. I didn’t know whether to use an MBR or GUID partition table, didn’t know how to write my Leopard image to the USB within Windows or Linux (constant errors), and figured it wasn’t worth the time if it can be done so easily in OS X (http://www.maciverse.com/install-boot-os-x-leopard-from-a-usb-flash-drive.html). At this point, hope was dwindling. I did something I thought I’d never EVER do in a million years.

I went to BEST BUY — yes, the store I haven’t entered in 5 years — to go buy OS X. I cringe at the thought. If there’s one thing you /wouldn’t/ think I’d do, it’s that. But I just couldn’t think of what else to do. I figured dropping $30 on something that *might* solve my problem wouldn’t be too bad. But of course, being Best Buy, they didn’t have the item they listed as in-stock online. And lucky they didn’t, because I just saved $30 and was about to learn how to fix the problem.

A week prior to this happening, I had installed Ubuntu 9.10 on my Thinkpad. This was a direct result of not being able to install OS X on it. So OS X went out, Linux came in. And as I was looking up ways to fix this problem, I thought, “Wait. Why don’t I boot an Ubuntu LiveCD on the MacBook?” I couldn’t believe I didn’t think of this earlier. By booting via LiveCD, I’d be able to see if all of my brother’s data was still in-tact. It worked. I booted via LiveCD and confirmed that everything was still there. So now I just had to fix the volume holding OS X. I’ve provided an entire log of my terminal session below to show exactly what I did.

Repairing:

## Booting from Karmic 9.10 LiveCD
## In order to read the HFS+ file system (aka Mac OS Extended) used by OS X,

ubuntu@ubuntu:~$ sudo apt-get install hfsprogs
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Couldn’t find package hfsprogs

## Repositories weren’t configured correctly to find the hfsprogs package
## Why?
## Booting from a LiveCD renders the repository source.list very limited
## Uncommenting some lines made some repositories active.

## Backup repository sources list while preserving file attributes (default: mode,ownership,timestamps)

ubuntu@ubuntu:~$ sudo cp -p /etc/apt/sources.list /etc/apt/sources.list.backup

## Install vim because I like it

ubuntu@ubuntu:~$ sudo apt-get install vim
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
vim-runtime
Suggested packages:
ctags vim-doc vim-scripts
The following NEW packages will be installed:
vim vim-runtime…
BLAH BLAH BLAH, more install output

## Edit repositories list and uncomment all lines

ubuntu@ubuntu:~$ sudo vim /etc/apt/sources.list
ubuntu@ubuntu:~$ sudo apt-get install hfsprogs
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Couldn’t find package hfsprogs

## Whoops. Looks like I forgot to update the repositories. :P Let’s do that now.
## Note: Internet connection was needed. Wireless surprisingly worked no problem.

ubuntu@ubuntu:~$ sudo apt-get update
Ign cdrom://Ubuntu 9.10 _Karmic Koala_ – Release i386 (20091028.5) karmic/main Translation-en_US
Ign cdrom://Ubuntu 9.10 _Karmic Koala_ – Release i386 (20091028.5) karmic/restricted Translation-en_US
Get:1 http://security.ubuntu.com karmic-security Release.gpg [189B]
Ign http://security.ubuntu.com karmic-security/main Translation-en_US
Hit http://archive.ubuntu.com karmic Release.gpg
Get:20 http://archive.ubuntu.com karmic-updates/restricted Sources [14B]
Get:21 http://archive.ubuntu.com karmic-updates/universe Packages [72.1kB]
Get:22 http://archive.ubuntu.com karmic-updates/universe Sources [17.5kB]
Get:23 http://archive.ubuntu.com karmic-updates/multiverse Packages [6,942B]
Get:24 http://archive.ubuntu.com karmic-updates/multiverse Sources [3,831B]
Fetched 8,648kB in 10s (833kB/s)
Reading package lists… Done

## Install hfsprogs

ubuntu@ubuntu:~$ sudo apt-get install hfsprogs
Reading package lists… Done
BLAH, BLAH, BLAH
Setting up hfsprogs (332.14-7) …

## Run fsck on the OS X partition (sda2) to check the HFS+ file system for errors

ubuntu@ubuntu:~$ sudo fsck.hfsplus -f /dev/sda2
** /dev/sda2
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking multi-linked files.
** Checking Catalog hierarchy.
** Checking Extended Attributes file.
** Checking volume bitmap.
** Checking volume information.
** The volume Macintosh HD appears to be OK.

## Seems to be okay…let’s try mounting it to see if all the data’s still there

ubuntu@ubuntu:~$ sudo mkdir /mnt/apple
ubuntu@ubuntu:~$ sudo mount /dev/sda2 -t hfsplus -o rw /mnt/apple
ubuntu@ubuntu:~$ cd /mnt/apple
ubuntu@ubuntu:/mnt/apple$ ls
Applications cores etc mach_kernel private Users
_b_ Desktop DB Extra mach_kernel.ctfsys sbin usr
bin Desktop DF home net System var
boot dev Library Network tmp Volumes

ubuntu@ubuntu:/mnt/apple$ cd Volumes
ubuntu@ubuntu:/mnt/apple/Volumes$ ls
Macintosh HD

## ^ looks like everything is still there.
## So let’s unmount it and do another fsck, rebuilding the catalog b-tree with -r

ubuntu@ubuntu:/mnt/apple/Volumes$ cd Macintosh\ HD
ubuntu@ubuntu:/mnt/apple/Volumes/Macintosh HD$ sudo umount /dev/sda2
ubuntu@ubuntu:/mnt/apple/Volumes/Macintosh HD$ cd /
ubuntu@ubuntu:/$ sudo fsck.hfsplus -r /dev/sda2
** /dev/sda2
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Rebuilding Catalog B-tree.
** Rechecking volume.
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking multi-linked files.
** Checking Catalog hierarchy.
** Checking Extended Attributes file.
** Checking volume bitmap.
** Checking volume information.
Invalid volume file count
(It should be 630434 instead of 611271)
Invalid volume directory count
(It should be 166625 instead of 159942)
Invalid volume free block count
(It should be 8523758 instead of 12930181)
Volume Header needs minor repair
(2, 0)
** Repairing volume.
** Rechecking volume.
** Checking HFS Plus volume.
** Checking Extents Overflow file.
** Checking Catalog file.
** Checking multi-linked files.
** Checking Catalog hierarchy.
** Checking Extended Attributes file.
** Checking volume bitmap.
** Checking volume information.
** The volume Macintosh HD was repaired successfully.

It looked like it was repaired, so I restarted and still got the question mark folder. Looking back on it, the above didn’t really do much. It was not until I booted rEFIt that it was fixed. I downloaded rEFIt (luckily there was an option to download a .cdr image — that just had to be renamed to .iso), burned it, and booted from the CD. I then ran the rEFIt partitioning tool and simply updated the MBR (not my image). I rebooted and everything worked.

Conclusion:

I can’t tell you if the fsck did anything useful. I’d like to think it played some part in the fix. And even if it didn’t, I learned a ton from just going through with this process. That’s the beauty of messing something up: you’re forced to fix it and learn new things. It’s great. I don’t know WHY it messed up in the first place, but I went through a process of trying new things and becoming more familiar with the Unix shell.

In the end, I found myself using Linux much more. I’ve dabbled in Linux tons of times before, but I always found myself falling back to Windows. However, for the past week, I’ve been using Ubuntu and it’s been great. I’ve learned more about navigating a Linux system in a week than I have in my entire life — all just by using Ubuntu as my primary OS. I’ve also got a CentOS box set up to get a taste of the Red Hat-type environment. Consider me converted.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • TwitThis
  • Facebook
  • StumbleUpon
  • Reddit
  • Digg
  • del.icio.us
  • Google
  • Technorati
Leave a Reply