How to enable PXE boot with VirtualBox

Jack Wallen walks you through the steps of enabling PXE boot for virtual machines in VirtualBox.

Image: tippapatt/Adobe Stock

PXE stands for Preboot Execution Environment and is a client-server interface that allows computers to be booted from a remote server over a network. This allows you to work with an automated provisioning of servers and workstations on a network.

SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)

Sometimes you might even want to do this with a virtual machine. But if you’re using VirtualBox, it doesn’t include all the parts needed to make PXE possible. Luckily it can be done and I’ll show you how to set it up.

What You’ll Need to Enable PXE Boot

For this to work you will need a running instance of VirtualBox on a Linux or Windows host. I will demonstrate on a Pop!_OS host and a test VM. That said, let’s do some virtual magic.

How to configure TEST VM settings

For your test VM, just create a new machine (I call mine TEST) but don’t attach an ISO to it. Once you have created this TEST VM, you will need to modify two parameters, which are:

  • Network: Set the network adapter to NAT, which is done in Network | Adapter 1 | Attached to.
  • Boot order: configure the virtual machine to start from the network, which is done in System | Motherboard | Start order. First, enable the network, then move it up (Figure A).

Figure A

Enabling and prioritizing network boot in VirtualBox.

That’s it for the VM settings.

How to add the necessary files

VirtualBox does not include the scripts required to manage PXE. Fortunately, you can add these scripts quite easily. Each host operating system stores these scripts in a different location. These locations are:

  • Linux and Oracle Solaris: $HOME/.config/VirtualBox.
  • the Windows: $HOME/.VirtualBox.
  • macOS: $HOME/Library/VirtualBox.

Open a terminal window and navigate to this directory. Once there, download the files with:

curl | tar zx --strip-components 1

This command will create a new directory, named TFTP in the VirtualBox storage location.

One thing to keep in mind is that the files in this download are Ubuntu specific and do not include the latest two versions – this stops at Xenial. Also note that this download only installs Ubuntu. For other distros, you’ll want to find and add their specific instructions for PXE. You can also consult the TFTP/kickstart/basic.cfg file to learn how to create your kickstart file.

If you want to add newer versions of Ubuntu, you need to download the kernel and initrd files for those versions and place them in TFTP/installers/ubuntu/. For example, if you want to use 20.04, you can follow these instructions:

Download the ISO image:


Mount the image:

sudo mount ubuntu-20.04.5-live-server-amd64.iso /mnt

Copy kernel and initrd files

cp /mnt/casper/{vmlinuz,initrd} ~/.config/VirtualBox/TFTP/

Copy the ldlinux.c32 file

cp /usr/lib/syslinux/modules/bios/ldlinux.c32 ~/.config/VirtualBox/TFPT

Backup the default configuration file with:

mv ~/.config/VirtualBox/TFPT/pxelinux.cfg/default ~/.config/VirtualBox/TFPT/pxelinux.cfg/default.bak

Create a new default file with:

nano  ~/.config/VirtualBox/TFPT/pxelinux.cfg/default

Paste the following content into this file:

DEFAULT install
LABEL install
KERNEL vmlinuz
INITRD initrd
APPEND root=/dev/ram0 ramdisk_size=1500000 ip=dhcp url=

Save and close the file.

How to create a symbolic link for your VM

Remember, we named our VM TEST. For each virtual machine that requires PXE, you must create a symbolic link from TFTP/lxelinux.0 to a new file with the same name. So, for our TEST VM, we would change to the TFTP directory with the command:

cd ~/.config/VirtualBox/TFTP

Next, we would create the new symbolic link with:

ln -s ./pxelinux.0 TEST.pxe

Remember that Linux is case sensitive, so if your VM is named TEST, the symbolic link must be named TEXT.pxe.

How to start your PXE-enabled virtual machine

That’s it for the setup. All you have to do now is start the virtual machine and you will be presented with two options:

  • Install
  • Start the installation

Congratulations, you now have PXE enabled with VirtualBox. Remember that for each virtual machine that needs to be PXE booted, you need to create the .pxe symbolic link.

Subscribe to TechRepublic How to make the technology work on YouTube for all the latest tech tips for professionals from Jack Wallen.

Comments are closed.