In my previous post, I alluded to a tool that we use to make NetBooting different machines with their correct OS quite a bit simpler. Here's what it is and how to use it. But first a few words about my workflow:
The Setup
-
We collect CPU installation media from customers and resellers and then rip them to the file server. I rip both disks into a folder named after the “mnemonic” name of that machine. For instance, “MacBook Pro (15-inch, Late 2008)” becomes “mbp_15_l08” etc.
-
I then use System Image Utility to create NetInstall sets of all ripped images and name the .nbi's according to the machine's hardware “model”, for instance “mbp_15_l08” then becomes “MacBookPro5,1”. You can read the model of a machine either from Mactracker, System Profiler or simply:
$ sysctl -n hw.model MacBookPro3,1
-
The reason I use two different naming schemes is because the first makes the images easy to browse for technicians and the second makes them easy to match to a specific machine (the first is easy to remember for humans, the second for machines, if you will)
-
The NetInstall sets are then transfered to a folder where they are accessible to NetBoot (see my previous post for specifics).
Making it Run
With things organized this way, it's now very simple to match any machine to it's corresponding installation media. To automate this, I created a tool that consists of two parts:
- A web service (which runs on the NetBoot server) that lists all the available NetInstall sets
- A command-line tool (essentially just a wrapper for bless) that can query the web service and set the appropriate boot args for a given NetInstall set
The web service couldn't be any simpler, it just lists the available NBIs:
<?php
$datadir="/data/nb";
header("Content-type: text/plain");
foreach (glob("${datadir}/*.nbi") as $nb)
{
$images[] = basename($nb);
}
echo implode(" ", $images)
By default, the client-side tool tries to match the current machine to a set on the server:
$ sudo ./netbless.sh
Error: model MacBookPro3,1 not found on the NetBoot server
… meaning I haven't ripped the media for this machine yet. In these cases I can force the tool to use a specific NBI. To do that, I'll probably need to know what is available:
sudo ./netbless.sh list
Available images: 10.5.6_retail.nbi MacBook3,1.nbi MacBook7,1.nbi MacBookAir2,1.nbi MacBookPro5,2.nbi MacBookPro6,2.nbi MacBookPro7,1.nbi Macmini3,1.nbi Macmini4,1.nbi boot.nbi iMac11,3.nbi retail_10.6.3.nbi retail_10.6.3_2.nbi
So, to boot to the 10.5.6 installer, I would say:
sudo ./netbless.sh 10.5.6_retail
The script makes some assuptions (for instance of the NetBoot and web services being on the same server) but is general enough to customise it to any environment. If you're image library is comprehensive enough, using netbless is usually just a matter of:
$ sudo ./netbless && reboot
And yes, using this requires a bootable system to start with (say your known-good diagnostics partition). Ideally, netbless would be an EFI-binary that you could run off a memstick, without an OS, but my EFI-programming skills aren't quite up to snuff yet…