|
mac geekeryGet your geek on. |
Make any Mac a NetBoot ServerMarch 27, 2006 - 8:32pm
Have you ever thought that having that emergency partition on your desktop was hackish and ugly? Or have you thought that it would be truly handy to have a boot DVD available via NetBoot for recovery purposes? Well, good news, Mac OS X can act as a NetBoot server just as well as Mac OS X Server itself can. All a Mac needs to NetBoot is a server running TFTP and either NFS or HTTP, and all are built in to a normal Mac OS X machine. In fact, any machine that can serve those basic protocols can be a NetBoot server. The reason one would prefer a Mac for this is because Apple has a protocol called Boot Service Discovery Protocol (BSDP) that it built into its bootpd server. While this is not strictly required for NetBoot, it is the protocol that makes the image show up in the Startup Disk preference pane and that simply makes life easier (you’ll see how much easier when I explain the alternative). Even better, Apple went as far as to document most of how to do this process in the manpage for bootpd. Some things are missing, but I hope this guide will clear those things up. And for good measure, I’ll show you how to do this without having to use BSDP at all (Debian NetBoot server, anyone?). Getting StartedNow, there are several ways of doing this and they depend on what you have at your disposal. If you have a copy of Mac OS X Server, then stop reading this and refer to the System Imaging Admin Guide for how to make a NetBoot image and serve it the really, really easy way. Yet, if you have a pair (or more) of Macs running Mac OS X (or a machine running Darwin) and plan on using one that’s not running Mac OS X Server to host this, then read on and use the easy way of making and serving the image. If you plan on serving the image from a machine based on an OS other than Mac OS X or Darwin, then you’ll want to follow the more in-depth steps and, hopefully, you know how to setup TFTP and NFS on your server. The Easy WayThe easy way works for people with multiple Macs who just want one machine to serve up an image or two. It could also work for large organizations that want to load-balance their NetBoot service without the expense of multiple NetBoot servers. Granted, you will loose the ability to easily manage those remote servers (that’s what you’re paying for with Mac OS X Server), but if you just want a remote mirror, then this works. All of the following commands must be done as root. Create the NetBoot Share DirectoriesNetBoot images must be kept together for various reasons, so we create two directories in /Library/NetBoot to store the various parts of this. The first is the NetBoot share point, mkdir -p /Library/NetBoot/NetBootSP0 mkdir /Library/NetBoot/NetBootClients0 chown root:admin NetBoot* chmod 775 NetBoot* Now, the names for the shares are not hard-coded into bootpd[9656]: bsdpd: no client sharepoints defined bootpd[9656]: bootpd: NetBoot service turned off So, create both folders and link both folders as follows, even if you won’t be using diskless NetBoot: ln -s /Library/NetBoot/NetBootSP0 /Library/NetBoot/.sharepoint ln -s /Library/NetBoot/NetBootClients0 /Library/NetBoot/.clients Configure and Enable NFSLike most services in Mac OS X, NFS is a bastardized version that gets its configuration out of NetInfo rather than an exports file. That said, NetInfo is easy to setup for something like this. You could use NetInfo Manager, but that just takes all the fun out of this, so here’s how to do this with nicl . -create /exports nicl . -create /exports '\/Library\/NetBoot\/NetBootSP0' nicl . -create '/exports/\/Library\/NetBoot\/NetBootSP0' opts ro Now that the path is exported to world, you want to start NFS. To do so, follow these steps in their exact order: service com.apple.portmap start mountd nfsd -t -u The Setup AFPDiskless NetBoot requires an AFP connection to the server for the clients directory, and System Image Utility can push an image to a server over AFP if the share is setup right. So, we set them both up right so you can do both things. nicl . -create /config/SharePoints/NetBootSP0 nicl . -create /config/SharePoints/NetBootSP0 afp_name NetBootSP0 nicl . -create /config/SharePoints/NetBootSP0 afp_shared 1 nicl . -create /config/SharePoints/NetBootSP0 afp_guest 0 nicl . -create /config/SharePoints/NetBootSP0 directory_path /Library/NetBoot/NetBootSP0 nicl . -create /config/SharePoints/NetBootClients0 nicl . -create /config/SharePoints/NetBootClients0 afp_name NetBootClients0 nicl . -create /config/SharePoints/NetBootClients0 afp_shared 1 nicl . -create /config/SharePoints/NetBootClients0 afp_guest 0 nicl . -create /config/SharePoints/NetBootClients0 directory_path /Library/NetBoot/NetBootClients0 Now turn on AFP in the Sharing preference pane. If it was already on, the changes are immediate. Configure and Enable TFTPTFTP is used to distribute the boot loader and kernel to the client system. We need to make some things work as expected here for NetBoot to send the right files to the client. While you could symlink the whole /Library/NetBoot folder to /private/tftpboot and it would work, that would also mean you couldn’t add other share points in there from other partitions. I’m all about the flexability, so run the following to setup the tftp root and then start the service: mkdir /private/tftpboot/NetBoot ln -s /Library/NetBoot/NetBootSP0 /private/tftpboot/ service tftp start Configure and Enable BSDPAll the hard work has been done, so there’s just a couple of final steps to getting nicl . -create /config/NetBootServer nicl . -create /config/dhcp netboot_enabled en0 service bootps start Now, check your bootpd[461]: interface en0: ip 10.0.1.4 mask 255.255.255.0 bootpd[461]: server name mymac.local bootpd[461]: subnets init using domain . failed: bootpd[461]: bsdpd: re-reading configuration bootpd[461]: bsdpd: shadow file size will be set to 48 megabytes bootpd[461]: bsdpd: age time 00:15:00 Download and Install the Admin ToolsApple provides the Server Admin Tools as a free download. Mostly these tools interact with the server processes Create the NetBoot ImageThere are many types of NetBoot images we can make with this tool:
The last is the easiest to make, so it will be the example. Open System Image Utility and click on Install in the toolbar. Name the image, give it an ID under 4096, and describe it.
On the Contents tab, change the source to Custom Package Install and click on the add button to add a completed package you’ve pulled down at some point in time. When all the packages you want to install have been added, click on Create and select the freshly-made NetBoot drive from the menu. If you’ve ever told Software Update to download and save the package, look in /Library/Packages for those packages. Fix the NetBoot ImageBy default, the image is disabled. We need to change this. Change directories to be inside the NBI image and then run the following commands to clean up the plist and enable the image: defaults write $PWD/NBImageInfo IsEnabled -bool true defaults delete $PWD/NBImageInfo EnabledSystemIdentifiers defaults delete $PWD/NBImageInfo DisabledSystemIdentifiers plutil -convert xml1 NBImageInfo.plist killall -HUP bootpd Tweak the NetBoot ImageSystem Image Utility lets you hack the image, if you want to. Click on List in the toolbar, pick the image to edit, then click on Edit in the toolbar. It offers to backup the original image for you, if you like, and then mounts the image inside the NBI folder at If you edited the disk in Terminal, make sure you’ve changed directories out of the Boot the MacMake sure you’re on the same ethernet network as the new server and then go to Startup Disk and you should see the image name as the available image on the network. Pick it and restart and you should boot off the other machine at this point. The Hard WayAll of that supposes that you’re using a Mac as the server. It can get a lot harder to do this if you’re not, but it’s still very possible to do. You’ll need to make the image and NBI resources on a Mac and then move the folder to the server to be served. Having read the above, you know the paths that are expected for NFS and TFTP so you should make those work in your environment. I’ll go over making the image by hand and setting the boot variables so that the Mac side is done. These instructions will center around imaging the install DVD and using it as the NetBoot device, but the same instructions would work for any mounted image or drive with an install of Mac OS X on it. Make an ImageOn the Mac, mount the drive with an installed copy of Mac OS X then do something like the following: The following commands presume you are working with a PPC image and your working directory is inside the NBI directory. There are two ways to make this image: read-only and read/write. Read-only is smaller and has a chance of being below 2GB for delivery over HTTP (Apache 1.3). Read/write will be larger, allow editing, and must be deployed over NFS or HTTP with Apache 2.0. If you pick read-only, then you’ll need twice the disk space free as the amount of space used on the target device and your format code is UDZO (read-only compressed). If you choose read/write, your format code is UDRW. System Image Utility makes UDRW images. $ mount ... /dev/disk2s3 on /Volumes/Macintosh HD (local, journaled) $ hdiutil create -srcdevice disk2s3 -format [format code] image.dmg If you made a compressed image and want to edit it later, do the following: $ hdiutil convert -format UDRW -o imagerw.dmg image.dmg $ hdiutil mount imagerw.dmg [do stuff] $ hdutil detatch imagerw.dmg $ hdiutil convert -format UDZO -o image.dmg imagerw.dmg Setup the NBI folderThe paths below reference the startup drive. You’ll want to mount the image and use the files on the image instead if it’s a different version of Mac OS X than the one you’re using. If it’s the same version, go ahead and use the local disk for this. If you’re using an install DVD with the same major version as the system you’re booted to, either use the local kernel and extensions or copy the extension cache from the DVD directly rather than regenerating it as the DVD doesn’t have extensions in the Extensions folder. cp -p /usr/standalone/ppc/bootx.bootinfo booter cp -p /mach_kernel mach.macosx kextcache -l -n -s -z -m mach.macosx.mkext /System/Library/Extensions defaults write $PWD/NSImageInfo Name -string 'Name of the image' defaults write $PWD/NSImageInfo BootFile -string booter defaults write $PWD/NSImageInfo Index -int 1001 defaults write $PWD/NSImageInfo IsEnabled -bool true defaults write $PWD/NSImageInfo Kind -int 1 defaults write $PWD/NSImageInfo RootPath -string image.dmg defaults write $PWD/NSImageInfo Type -string NFS plutil -convert xml1 NBImageInfo.plist If you are deploying this on a non-Mac OS X system, the Setup TFTP and NFSMake sure these are enabled on your server and that the following paths work: tftp://server.name/NetBoot/NetBootSP0/ImageName.nbi/booter If you want to use other names or paths and are deploying on a Mac, read bootpd’s manpage for how to specify an image name and location. If you are deploying on something else, just note what the actual paths are over each protocol. Set the Mac’s Boot ArgumentsThere are three Open Firmware boot variables that matter here:
Both the boot-device and boot-file arguments will use TFTP and require the use of backslashes instead of slashes to delimit the directories. For example: boot-device enet:10.10.10.10,NetBoot\NetBootSP0\TigerDVD.nbi\booter boot-file enet:10.10.10.10,NetBoot\NetBootSP0\TigerDVD.nbi\mach.macosx Here’s an example that does not use conventional directories: boot-device enet:10.10.10.10,MacNetBootImages\TigerDVD\booter boot-file enet:10.10.10.10,MacNetBootImages\TigerDVD\mach.macosx Lastly, you need to tell the kernel where to get its root filesystem from. Your choices are HTTP and NFS. Here’s a pair of examples:
Note the colon in the path (and the use of normal slashes). The colon delineates the NetBoot share point from the image name and path within. PrayJust that. It would appear several of these steps require the blood of a virgin Dutch chicken. Accept no substitutes. CreditA lot of this information was based on me testing this out with a copy of Mac OS X Server at my side and watching what it did. A lot of it was reading the bootpd manpage from head to toe. A lot of it was from Mike Bombich’s great NetBoot resources and previous work with NetBoot. His site’s tips center around using Mac OS X Server in creative ways, and my experience is with using Mac OS X in very perverse ways, so it worked out well, I think.
Due to some site issues, this article has been re-dated for today as this was, technically, the first day it appeared in the site’s RSS feed. About Adam Knight |
|
This is awesome and you saved us like, well, $1000
The absolute sym links created problems with bootpd—
Instead, make relative sym links:
ln -s NetBootSP0 /Library/NetBoot/.sharepoint
ln -s NetBootClients0 /Library/NetBoot/.clients
Also, when you setup tftp:
ln -s /Library/NetBoot/NetBootSP0 /private/tftpboot/NetBoot
(forgot the “NetBoot” at the end)
Finally, if you are doing any disk imaging, you really want diskless clients— otherwise you can’t umount the local drive!. Diskless macs via a linux server is a whole other ballgame: http://mike.passwall.com/macnc/
I’ve been trying to implement this with intel-based Macs to no avail. Oddly, I haven’t had time to try it on a PPC Mac to prove that it works! With the intel machines, I get to the point where I can receive the mach bootfiles via TFTP, but then something seems to go amiss and I never get an Apple logo. g=
I’ve been trying to get this to work on a new Dual Core Intel Mini, but it just doesn’t work. This same process worked on a PowerBook G4. Any ideas on what has changed on the Intel Mac’s and what needs to be changed in the process?
Yes, the NetBoot image structure changed. Mike Bombich has a section at the end of his NetBoot page that talks about making the Intel images.
Yea, I understood that the structure was different, but I’m having problems setting up the Intel Mini as the NetBoot server. I’ve run through the process at least three times, and I can’t get a G4 PowerBook to see the Intel Mini to NetBoot from. Are there differences in the setup process above for the Intel Macs (such as the Intel Mac Mini), or do you think the problem lies in the .nbi itself?
Doh! Yeah, good question, that. I’ve not tried it on an Intel machine yet but I’ll toy with it a little this week and see if I can’t get that going.
That said, Tiger Server for Intel is shipping now, if availability was the concern and not price.
Hmm, how can I get my hands on that one to toy around with … ponders
Like the subject line says, I’ve just about given up on trying to get this Intel Mini to work. I can get it to work on a PowerBook, but there’s something with the Intel chips. In the system log it shows it going haywire saying that there was some sort of irreconcialable name resolution error or something like that. It’s really frustrating that I’m having this problem.
I notice that getting an intel mac mini to clone itself also does this: remember how anything that was G5 PPC and previous could clone itself (while running) in Disk Utility? the new Intels go mental if you try that same thing: they lose their id, and won’t boot, because it’s unrecoverable. even when they do get to the root console in single-user mode, you can’t redeem it.
It has nothing to do with the fact of the images or setup. The way that netboot is setup on Tiger now is a little different. The software links are incorrect and point in the wrong direction. It works fine. I got it to work.
having some problems using 10.3.9 and cant get a g5 to netboot any advice novice pretty much
For some machines it is necessary to activate NetBoot 1.0 compatibility. To achieve this you have to
sudo nicl . create /config/dhcp old_netboot_enabled en0
and
sudo killall bootpd
This was necessary to connect my old G3 Powerbook [no firewire]
this is awesome – and it’ll let me resurrect a disabled powerbook g4’s DVD drive gas gone south. I have one issue – I get the following in my syslog:
bsdpd: setting permissions on ‘/Library/NetBoot//Library/NetBoot/NetBootSP0’ failed: No such file or directory
bootpd: NetBoot service turned off
I know this is buried somewhere in the netinfo config – any pointers?
I was having the same problem, follow the instructions in the first comment.
Now to figure out why I can’t seem to pull any files via tftp, despite the permissions and ownership being set as described in the original post.
I fear this wesite has been made obsolete by the recent Mac OS X updates. I noticed my NetBoot images were no longer available on other computers after an upgrade.
I sure hope someone can modify this website to make it work on the new upgrades. Also something for Eleven when it comes out.
Here are instructions for setting up NetBooting on Mac OS X Leopard. I tested it on version 10.5.2. Most of the setup has been put into one well-commented script; cut and paste the script, save it as "set_up_netbooting.sh", and then open the Terminal and run "sudo bash set_up_netbooting.sh" in the directory the script is in. The script will created directories for netboot files, enable NFS, activate a TFTP server, and create a property list that controls a BSDP/DHCP server. [You don't particularly have to know what these things are, but note that internet sharing (System Preferences -> Sharing -> Internet Sharing) may interfere with the BSDP/DHCP server, and vice versa.]
Be sure to look at the optional steps and troubleshooting tips that follow the script. Without further ado, here is set_up_netbooting.sh:
#!/bin/bash
# This script sets up netbooting on a Leopard (Client) machine.
# START WITH SOME SANITY CHECKS
# -----------------------------
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "You must run this script as the root user. (Try \"sudo $0\")"
exit 1
fi;
# check that this is Mac OS X Leopard (Client)
if [[ "`sw_vers -productName`" != "Mac OS X" ]] || [[ "`sw_vers -productVersion`" < "10.5" ]]; then
echo "The script is designed to be run on Mac OS X Leopard, on a non-server version."
exit 2
fi;
# CREATE DIRECTORIES AND SIMLINKS NEEDED FOR NETBOOTING
# -----------------------------------------------------
mkdir -p /Library/NetBoot/NetBootSP0
mkdir /Library/NetBoot/NetBootClients0
chown root:admin /Library/NetBoot/NetBoot*
chmod 775 /Library/NetBoot/NetBoot*
cd /Library/NetBoot
ln -s NetBootSP0 /Library/NetBoot/.sharepoint
ln -s NetBootClients0 /Library/NetBoot/.clients
# EXPORT NETBOOTING FOLDERS OVER NFS (NETWORK FILE SYSTEM)
# --------------------------------------------------------
echo "/Library/NetBoot/NetBootSP0 -ro" >> /etc/exports
# Note that as soon as the file changes, the OS restarts the NFS daemon
# START UP THE TFTP (TRIVIAL FILE TRANSFER PROTOCOL) SERVER
# ---------------------------------------------------------
mkdir /private/tftpboot/NetBoot
ln -s /Library/NetBoot/NetBootSP0 /private/tftpboot/NetBoot
service tftp start
# SET UP BSDP (BOOT SERVICE DISCOVERY PROTOCOL)
# ---------------------------------------------
# Create the /etc/bootpd.plist file.
# This file below is based on information from the bootpd man page.
# It configures a DHCP server to allocate addresses
# from from 192.168.127.10 to 192.168.127.225, on the
# ethernet (en0) port, with NetBooting extensions.
echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Subnets</key>
<array>
<dict>
<key>allocate</key>
<true/>
<key>name</key>
<string>192.168.127/24</string>
<key>net_address</key>
<string>192.168.127.0</string>
<key>net_mask</key>
<string>255.255.255.0</string>
<key>net_range</key>
<array>
<string>192.168.127.10</string>
<string>192.168.127.225</string>
</array>
</dict>
</array>
<key>bootp_enabled</key>
<string>en0</string>
<key>detect_other_dhcp_server</key>
<true/>
<key>dhcp_enabled</key>
<string>en0</string>
<key>netboot_enabled</key>
<string>en0</string>
<key>old_netboot_enabled</key>
<string>en0</string>
</dict>
</plist>' > /etc/bootpd.plist
service bootps start
# WE ARE FINISHED
# ---------------
echo "NetBoot setup script complete. Please be sure to follow the instructions for additional steps you must take."
</pre>
Optional steps:
After that, you will just need to populate the /Library/NetBoot folders. This setup works really well with a NetInstall set created by Net Restore.
Troubleshooting
sudo service bootps start" may help.sudo rm /var/db/bsdpd_clientssudo killall -HUP bootpdI imagine that it goes without saying that you are welcome to use the above script however you see fit, but at your own risk.
I believe that conflicts between internet sharing and running your own netboot server can be mitigated by doing the following.
Start NetBooting for the first time:
Disable NetBooting so you can use Internet Sharing:
Re-enable the NetBoot server:
I believe that will work. You may also need to run “
sudo service bootps stop” to turn off the netboot server, and “sudo service bootps start” to turn it back on.What the?... I used to 10.5 script and now I can’t disable dhcp on my machine! There doesn’t appear to be a “service dhcp”, /etc/bootp.plist is gone and a reboot isn’t fixing it either… where the hell is dhcp???
xSmurf,
that is curious. I really thought that with the bootps service turned off, dhcp would be turned off. If you look at the /etc/bootpd.plist file embedded in the script, you will see that there is an option there that enabled DHCP:
<key>dhcp_enabled</key>
<string>en0</string>
I think you turn it off by doing this:
<key>dhcp_enabled</key>
<false/>
Also, though, the plist includes these two lines:
<key>detect_other_dhcp_server</key>
<true/>
which should prevent your computer from serving DHCP if it detects another DHCP server. I had thought that this would prevent having two DHCP servers on one subnet.
I'm afraid I have no idea what causes the ports to open or close. I would assume that turning the services on and off does this.
Cheers,
Armagon
xSmurf: have you tries “sudo service bootps stop” The service isn’t called DHCP as far as I can tell. On the other hand have you gotten this to work? I am still struggling. I have it working as far as the other machines being able to recognize the image in startup disk but when they reboot they will eventually boot back to the local drives.
I think that it is related to my booter files because I can see that there was a tftp transfer done shortly before the netboot fails. Anyone have a thought?
@Bull, yes bootps is stopped, but ports 1020 to 1023 are still opened and I can see other machines end up with a DHCP offer from that machine instead of the router. Yes I’ve gotten it to work for the most part. I can boot the bootloader (ofwboot.xcf for NetBSD as well as the Mac OS ROM for OS 9). But I never got it to actually boot the system.
Is it possible to make a client Mac boot as a diskless workstation with some variation of these instructions? I know this can be done with OS X Server 10.4, but what about regular 10.4? I’d love to be able to use this solution for a small group of tray load 64Mb iMac’s that are heading for recycling otherwise.
Thanks
having the following issues under 10.5 using the script submitted by armagon… here’s a log of my 10.5 server (a real server) which runs netboot just fine:
10/10/08 9:12:17 AM /sbin/nfsd67 Too many groups for root
10/10/08 9:12:36 AM bootpd24077 can’t open /etc/bootptab
10/10/08 9:12:36 AM bootpd24077 server name tenfiveserver.domain.com
10/10/08 9:12:36 AM bootpd24077 interface en0: ip 10.1.2.2 mask 255.255.0.0
10/10/08 9:12:36 AM bootpd24077 subnets: Failed to convert ‘router’: Invalid IP address
10/10/08 9:12:36 AM bootpd24077 bsdpd: re-reading configuration
10/10/08 9:12:36 AM bootpd24077 bsdpd: shadow file size will be set to 48 megabytes
10/10/08 9:12:36 AM bootpd24077 bsdpd: age time 00:15:00
and here’s the one from my 10.5 client configured using the script and using the same exact /etc/bootpd.plist and same exact files within /Library/NetBoot/NetBootSP0/ :
10/10/08 12:08:46 PM bootpd498 can’t open /etc/bootptab
10/10/08 12:08:46 PM bootpd498 server name tenfiveclient.local
10/10/08 12:08:46 PM bootpd498 interface en0: ip 10.2.2.73 mask 255.255.0.0
10/10/08 12:08:46 PM bootpd498 subnets: Failed to convert ‘router’: Invalid IP address
the only differences i note are the “server name” which in the client’s case is a bonjour name, and the fact that bsdpd doesn’t even fire off on my client.
does anyone know what could be causing this?
it seems to work only with 10.4.x and newer. 10.3.9 hasnt any com.apple.portmap nor launchd nor launchctl.