Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

How to set up a Mac as a PXE boot server, with Debian Live Network
Here is how to set up a Mac, running OS X Client 10.5 or later, as a PXE boot server.  We will configure OS X's built-in DHCP, TFTP, and NFS servers, start the servers, and put the client boot files in place.  (The NFS server may be optional, depending on the operating system we are booting.)

You'll need the Mac, a PXE-capable PC, and an ethernet cable.  Some steps will require being logged in as an administrator on the Mac.

We'll boot Debian Live on the client PC as an example.  We'll show a regular setup with NFS, an alternate setup without NFS, and how to uninstall.
Regular setup (with NFS):
  1. Connect the Mac and the client PC with the ethernet cable.

  2. On the Mac, in System Preferences > Network, click "Ethernet" and enter the following settings:
    Configure IPv4: Manually
    IP Address: 192.168.1.1
    Subnet Mask: 255.255.255.0
    (All others can be left blank)
    
    Note the status may read "Cable Unplugged" at this point, which is ok.

  3. In Terminal, make new directories /srv and /srv/debian-live (we'll be sharing /srv/debian-live over NFS) with the following commands:
    $ sudo mkdir /srv
    $ sudo mkdir /srv/debian-live
    
  4. To create the NFS configuration file, enter the following command:
    $ sudo nano /etc/exports
    
    paste the following text into the editor:
    /srv/debian-live -ro -network 192.168.1.0 -mask 255.255.255.0
    
    and press Control-O to save and Control-X to exit nano.

    This will share /srv/debian-live to the ethernet network as read-only.

    For more information, type man nfsd and man exports in Terminal, and see this hint.

  5. Check the /etc/exports file created in step 4 (no output means ok):
    $ nfsd checkexports
    
    check the status of the NFS server (should say enabled and running):
    $ nfsd status
    
    and check the server's exports list (should show the /srv/debian-live directory):
    $ showmount -e
    
    For more information, see man nfsd and man showmount.

  6. To create the DHCP configuration file, enter the following command:
    $ sudo nano /etc/bootpd.plist
    
    paste the following text into the editor:
    <?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>dhcp_enabled</key>
    	<string>en0</string>
    	<key>Subnets</key>
    	<array>
    		<dict>
    			<key>name</key>
    			<string>192.168.1</string>
    			<key>net_mask</key>
    			<string>255.255.255.0</string>
    			<key>net_address</key>
    			<string>192.168.1.0</string>
    			<key>net_range</key>
    			<array>
    				<string>192.168.1.2</string>
    				<string>192.168.1.254</string>
    			</array>
    			<key>allocate</key>
    			<true/>
    			<key>dhcp_option_66</key>
    			<string>192.168.1.1</string>
    			<key>dhcp_option_67</key>
    			<data>cHhlbGludXguMAA=</data>
    		</dict>
    	</array>
    </dict>
    </plist>
    


    and press Control-O to save and Control-X to exit nano.

    Notes:

    • If the file /etc/bootpd.plist already exists, turn off Internet Sharing in System Preferences > Sharing.  Then the file will be removed, and you can create it as in this step.

      (Make sure to move /etc/bootpd.plist to the Trash and disable the DHCP server before turning Internet Sharing back on.  See "Uninstall steps" below.)

    • If you are using an ethernet port other than en0 (see System Information or System Profiler for the port name), change the value for the dhcp_enabled key to the port you are using.

    • The data for the dhcp_option_67 key is the bootloader filename "pxelinux.0" (see step 9 below), null terminated and encoded into base64.  This can be generated with the free DHCP Option Code Utility, or by entering the following command in Terminal:
      $ printf %s00 `echo -n pxelinux.0 | xxd -p` | xxd -r -p | openssl base64
      
      (See this discussion thread.)

    • The string for the dhcp_option_66 key is the IP address of the tftp server, i.e. the address of the Mac from step 2.

    • See man bootpd and man tftpd.


  7. Enable the DHCP and TFTP servers with the following commands:
    $ sudo launchctl load -w /System/Library/LaunchDaemons/bootps.plist
    $ sudo launchctl load -w /System/Library/LaunchDaemons/tftp.plist
    
    See man launchd, man launchctl, man launchd.plist, and this article.

  8. Download a Debian Live netboot archive, gnome-desktop or another flavor, from one of the following (choose i386 or amd64 depending on the client PC's architecture):


    Place the .tar.gz file on the Desktop (or anywhere convenient), then double-click it to expand the archive.

  9. Open the folder that is created (with a name like "debian-live-6.0.7-i386-gnome-desktop-net"), open the "tftpboot" subdirectory, select all of the files, and move them to /private/tftpboot.  (This includes the pxelinux.0 file mentioned in step 6, and other boot menu and kernel files.)

    Note that files in /private/tftpboot should be readable by everyone (so they will transfer), but not writeable by everyone (so they can't be modified).  Check permissions with Get Info or ls -l if needed.

  10. Click the Back button to leave the "tftpboot" subdirectory, then open the "debian-live" subdirectory, then select the folder called "live" and move it to /srv/debian-live.  (When Debian Live is booting, it will look for the file /srv/debian-live/live/filesystem.squashfs over NFS, which contains the root filesystem.)

  11. Optionally, test the TFTP server:
    $ tftp localhost
    tftp> get pxelinux.0
    tftp> quit
    $ ls -l pxelinux.0
    
    You should see that a copy of the file pxelinux.0 has been downloaded to the current directory.

  12. Turn on the client PC, and press or hold the key to bring up the boot options (something like F2 or F12; check the documentation for your machine or look for a message onscreen).

  13. Choose to boot from the network (PXE).  The PC receives an IP address from the DHCP server, loads pxelinux from the TFTP server, and displays the Debian Live boot menu.

  14. Choose a boot option, and after the kernel is downloaded, the root filesystem is accessed over NFS, and the operating system is loaded, you'll end up at your graphical desktop or shell prompt of choice!
To uninstall, see "Uninstall steps" below.


Alternate setup (no NFS):

This is a shorter method, because NFS is not required.  Debian Live will download its root filesystem over TFTP.  (However, the largest file that can be downloaded is limited by a bug.)
  1. Follow steps 1, 2, 6, and 7 of the regular setup, and skip steps 3, 4, and 5.

  2. In step 8, choose a smaller archive, like the standard flavor from 6.0.7, or the lxde-desktop flavor from 5.0.10.  (A bug causes some of the larger versions to stall when downloading the root filesystem over TFTP.)  Place the .tar.gz file on the Desktop, then double-click it to expand the archive.

  3. Follow step 9 of the regular setup.

  4. In step 10, instead of moving the folder "live", open it and move the file "filesystem.squashfs" to /private/tftpboot.

  5. Open the file /private/tftpboot/debian-live/i386/boot-screens/live.cfg in TextEdit.  Edit the kernel parameters for the boot menu option you'll be using, replacing the two parameters
    netboot=nfs nfsroot=192.168.1.1:/srv/debian-live
    
    with a single parameter
    fetch=tftp://192.168.1.1/filesystem.squashfs
    
    then save the file and quit TextEdit.

  6. Follow the regular setup steps 11, 12, 13, and 14.  The root filesystem may take some time to download in step 14 (1 to 2 minutes over 100mbps ethernet), but when it finishes, you'll end up booted into Debian Live!
To uninstall, follow steps 1, 3, and 4 under "Uninstall steps", but ignore the /etc/exports file in step 1, and the /srv/debian-live directory in step 4.  Skip steps 2 and 5.


Uninstall steps:
  1. Move the files /etc/bootpd.plist and /etc/exports to the Trash.

  2. Restart the NFS server:
    $ sudo nfsd restart
    
    and check the status of the server (should say enabled, not running):
    $ nfsd status
    
  3. Disable the DHCP and TFTP servers:
    $ sudo launchctl unload -w /System/Library/LaunchDaemons/bootps.plist
    $ sudo launchctl unload -w /System/Library/LaunchDaemons/tftp.plist
    
  4. Move the files and folders from /private/tftpboot and /srv/debian-live to the Trash.

  5. Remove the /srv/debian-live and /srv directories:
    $ sudo rmdir /srv/debian-live
    $ sudo rmdir /srv
    
Lex adds: I haven't tested this one.
    •    
  • Currently 2.80 / 5
  You rated: 5 / 5 (5 votes cast)
 
[12,835 views]  

How to set up a Mac as a PXE boot server, with Debian Live | 6 comments | Create New Account
Click here to return to the 'How to set up a Mac as a PXE boot server, with Debian Live' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
How to set up a Mac as a PXE boot server, with Debian Live
Authored by: drudus on Jun 28, '13 08:56:35AM

I didn't see this mentioned so try to avoid having two devices running DHCP on one network, otherwise you may find the client doesn't pick up the server & PXE boot fails (or worse things happen).

Personally I find this Mac PXE boot server somewhat involved, on Debian it's simpler to use dnsmasq. Skip to the using dnsmaq sectionů
http://www.debian-administration.org/articles/478

You can run it from a USB stick if you want to keep the Mac setup on OS X.

Good work getting this running on OS X.



[ Reply to This | # ]
How to set up a Mac as a PXE boot server, with Debian Live
Authored by: sr105 on Jun 28, '13 01:02:45PM

The nice part of the pure OSX approach is that you only have to set it up once. You can even effectively turn it off (well, the bootp part, at least) by changing your Network Preferences for the Ethernet port. I have a Network Location saved for just this purpose. Like I said in my other comment, if the network set for the Ethernet port doesn't match, the bootp server doesn't respond to incoming requests.

I suppose you could "turn off" the nfs and tftp by adding firewall rules only allowing connections from the configured network address range.



[ Reply to This | # ]
How to set up a Mac as a PXE boot server, with Debian Live
Authored by: sr105 on Jun 28, '13 12:57:51PM

It's a good idea to use something other than 192.168.x.x for your network. Those IPs are used by lots of routers, VMWare, Parallels, etc. Use 10.x.y.z as an alternative with a unique number for 'x'. Make sure your network and network masks match between bootp and Network Preferences. If they don't match, e.g. 10.1.1.x/16 vs 10.1.1.x/24, bootp will silently refuse to answer.

Set the bootp flag to detect other dhcp servers as well.

I use this for testing hardware and always change the paths for tftpboot and debian-live to be inside my home directory.

Last, if you're only testing with one machine, you don't need a hub/switch. Just connect a cable direct from your mac to the device.



[ Reply to This | # ]
How to set up a Mac as a PXE boot server, with Debian Live
Authored by: lullabud on Jun 30, '13 04:07:39PM
It's a good idea to use something other than 192.168.x.x for your network. Those IPs are used by lots of routers, VMWare, Parallels, etc. Use 10.x.y.z as an alternative with a unique number for 'x'. Make sure your network and network masks match between bootp and Network Preferences. If they don't match, e.g. 10.1.1.x/16 vs 10.1.1.x/24, bootp will silently refuse to answer.
Not necessarily true, at least for a home network. 192.168.x.0/24 is great for home networks precisely because it is not (sanely) used in enterprise, and thus there are no route collisions when connecting to VPNs.

Also, in the case that you do want to connect to other 10/8 networks and participate within that IP space, you shouldn't randomly select one because once again you may have routing problems.

But hey, 10/8 networks are really easy to type, especially if you use 10.0.0.x, because you can type those like 10.x and they'll still work with most CLI tools and browsers and stuff.

[ Reply to This | # ]
How to set up a Mac as a PXE boot server, with Debian Live
Authored by: edxley on Jul 04, '13 01:40:17PM
Yes, match the address and mask between Network Preferences and the bootpd plist file, and also the exports file if you are using NFS.  The exports file would look something like this:
/srv/debian-live -ro -network 10.1.1.0 -mask 255.255.255.0
Also, for Debian Live, edit the address in the nfsroot= parameter in the live.cfg file.  Change the 192.168.1.1 to the 10.1.1.x address that you are using, so the whole parameter is something like nfsroot=10.1.1.1:/srv/debian-live.  (For the alternate setup, edit the fetch= parameter in live.cfg, to something like fetch=tftp://10.1.1.1/filesystem.squashfs.)

Should be doable even with other than 192.168.x.x!

[ Reply to This | # ]
How to set up a Mac as a PXE boot server, with Debian Live
Authored by: cawaker on Jul 02, '13 12:59:23PM

very awesome, thanks!
I was just looking to do something like this since i've been jumping through a bunch of linux distros lately for testing stuff.



[ Reply to This | # ]