Site icon TechNewsBoy.com

How to enable PXE boot with VirtualBox

Jack Wallen walks you through the steps for 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 makes it possible for computers to be booted from a remote server on a network. This makes it possible for you to work with automated provisioning of servers and workstations over 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 of the necessary pieces to make PXE possible. Fortunately, it can be done and I’m going to show you how to set this up.

What you’ll need to enable PXE boot

To make this work, you’ll need a running instance of VirtualBox on either a Linux or Windows host. I’ll be demonstrating on a Pop!_OS host and a test VM. With that said, let’s make some virtual magic.

How to configure the TEST VM settings

For your test virtual machine, simply create a new machine (I’m calling mine TEST) but don’t attach an ISO to it. Once you have this TEST VM created, you’ll need to tweak two settings, which are:

  • Network: Set the network adapter to NAT, which is done in Network | Adapter 1 | Attached To.
  • Boot order: Set the VM to boot from the network, which is done in System | Motherboard | Boot Order. First, enable Network and then move it to the top (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 doesn’t include the required scripts to handle PXE. Fortunately, you can add those scripts fairly easily. Each host OS stores these scripts in a different location. These locations are:

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

Open a terminal window and change into that directory. Once there, download the files with:

curl https://codeload.github.com/defunctzombie/virtualbox-pxe-boot/tar.gz/master | tar zx --strip-components 1

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

One thing to keep in mind is that the files contained in that download are specific for Ubuntu and do not include the last two releases — it stops at Xenial. Also, note that this download only enables the installation of Ubuntu. For other distributions, you’ll want to find and add their specific instructions for PXE. You might also want to take a look at the TFTP/kickstart/basic.cfg file for an idea of how to create your kickstart file.

If you’re looking to add more up-to-date versions of Ubuntu, you’d need to download the kernel and initrd files for those releases and place them in TFTP/installers/ubuntu/. For example, if you want to use 20.04, you could follow these instructions:

Download the ISO image:

wget https://releases.ubuntu.com/20.04/ubuntu-20.04.5-live-server-amd64.iso

Mount the image:

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

Copy the 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

Back up the default config 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 contents into that file:

DEFAULT install
LABEL install
KERNEL vmlinuz
INITRD initrd
APPEND root=/dev/ram0 ramdisk_size=1500000 ip=dhcp url=https://releases.ubuntu.com/20.04/ubuntu-20.04.5-live-server-amd64.iso

Save and close the file.

How to create a symlink for your VM

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

cd ~/.config/VirtualBox/TFTP

Next, we’d create the new symlink with:

ln -s ./pxelinux.0 TEST.pxe

Remember, Linux is case-sensitive, so if your VM is named TEST, the symlink must be named TEXT.pxe.

How to boot your PXE-enabled VM

That’s it for the configuration. All you have to do now is boot the virtual machine and you’ll be presented with two options:

  • Install
  • Kickstart Install

Congratulations, you now have PXE enabled with VirtualBox. Remember, for every VM you need PXE booting enabled, you must create the .pxe symlink.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

For all the latest Technology News Click Here 

 For the latest news and updates, follow us on Google News

Read original article here

Denial of responsibility! TechNewsBoy.com is an automatic aggregator around the global media. All the content are available free on Internet. We have just arranged it in one platform for educational purpose only. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials on our website, please contact us by email – abuse@technewsboy.com. The content will be deleted within 24 hours.
Exit mobile version