How to make BSDP NetBoot image selection from a script on OS X 10.9+

dhcpmac-osxnetbootscripting

Background:
BSDP is Apple's protocol used to discover and make selections on NetBoot servers on the network (Not to be confused with PC-style PXE boot). specs (Word doc). Long story short – it's a protocol that sits above DHCP, using INFORM messages to pass information between client and server.

I need to automate an environment where test machines will be booting different boot images on the network. The simplest way (for me) to do this is to perform a boot image selection from a script running on the client. This is, from the server's and network's view equivalent to selecting the boot image in System preferences -> Startup disk

I found references to bsdpc, an old utility from Apple which is no longer part of any standard OS X installation, or Server version/package I could get my hands on.
Its source is available from Apple here, but the code doesn't build using the standard SDK, and I can't find any information as to which libraries/versions are necessary to build it successfully.

Can anyone suggest an easy solution? At this point I'm not sure if trying to get Apple source to compile is actually easier than writing a client from scratch.

Best Answer

Disclaimer: I haven't tested this, and it's mostly taken this JAMF Nation discussion, with some additional notes from an old AFP548 article.

You need to use the bless command (which is part of the standard OS X install). The simple format for configuring NetBoot is:

sudo bless --netboot --server bsdp://${ipAddress}

... but unfortunately that only configures the address to send BSDP queries to; if you have more than one NetBoot image served from the same server, it doesn't let you specify which one to use. (I think it'll use whichever's defined as the default in the server's settings). The obvious way to specify a particular image is by its image ID number... but I can't find a way to set that on the client.

What you can do is bypass BSDP entirely, and tell the client where to get the actual boot resources (i.e. give it the info it'd normally get in the BSDP response):

bless --verbose --netboot \
    --booter "tftp://${ipAddress}/NetBoot/NetBootSP0/${nbiName}/i386/booter" \
    --kernelcache "tftp://${ipAddress}/NetBoot/NetBootSP0/${nbiName}/i386/x86_64/kernelcache" \
    --options "rp=nfs:${ipAddress}:/private/tftpboot/NetBoot/NetBootSP0:${nbiName}/${dmgName}"

Note that the last command assumes you're booting a 64-bit kernel (all 10.9 comes with), it's a true NetBoot (i.e. not NetInstall or NetRestore) image, and that you're serving it over nfs rather than HTTP (my recommendation; I keep running into problems with HTTP-served images, even though Apple made that the default a few versions ago). If you need some other variant, check the JAMF Nation link for more options and/or try configuring one client manually and then use nvram -p to see what the resulting raw firmware settings are (see the AFP548 link).

Related Topic