More Netboot Shenanigans: Mac network boot without a netboot server

Sometimes you want to boot a Mac from the network without running a netboot server. You already have a TFTP server set up, and the root image is sitting on a HTTP server. The only missing piece of the puzzle is how to get the Mac to boot from the network.

One option is to deploy an Apple netboot server.

Another option is to fudge it using a Linux DHCP server.

However, if you can’t do either of those things (or if you just don’t want to), then you only other option is to inject it directly into the Mac’s firmware settings.

Fortunately, the bless command has some undocumented arguments to make this easier.

This document assumes you have a netboot bundle on a server somewhere, and HTTP and TFTP already configured.

Netboot bundles will typically contain the following components:

  • booter: i386/booter
  • kernel: i386/mach.macosx and/or i386/x86_64/mach.macosx
  • mkext: i386/mach.macosx.mkext and/or i386/x86_64/mach.macosx.mkext
  • kernelcache: i386/kernelcache and/or i386/x86_64/kernelcache
  • root filesystem image: NetInstall.sparseimage and/or NetRestore.sparseimage

OS X 10.6 bundles typically have a booter, a kernel, and a root filesystem image. The bless command looks like this:

sudo bless --netboot \
   --booter tftp://server/path/to/i386/booter \
   --kernel tftp://server/path/to/i386/mach.macosx \
   --options rp=http://server/path/to/NetInstall.sparseimage

The mkext doesn’t need to be specified; the firmware attempts to load it automatically.

This is explained in further detail in the Mactips article How to NetBoot Across Subnets.

Some time around 10.7 or 10.8, Apple removed the kernel and replaced it with the kernelcache:

sudo bless --netboot \
   --booter tftp://server/path/to/i386/booter \
   --kernelcache tftp://server/path/to/i386/x86_64/kernelcache \
   --options rp=http://server/path/to/NetInstall.sparseimage

However, what if you want to boot to a Mountain Lion netboot image from Snow Leopard? Unfortunately, the bless command in Snow Leopard does not support the --kernelcache option, and if you specify the kernelcache in the --kernel option, then the firmware treats it as a kernel, which fails.

To get kernelcache working from Snow Leopard, you need to get creative:

sudo bless --netboot \
   --booter tftp://server/path/to/i386/booter \
   --kernel tftp://server/path/to/i386/x86_64/kernelcache \
   --options rp=http://server/path/to/NetInstall.sparseimage
sudo nvram "$( sudo nvram efi-boot-file \
   | sed -E 's/^efi-boot-file[[:space:]]*/efi-boot-kernelcache=/' )"
sudo nvram -d efi-boot-file

This command uses bless to put the kernelcache into the wrong nvram variable. Next, it uses the nvram command to copy the kernelcache into the correct nvram variable. Finally, it uses the nvram command to delete the incorrect variable.

The end result is the same as if the --kernelcache option was used in Mountain Lion.