VirtualBox - Preboot Execution Environment (PXE)


Preboot Execution Environment (PXE)

Network-based installations are especially useful when used together with a Preboot Execution Environment (PXE) server, which allows you to boot the installation program from the network as well.

The preboot execution environment (PXE) is an environment to boot computers using a network interface independently of available data storage devices or installed operating systems.

If you do not use gPXE, you might experience problems while booting the ESX installer on a heavily loaded network. TFTP is a light-weight version of the FTP service, and is typically used only for network booting systems or loading firmware on network devices such as routers. TFTP is not a robust protocol and is sometimes unreliable for transferring large amounts of data.

PXELINUX is part of the SYSLINUX package. Many Linux distributions include it. Many versions of PXELINUX also include gPXE. Some distributions, such as Red Hat Enterprise Linux version 5.3, include older versions of PXELINUX that do not include gPXE.

In order for PXE booting to work with the builtin server in Virtualbox you need to configure your VM's network settings and boot order properly.

  • Set the VM to use the NAT networking (Network → Adapter 1 → Attached to: NAT).
  • Set the VM to boot from network (System → Motherboard → Boot Order). Alternatively, you can use F12 in the booting VM to load the boot menu. For testing PXE and kickstart configs, I found that changing the boot order was easier.

PXE functionality is built into the NAT network mode of the VirtualBox.

# VirtualBox will use the pxelinux.0 file as the PXE file for that VM.

# default PXE file
VBoxManage modifyvm "MachineName" --nattftpfile1 /pxelinux.0

You can also change the boot order to have the Network as the first option (System → Motherboard → Boot Order).

pxe File

The PXE configuration file defines the menu displayed to the target host as it boots up and contacts the TFTP server. The TFTP server is always listening for PXE clients on the network. When it detects that a PXE client is asking for PXE services, it sends the client a network package that contains this boot menu.

Each PXE boot menu selection points to the location of the kernel and ramdisk files. You can create:

  • one PXE configuration file for each target VM host,
  • or one PXE configuration file and name it default.

Virutalbox doc:

PXE booting is now supported in NAT mode. The NAT DHCP server provides 
a boot file name of the form vmname.pxe if the directory TFTP exists 
in the directory where the user's VirtualBox.xml file is kept. It is the responsibility 
of the user to provide ''vmname.pxe''.

pxe file must be located here:

# On linux
# On OSX it is 
  • PXE boot the installer and perform a scripted installation with local or remote media (RPM files), as specified in the installation script
label scripted
menu label Scripted Installation
kernel test/vmlinuz
append initrd=test/initrd.img vmkopts=debugLogToSerial:1 mem=512M ks=nfs://


  • vmlinuz is the boot loader kernel code. vmlinuz is a Linux kernel used for booting.
  • initrd.img is the boot ramdisk. The kernel is located in the initrd.img file

The kernel image and ramdisk directory contains files that that must be loaded across the network to enable PXE booting of the VM installer.

The kernel image and ramdisk directory is located on a Web server or on the TFTP server in the /tftpboot directory For example, the directory might be at /tftpboot/esx/ and contain the following files:

  • initrd.img
  • vmlinuz

These files come from the ESX installation DVD, under the /isolinux directory.

You reference the vmlinuz and initrd.img files from the PXE configuration file.

The initial boot file pxelinux.0 or gpxelinux.0 tries to load a PXE configuration file.

  • It tries with the MAC address of the target host, prefixed with its ARP type code (01 for Ethernet).
  • If that fails, it tries with the hexadecimal notation of target system IP address.
  • Ultimately, it tries to load a file named default.

File Location for the PXE Configuration File

  • Save the file in var/lib/tftpboot/pxelinux.cfg/ on the TFTP server.
  • For example, you might save the file on the TFTP server at var/lib/tftpboot/pxelinux.cfg/01-00-21-5a-ce-40-f6. The MAC address of the network adapter on the target host is 00-21-5a-ce-40-f6.

Documentation / Reference

Powered by ComboStrap