An external hard drive containing a bootable copy of OS X is probably the most important tool for any Mac technician to have. Whether you're trying to troubleshoot a failed software update or need to install Mavericks onto hundreds of Macs, an external hard drive loaded with OS X can be just what you need to perform whatever software task might be needed.
Serving as an epilogue to our series Disk Management from the Command-Line, we'll explore how to build an external boot drive and automate the process if multiple drives are needed.
Troubleshooting Software Issues
There can be many reasons why a Mac can no longer boot correctly and it's usually software-related. Some of these reasons, in no particular order, include:
- A failed software update
- Corrupt drivers or fonts
- Deleted system files
Luckily, the Mac can boot from almost any type of external storage device, in addition to its internal hard drive, via USB, Thunderbolt or FireWire. By holding down the Alt key during boot, the Mac will display all available volumes that it can boot from.
Having an external hard drive loaded up with the installers of different versions of OS X, as well as a known-working installation of OS X, can be used to perform almost any troubleshooting task you may need by bypassing any potential software issue that the Mac is suffering from.
An external hard drive used in this manner is commonly referred to as a Triage Drive.
OS X Recovery
Since the release of OS X Lion, Apple has provided Mac users with a separate, hidden volume known as OS X Recovery. It's a very lightweight build of OS X that provides access to a small set of utilities, such as Disk Utility and Terminal, though its primary purpose is to make the reinstallation of OS X as easy as possible.
Because OS X Recovery is mainly used for installation purposes, it has to download all of the necessary files whenever this is performed. This requires both an internet connection and a great deal of time. For any Mac technicians needing to perform regular upgrades or reinstalls of OS X on many different Macs, an external boot drive can be loaded up with a full installer that is usable on multiple Macs.
Drive Contents
The triage drive we're going to build will contain the following:
- Installer for OS X Lion
- Installer for OS X Mountain Lion
- Installer for OS X Mavericks
- Bootable installation of OS X Mavericks
- Spare volume
As you may have read previously, a single hard drive can contain multiple partitions that each house a separate volume. With this, we can place individual installs of Mac OS X onto each volume to support a wide range of Macs that may not all support the same version of OS X.
Depending on your requirements, you may need a bootable installation of OS X Lion or Mountain Lion. Each person's requirements will likely be different so I'll just demonstrate how to build a basic triage drive that you can build upon.
Finally, it will be assumed that you have previously purchased OS X Lion and Mountain Lion, or at least have the full installer app available within your Applications folder.
If you have purchased the installers previously but no longer have them on your Mac, launch the Mac App Store and select the Purchased tab. From here, they can still be downloaded.
Depending on the age of your Mac, you may not be able to download older installers for OS X if your Mac is relatively new. I was unable to download OS X Lion on my Retina MacBook Pro, instead greeted with an error message.
Should this occur, you'll need to sign in to the Mac App Store on another, older, Mac and download the installer on it first.
Interface Options
I'm using a 120GB USB drive for the purposes of this guide. While most Macs can boot from Thunderbolt or FireWire, USB is the only ubiquitous interface that every Intel Mac includes, so there's no point using anything else other than USB. I'd also recommend using a USB 3.0 drive since it's exceedingly fast yet still backwards compatible with Macs containing USB 2.0 ports, while still being much cheaper than their Thunderbolt equivalents.
Partitioning the Triage Drive
The triage drive needs to be split into five partitions, each formatted with a volume. While we could easily use Disk Utility to do this, we'll use the command-line as we'll be looking at automating this process later.
First, find out the disk identifier using diskutil list
.
The disk identifier for the drive I want to use is disk2
, so the command to use would be:
diskutil partitionDisk /dev/disk2 GPT JHFS+ Lion-I 10g JHFS+ MountainLion-I 10g JHFS+ Mavericks-I 10g JHFS+ ExBoot 40g JHFS+ SpareVolume 0b
This will create the five volumes required and name them accordingly. I've given them rather unique names to set them apart, but if you do happen to have any volumes with the same name then update the following commands accordingly.
Copying the Installers
With the hard drive partitioned, it's time to copy the installers required onto each respective volume.
The installers for both OS X Lion and Mountain Lion include a Disk Image (DMG) file that can be restored to a volume and turn it into a fully-bootable installer that doesn't require an internet connection to download additional files.
Copying OS X Lion
To see where the installer is located from within the Finder, right-click on it and select Show Package Contents. The installer is located at Contents/SharedSupport/InstallESD.dmg
We can restore this to the triage drive using asr
. Using the following command, we can restore the DMG to the relevant volume.
sudo asr restore -source /Applications/Install\ Mac\ OS\ X\ Lion.app/Contents/SharedSupport/InstallESD.dmg -target /Volumes/Lion-I -erase -noverify -noprompt
Once the restore process has finished, you'll now see a volume labelled Mac OS X Install ESD. We'll need to rename this since the restore for OS X Mountain Lion creates a volume of the exact same name, making it somewhat confusing.
Renaming the volume can be done using the command:
diskutil rename "Mac OS X Install ESD" "Lion-I"
The restore process also sets the volume's boot label (the name displayed at the boot menu if Alt is held) to "Mac OS X". Renaming the volume name doesn't change the boot label as well, but it's easily changed by using the bless
command:
sudo bless --folder "/Volumes/Lion-I" -label "Lion Install"
Copying OS X Mountain Lion
Restoring the installer for OS X Mountain Lion is exactly the same as OS X Lion, only we need to update the command with the correct path.
sudo asr restore -source /Applications/Install\ OS\ X\ Mountain\ Lion.app/Contents/SharedSupport/InstallESD.dmg -target /Volumes/MountainLion-I -erase -noverify -noprompt
Again, once the restore has been complete then we will be left with a volume named Mac OS X Install ESD. Rename this with:
diskutil rename "Mac OS X Install ESD" "MountainLion-I"
Restoring the Mountain Lion installer also sets the boot label for the volume to "Mac OS X". Change it using:
sudo bless --folder "/Volumes/MountainLion-I" -label "Mountain Lion Install"
Copying OS X Mavericks
Unlike with Lion and Mountain Lion, the process for OS X Mavericks is somewhat different. The DMG required is no longer InstallESD.dmg but is now called BaseSystem.dmg, though it's buried within another DMG file.
While it's still possible to use asr
to restore the installer to the drive, we can make use of a new command within the OS X Mavericks installer called createinstallmedia
, offering the same functionality as asr
when it comes to restoring a fully-installable version of Mac OS X.
The createinstallmedia
command's structure is similar to asr
as you need to specify a volume to restore to, referred to as --volume
.
Even though the command is found within the OS X Mavericks installer, it doesn't know that. You still need to specify the installer's location using --applicationpath
.
sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/Mavericks-I --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction
Unlike OS X Lion and Mountain Lion, the name of the newly restored volume is more identifiable. But since we'd prefer to keep the naming convention manageable, let's rename this as well:
diskutil rename "Install OS X Mavericks" "Mavericks-I"
The Mavericks installer's boot label is more recognisable as it is the same as the volume name created. But let's change it anyway to standardise the naming across all the volumes.
sudo bless --folder "/Volumes/Mavericks-I" -label "Mavericks Install"
Bootable OS X
With the three installers complete, we can test if the triage drive works by completing the final part of this guide - performing an install of Mavericks onto the volume ExBoot.
Installing OS X to ExBoot
Switch your Mac on and hold down the Alt key. Eventually, you should see an icon of the Mac's built-in hard drive displayed. Once you do, connect the triage drive and wait a few moments for the volumes to appear then select Mavericks Install.
If everything is working, you should be able to perform an install of OS X Mavericks to the volume ExBoot from the triage drive.
Creating a Restore Image of ExBoot
With a working installation of Mac OS X on the triage drive, it's best to create a disk image of it before making any changes or putting it to use. This way, if you want to create more triage drives or restore the whole drive back to a specific state, you've already got a working installation ready.
To create a disk image of the volume ExBoot, use hdiutil
to create a disk image:
sudo hdiutil create ~/Desktop/exboot.dmg -srcfolder /Volumes/ExBoot
Once complete, you now have a working installation of Mac OS X to restore whenever setting up triage drive.
Automating the Process With a Shell Script
Creating a triage drive is relatively straightforward but if you needed to set up a number of triage drives or want to regularly restore one back to a known-working state, it can be a bit tedious to repeatedly enter these commands every time.
Instead, we can combine all of them together inside a shell script and have it do all of the work for us.
Below is a copy of an example script called Triage Drive Creator. To use it, connect the drive you wish to use and then run it from the command-line.
The script runs diskutil list
first and asks you to specify the number that corresponds to the disk. This number is stored as a variable and used during partitioning so that you won't inadvertently wipe the wrong drive.
For example, if you want to use a disk located at /dev/disk2
, then just enter 2.
The rest of the script then copies the installers, renames the volumes and sets the boot labels automatically.
Wrapping Up
With a few basic commands and some planning in advance, building a triage drive is something that every Mac technician can do. The benefits of having multiple installers for different versions of Mac OS X, as well as a fully bootable installation that is free from any problems, is a powerful tool in the Mac support arsenal.
The shell script provided only covers the commands found in this guide but there are plenty of different options to consider that would add further functionality. Try to find a way of having the shell script eject the drive once complete or be able to also restore a working install of OS X (hint: you'll need to create a disk image from one, beforehand).
You can purchase the complete guide to Disk Management From the Command-Line that includes Building an OS X Triage Drive as an ebook in ePub and PDF format for just $0.99.