Recently I had the rare opportunity to tackle a serious problem with a Macbook Pro. For some reason an update locked up midway through and the owner had no choice but to shut the laptop off abruptly after it had been siting on for several hours not making any progress in the update and with no available option to cancel/revert. I suspect the hard drive is beginning to wear out and failed to read/write something important, locking the system up completely. When they attempted to power their system on next time it remained stuck with the startup screen (Apple Logo with the rotating “gears” below).
Apple includes a copy of their OS on discs you can boot from to run the included Disk Utility. This checks the file system for integrity issues, file permission errors and corrects them for you. Unfortunately doing this did not solve this particular problem and the laptop remained stuck. Even booting into MacOS’s “Safe Mode” (by holding down SHIFT right after the startup chime is heard) didn’t work.
Most guides I’ve found on the Internet will tell you to send the system to an Apple Expert at this point. While there is a slim chance they might be able to revert the changes or correct the problem that’s causing a system to lockup while booting, an alternative approach is to do what is termed a “destructive recovery”, where the hard drive is erased and the OS reinstalled on a clean slate so to speak. Before you do that of course you’ll want to pull your own personal files/data off the drive. You can’t do this with the Disk Utility provided by the MacOS install discs, but there is another “utility” that’s totally free to download that you can do this with: Ubuntu Linux.
What You Need
1. A blank CD
2. Another computer to burn that CD with
3. Ubuntu Linux ISO image file
4. An external hard drive (preferably one that’s formatted to Windows NTFS; I will explain why in a moment)
Burning Ubuntu to a CD
First, visit the link to Ubuntu’s website. Click the Get Ubuntu button and follow the steps to download the 32-bit version of Ubuntu. You’ll be asked to download a large (about 700MB) ISO image file. Once downloaded, you need to burn this file to a CD. If you are burning this CD with another Mac you can follow this guide that will show you how to use the built in Disk Utility app to burn the Ubuntu ISO file you have to download from www.ubuntu.com. And if you are burning with Windows, there is a “Show Me How” button you can click on at Ubuntu’s download page that will show you how to use a program called InfraRecorder to burn the ISO file.
Booting Ubuntu On Your Mac
Once the CD is burnt you will need to boot from it. I have found the best way to do this on a Mac is to turn the system on and immediately after you hear the classic “chime” sound, hold down the Option key on your keyboard. (Tip: If you are using a Mac with a Windows keyboard hold down ALT instead. Also, if you need to eject a disc from the system, hold down F12). Eventually you will see this:
If all goes well (and I can’t promise that it will but it did for me) you will see the Ubuntu boot screen appear (pictured above) with the purple background. Please be patient as this is a slow process; loading an entire OS from a CD is not a quick and snappy ordeal. Eventually Ubuntu will load up the Ubuntu installer screen. At this point click “Try Ubuntu”.
It will proceed to load the rest of Ubuntu Linux right off the disc. Eventually you will see something like this:
Accessing Your Data
First, we need to browse the hard drive inside the Mac. You’ll do this using the Places menu. When you click Places, you will see a list of several common folders like Home Folder, Pictures, etc. Look past those in about the middle of the list and you should see an item called Macintosh HD. We will mount it by clicking on it in the places menu. (Note: It would also be a good idea to repeat this step to mount the external hard drive or media you intend to copy your data on to at this time, just to get mounting it out of the way). The next thing you’ll see is the contents of the Macintosh HD volume. Unfortunately there is a lot of data in this drive that you won’t be able to access/read right away due to file ownership and permissions. But there’s a way around that.
You need to gain full administrative access to the hard drive so you don’t have to worry about file permissions getting in the way. It is also recommended that you use an NTFS formated external hard drive for this because it will help avoid further file permission issues later down the road when you move your data back. (If you use a Linux/Unix/Mac formatted external drive the files you copy are going to change owners from you to the Linux superuser account which means you’d have to change ownership of every file after copying them, so it’s just easier to scrape all those attributes off the files by sending them to an NTFS filesystem which does not store those descriptors).
Gaining Full Administrative Access To Your Files
To gain administrative access to the hard drive and browse the contents, click Applications>Accessories>Terminal in the upper left. A new window will appear with a black background and white text. From here type:
…and press the Enter key. This will open the Nautilus file browser as the SuperUser (aka, “root” user). It is exactly the same window you saw open when you mounted the drives from the Places menu, but keep in mind that this new file browsing window that has appeared is the ONLY window with root access. Any others that were already open are still running at the standard user level, so you can’t drag files from the super users browser to any others unless you open a second terminal window and start a second instance of Nautilus in the same manner. But it’s pretty easy to do all the browsing you need with the one window using the Edit>Copy and Edit>Paste menu options.
Note: The rooted instance of Nautilus will only let you browse volumes that have already been mounted. If you’ve not already accessed your external hard drive or the Macintosh HD hard drive using the Places menu as mentioned earlier, do so now and then close or minimize those windows to get them out of the way, leaving the super-user instance of Nautilus running up front.
Copying Your Data
Once you’ve started the Nautilus file browser as the super-user, you can click on “Macintosh HD” in the left hand side of the Natilus window to begin browsing your hard drive. For most users the most important data is going to be stored in the Users folder. Simply scroll through the Macintosh HD hard drive to find a folder called Users. If you browse through it a little you will quickly be familiar with the files you are looking at inside the Users folder. You just need to copy everything out to the external hard drive. To makes things simple and quick it’s easy to just copy and paste the entire Users folder to an external hard drive (as mentioned, NTFS drives are recommended purely to make the copying of data back to the computer easier after the OS has been reinstalled).
Also note: Stopping after the Users folder alone may not be adequate enough for some advanced users who may have data stored in other folders, such as the /var folder if the system was an Apache server. Details about where your production/business critical data is auto-saved should be researched from the developers/publishers of said software or their respective README.txt/help documentation before proceeding to format your hard drive as all data will be lost after formatting. In almost all cases everything will be in the Users folder, but fair warning to you if you are not certain. For more information, refer to this official help article about application data storage locations. By the way, the ” ~/ ” folder they refer to is shorthand for “your home folder”, which is inside the Users folder; you will find that everything they list is stored somewhere in there so you should be good with not copying anything else.
Reinstalling Mac OS
Now with all the user data backed up on an external hard drive you can restart the system with your original Mac OS install discs and proceed to use the Disk Utility to erase and re-format the hard drive and then proceed with installing the OS on a fresh partition. Just press that Option key again to bring up the boot menu and boot from the MacOS install disc 1. I would strongly recommend searching for and installing any and all available updates available for the OS and software before moving data back to the computer.
Moving Your Data Back
I have found that moving data back isn’t going to be as simple as moving the entire Users folder at once because Mac doesn’t like to let you merge folders. You will be able to copy and paste the files and folders in groups to get everything back to where it was originally. Alternatively you can use this tool called Folder Merge for Mac to help you copy all your files and folders back into place while skipping the ones that can’t be overwritten in their place.
If all goes well, you should be able to backup the data from your Mac and reinstall the OS in a matter of about 3 hours, most of which is a just a matter of sitting and waiting for things to finish.
Troubleshooting: What if the drive isn’t shown?
In newer versions of Ubuntu (verions 11.04 and newer) the new Unity desktop interface is used, so there is no Places menu to open up. However, you can still open your Nautilus file browser by clicking on the Home Folder icon. Once open, look along the left side of the screen to see if your drive is shown among the other popular locations.
If it is not shown it may be necessary to mount the drive manually via a terminal window. To open a terminal in Ubuntu 11.04 or later, click the Ubuntu button at the top of your dock bar to open the search panel and type in “Terminal”. You’ll see the shortcut for Terminal appear which you can just click on to open up a terminal/command prompt.
Once the terminal is open you’ll want to get a list of the drives Linux is able to see. To do this, type in the command:
sudo fdisk -l
The output will look something like this:
Starting at the top Linux is telling me that it sees an 80 gigabyte sized hard drive and has called the drive /dev/sda. Within that hard drive are three partitions, called /dev/sda1, /dev/sda2 and /dev/sda5. Below that we see there is a second 2000 gigabyte sized external hard drive and it has been called /dev/sdb, with only one partition called /dev/sdb1. If we were looking at a Mac we’d likely only care about /dev/sda partitions and would only be interested in mounting whichever of these partitions is the largest. You can quickly determine which is the largest of them all by checking under the Blocks column.
Once you’ve determined which partition is the largest we need to mount it. For the sake of example, lets pretend that /dev/sda1 needs to be mounted. Before we can do that we need to create a temporary placeholder folder for this partition to be aliased with after mounting. To create an empty folder on your desktop called “temp” you would type:
(Note: all linux terminal commands are case-sensitive). Now we can mount /dev/sda1 into this temp folder with the following command:
sudo mount /dev/sda1 ~/Desktop/temp
You can close or minimize the terminal window at this point and find the folder we created called temp on your desktop and open it. Within should be the contents of your Mac hard drive, and you can now begin copying data from there into an external hard drive or other external media. When you are finished it’s easiest to use the shut down menu in the top-right corner to shut the computer down (which will eject the disk for you). If you were successful at extracting your data the next step would be to boot from your MacOS disc and proceed with using the Disk Utility to remove/format the existing partition(s) on your Mac’s hard drive, create a new partition and install MacOS on top. I would recommend disconnecting your external hard drive before doing this so you don’t risk deleting your external hard drives partition by accident.
Saturday, July 2nd, 2011