Couple of days ago a cousin of mine told me that her laptop, Macbook pro, couldn’t boot. This is the process I followed to restore. Just to remember it in case I need to do it again.
The laptop could pass the gray screen with the spinning circle (picture bellow). The first thing I did was to see what happens during boot. I restarted the laptop and pressed Command-V, just after the booting sound, to enter verbose boot. The system was running fsck for the boot hard drive. fsck was trying to Rebuilding catalog B-tree. After a while it would fail with: The volume Macintosh HD could not be repaired. After that it would just wait.
I restarted it in recovery mode by pressing Command+R. There was no recovery partition to the disk, so the process had to download everything using an internet connection.
I used the Disk Utility. No luck. It was just trying to fsck the disk. I couldn’t even to mount the disk and make a back up of the files. The next reasonable thing was to remove the disk and try mounting it with my desktop computer. The removal of the disk is quite easy. Connecting the disk to the desktop was trivial also. You don’t need any usb-to-sata adapter. Even the 2.5 inch disks use standard sata connectors. So, plug the disk directly to the motherboard.
GNU/Linux mounted the disk without any problems. I copied the entire /Users directory to another disk. After securing the data I became more aggressive with the disk. I tried the GNU/Linux version of fsck. The result was exactly the same. The volume Macintosh HD could not be repaired. Witch make sense since the HSF/HSF+ user space utils is Apple’s code (hsfprogs). I tried many things without success. Searching around for a solution one thing was always popping-up. DiskWarrior. DiskWarrior is a commercial software made by AlSoft that repairs Mac OS X disks. I cost’s 100 usd. It is a DVD you can boot from.
I reinstalled the disk to the laptop and started it again. After the boot sound I pressed C to boot from the DiskWarrior dvd. After about 5 minutes the boot was completed. I selected the disk and pressed Rebuild. After couple of minutes the disk was ready as the software stated. I don’t know what AlSoft knows for Apple’s file system that Apple doesn’t…
I rebooted the laptop and… Voilà! I passed the boot process and I was presented with the user login screen. I pressed the code and tied to login. After a frame of a whit screen I was again presented with the login screen. I could login! It was reading the password correctly. If a wrong password was entered there was the text box shaking.
Something must be corrupted for the user. I rebooted and entered single user mode by pressing Command+S, in order to clear caches. After booting I used the following command to mount the disk.
mount -uw /
After that I deleted the contents o /Library/Caches and ~/Library/Caches and tried to login once again. Nothing, the same behavior. Booted again to single user mode, mounted the disk and renamed the Prefernces and LaucnhAgents folders (located under /Users/username/Library) and created empty ones. Still, no successful login.
Once again Boote to repair mode and tried a Repair permissions. Still no login. After that I tried to make a new user to test. Booted to Single Use Mode again and did the following.
mount -uw /
launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist
dscl . create /Users/alexander
dscl . create /Users/alexander UserShell /bin/bash
dscl . create /Users/alexander RealName “Alexander”
dscl . create /Users/alexander UniqueID 503
dscl . create /Users/alexander PrimaryGroupID 1000
dscl . create /Users/alexander NFSHomeDirectory /Local/Users/alexander
dscl . passwd /Users/alexander MY-PASSWORD
dscl . append /Groups/admin GroupMembership alexander
Now at the login screen there was the user alexander. Selected the new account, entered my password and… No luck. Still a white screen splash and back to the login screen. The error must be more deeply in the operating system. I had no time available to start going through log files. Once again I rebooted in Recovery Mode (Command+R). I selected Reinstall Mac OS X. After the verification with Apple server’s it started to download the OS. I was unsure for the final result. I had never reinstall Mac OS X before. Will it erase everything?
After two hours of downloading and installing the operating system, it asked for a final reboot. Once again I entered the user password and pressed Enter. The “gay” spinning disk came up and after couple of second it logged me in successfully!