Jun 28, '13 07:30:00AM • Contributed by: edxley
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):
-
Connect the Mac and the client PC with the ethernet cable.
-
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.
-
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
-
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, typeman nfsdandman exportsin Terminal, and see this hint.
-
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, seeman nfsdandman showmount.
-
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 bootpdandman tftpd.
-
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.
-
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
Seeman launchd,man launchctl,man launchd.plist, and this article.
-
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.
-
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 orls -lif needed.
-
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.)
-
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.
-
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).
-
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.
- 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!
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.)
-
Follow steps 1, 2, 6, and 7 of the regular setup, and skip steps 3, 4, and 5.
-
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.
-
Follow step 9 of the regular setup.
-
In step 10, instead of moving the folder "live", open it and move the file "filesystem.squashfs" to /private/tftpboot.
-
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 parameterfetch=tftp://192.168.1.1/filesystem.squashfs
then save the file and quit TextEdit.
- 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!
Uninstall steps:
-
Move the files /etc/bootpd.plist and /etc/exports to the Trash.
-
Restart the NFS server:
$ sudo nfsd restart
and check the status of the server (should say enabled, not running):$ nfsd status
-
Disable the DHCP and TFTP servers:
$ sudo launchctl unload -w /System/Library/LaunchDaemons/bootps.plist $ sudo launchctl unload -w /System/Library/LaunchDaemons/tftp.plist
-
Move the files and folders from /private/tftpboot and /srv/debian-live to the Trash.
-
Remove the /srv/debian-live and /srv directories:
$ sudo rmdir /srv/debian-live $ sudo rmdir /srv
