XCP-ng using PXE to install a VM

XCP-ng using PXE to install a VM

One VM creation option is using the Preboot Execution Environment (PXE).

Screenshot Create a new VM on

How do you start using this?

The first step is to create a PXE boot server. One solution is to use netboot. XYZ. Later, I will explain how to do this with iVentoy.

What do you need before you start? Access to the DHCP server of the LAN you are using and a computer where you can deploy the container on and internet access.

Link to the documentation of netboot.xyz to deploy the docker container.
https://netboot.xyz/docs/docker/

First, have a look at the docker-compose.yml file we will be using.

---
services:
  netbootxyz:
    image: ghcr.io/netbootxyz/netbootxyz
    container_name: netbootxyz
    environment:
      - MENU_VERSION=2.0.47 # optional
      - NGINX_PORT=80 # optional
      - WEB_APP_PORT=3000 # optional
    volumes:
      - ./config:/config # optional
      - ./assets:/assets # optional
    ports:
      - 3000:3000  # optional, destination should match ${WEB_APP_PORT} variable above.
      - 69:69/udp
      - 8080:80  # optional, destination should match ${NGINX_PORT} variable above.
    restart: unless-stopped

Launch the container with the following command:

# docker compose up -d

This will start the container and create in the directory where the docker-compose.yml file resits two folders, the config and assets folder.

From now on, you can access the configuration webpage with the "http://your_ip:3000".

Webpage

To automate the booting process from the network, you will need to configure also the DHCP server. In my case, I am using OPNsense to hand out IP addresses in my homelab environment. But in the documentation, you will find the answer for your DHCP server if you are lucky. For OPNsense go to services DHCP for your interface, add to network boot options the following values:

next server IP : "your_ip"
iPXE boot filename: "netboot.xyz.kpxe"

OPNsense screenshot

This worked quite well for me.

Now, the alternative for netboot.xyz could be iVentoy.

I am using a server with Rocky Linux 9 installed with the following utilities, wget and tar.

# dnf install wget tar -y

Download iVentoy

# wget https://github.com/ventoy/PXE/releases/download/v1.0.20/iventoy-1.0.20-linux-free.tar.gz

Untar

# tar -xf iventoy-1.0.20-linux-free.tar.gz

Open following ports on the Firewall if needed 26000, 16000, 10809 and 69

# firewall-cmd --permanent --zone=public --add-port=26000/tcp
# firewall-cmd --permanent --zone=public --add-port=16000/tcp
# firewall-cmd --permanent --zone=public --add-port=10809/tcp
# firewall-cmd --permanent --zone=public --add-port=69/udp
# systemctl reload firewalld

Go to the iVentoy folder and start the program with the following command

# bash ./iventoy.sh start

Browse to "http://your_ip:port"

Change the DHCP configuration to use third-party DHCP server. Download the ISO you will be using to install the VMs. And again configure the DHCP server, but now the iPXE boot filename will be iventoy_loader_16000

Enjoy Your Homelab.