Setup PXE boot environment

It's really helpful to have a nice netboot environment at home or at the datacenter. It allows you to be flexible by changing the operating system version or have different installation methods.

We use it to boot our different SmartOS versions without having an usb key installed on the server. To be also flexible we using pxelinux and grub2 as boot loaders, tftpd and nginx to deliver the files to the node.

DHCP setting

I think you know already how to install an dhcpd on your preferred server. The following options are required to setup PXE boot.

## /etc/dhcp/dhcpd.conf
# pxe bootable
allow booting;
allow bootp;

# pxe-specific configuration directives
next-server 192.168.15.1;
filename "/pxelinux.0";

If the node is configured to use PXE it automatically checks and download the file pxelinux.0 from the configured next-server tftpd server.

TFTP

We use tftpd-hpa, it could easy configured on Debian in /etc/default/tftpd-hpa. To have tftpd a little bit more secure you should use an extra user that have access the the PXE files.

## /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/pxe"
TFTP_ADDRESS="192.168.15.1:69"
TFTP_OPTIONS="--secure"

PXELinux / SYSLinux

The syslinux package provides all files for pxelinux setup. We deploy all files to /srv/pxe to have one place which stores the configuration.

/srv/pxe
|-- boot -> .                # Simple symlink to boot folder
|-- grub                     # Grub2 configuration folder
|   |-- grub.cfg             # Grub2 configuration file
|   `-- i386-pc              # Grub2 modules folder
|-- os                       # Operating system folder
|-- pxelinux                 # PXELinux module folder
|-- pxelinux.0               # PXELinux file
`-- pxelinux.cfg             # PXELinux configuration folder
    |-- 01-00-0d-b9-32-6b-d0 # Extra configuration based on MAC
    `-- default              # Default configuration file for PXELinux

The pxelinux.cfg folder contains files named of the MAC address (01-[mac address]) of the node or fallback default configuration file. In the default file we've different options for:

  • Boot from local disk
  • Boot SmartOS
  • Boot FreeDOS
  • Boot Grub2

The menu contains some style options to have a fancy interface. But checkout the configuration file by yourself.

# Seriel console and default option
SERIAL 0 115200 0
DEFAULT pxelinux/vesamenu.c32
PROMPT 0

TIMEOUT 100

# Menu Style
MENU BACKGROUND pxelinux/splash.png
MENU TITLE Welcome to f.fruky.net-PXE
MENU VSHIFT 11
MENU ROWS 6
MENU TABMSGROW 15
MENU CMDLINEROW 14
MENU HELPMSGROW 16
MENU TABMSG Press [Tab] to edit options, [F1] for boot options.
MENU COLOR border 30;44 #00000000 #00000000 none

# Menu Setup
LABEL local
  MENU LABEL Local Disk
  LOCALBOOT 0

LABEL smartos
  MENU LABEL SmartOS-20140611EAIT
  KERNEL pxelinux/mboot.c32
  APPEND os/smartos/20140611EAIT/platform/i86pc/kernel/amd64/unix -B smartos=true,console=text --- os/smartos/20140611EAIT/platform/i86pc/amd64/boot_archive

LABEL FreeDOS
  MENU LABEL FreeDOS
  LINUX pxelinux/memdisk
  INITRD os/freedos/fdboot.img

LABEL grub
  MENU LABEL Grub2 boot
  boot grub/i386-pc/core.0

F1 help.msg #00000000

Grub2

You maybe think, why grub2 if you've a running pxelinux environment. Grub2 has some features that helps us more for debugging or installation from an web server.

  • Better serial console support
  • Better debug support (for example: changing of PCI device order)
  • Fetch additional information from http servers
## grub.cfg
# Load modules
insmod pxe
insmod serial
insmod usbserial_pl2303
insmod usbserial_ftdi

# Configure serial console
serial --speed=115200 --word=8 --parity=no --stop=1
terminal_input serial
terminal_output serial
terminal serial

# Play sound
play 480 440 1

# Menu
menuentry "SmartOS DEBUGGING" {
    multiboot /os/smartos/DEBUG/platform/i86pc/kernel/amd64/unix /os/smartos/DEBUG/platform/i86pc/kernel/amd64/unix -v -kd -B smartos=true,console=ttya,ttya-mode="115200,8,n,1,-"
    module /os/smartos/DEBUG/platform/i86pc/amd64/boot_archive /os/smartos/DEBUG/platform/i86pc/amd64/boot_archive
}

menuentry "FreeDOS" {
    linux16 /pxelinux/memdisk harddisk c=19 h=16 s=63
    initrd16 /os/freedos/freedos10.img
}

menuentry "Debian 7.4 Live Rescue (amd64)" {
    linux /os/debian/debian-live-7.4-amd64-rescue.vmlinuz boot=live config fetch=http://192.168.15.1/os/debian/debian-live-7.4-amd64-rescue.squashfs quiet console=ttyS0,115200n8
    initrd /os/debian/debian-live-7.4-amd64-rescue.initrd.img
}

menuentry "Debian 7.4 Live Standard (amd64)" {
    linux /os/debian/debian-live-7.4-amd64-standard.vmlinuz boot=live config fetch=http://192.168.15.1/os/debian/debian-live-7.4-amd64-standard.squashfs quiet console=ttyS0,115200n8
    initrd /os/debian/debian-live-7.4-amd64-standard.initrd.img
}

menuentry "Debian 7.5 Installer (amd64)" {
    linux /os/debian/installer-7.5-amd64/linux
    initrd  /os/debian/installer-7.5-amd64/initrd.gz
}

The Debian Rescue and Debian Live configuration fetches the squashfs via http. This is much faster than download the files via tftp.

To boot SmartOS via grub2 the following grub2 menuentry parameters required. You need to specify every value two times.

  • multiboot: SmartOS Kernel
  • module: SmartOS boot archive

Posted

July 19, 2014, 2:00 pm

Tags

, , , , ,

More

Permalink

Comments

Send your comment by mail.