Quick way to PXE a Mac

TCPMeta

Solid State Member
Messages
8
Location
US
For giggles I wanted to PXE boot my MacBook Pro. Since the Apple EFI system is a stripped own version of Tiano core there have been some nifty boot replacements/toolkit that let you multiboot the system. I myself prefer to use rEFIt. This little badboy will let you boot standard MBR style media and even via USB.

Anyway install rEFIt. I installed mine to the EFI partition. I know it's a "no no" but it's up to you.

Open termial and run

system_profiler > profile.log

This will dump a super detailed summary if your mac. It can take a few minutes to compile. When its done just use TextEdit and find en0. Write down the PCI Vendor and PCI Device info for the ethernet. My MacBook uses 0x10de for the vendor and 0x0ab0 for the device. yours might be different.

Go to the etherboot website. Select the output format to USB keychain disk image. Skip 2 and head over to 3 and enter the vendor and device info. You only need the last four of the code so it should look like this
10de 0ab0
You don't need the 0x part. Download the image, it's super small.

Now go back into terminal. Pop in a USB jump drive. Run
diskutil list
This will list all the drives and partitions on the system. Chances are the USB will be a FAT partition so you'll know. On my system the USB can up as /dev/disk1.
Now we have to unmount the drive so you can write the image to it. Just issue the command
diskutil unmountDisk /dev/diskN
The N is what ever number your USB shows up as. Now go to where you downloaded the image in the terminal and issue this command

if=gpxe-1.0.1-gpxe.usb of=/dev/rdiskN

Yes, I did say rdisk because it's writing directly to the USB disk. Now power off the Mac and turn it back on. Some odd reason rEFIt won't see the USB on a typical reboot.
 
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
 
Back
Top Bottom