Setting Up A Pxe Server On Rocky Linux 9.X
- Install a
dhcpserver:sudo dhcp install -y dhcp-server - Edit the configurations of your DHCP server in
/etc/dhcp/dhcpd.conf:subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.240 192.168.1.250; option broadcast-address 192.168.1.255; option routers 192.168.1.1; filename "pxelinux.0"; next-server 192.168.1.106; } - Install the
tftpserver:sudo dnf install -y tftp-server - Start and enable the
tftpservice:sudo systemctl enable --now tftp - Install the
syslinuxpackage, which contains the PXE bootloader:sudo dnf install -y syslinux - Copy boot files to the TFTP server directory:
sudo cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ - Create a directory for your installation files:
sudo mkdir /var/lib/tftpboot/<distro_name_here> - Mount the ISO image:
sudo mount -o loop /path/to/<your_ISO>.iso /mnt - Copy the contents of the distro ISO to the
tftpbootdirectory:cp /mnt/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/<distro_name_here> - Create a configuration at
/var/lib/tftpboot/pxelinux.cfg: ``` default menu.c32 prompt 0 timeout 300 ONTIMEOUT local
menu title PXE Boot Menu
label
* Restart the `dhcp` server:
sudo systemctl restart dhcpd
* Restart the `tftp` server:
sudo systemctl restart tftp
* Check that the configurations were correct:
sudo systemctl status dhcpd sudo systemctl status tftp
* Unmount the ISO at `/mnt`:
sudo umount /mnt
* Edit this file:
/etc/libvirt/qemu.conf
* Uncomment this line:
#vnc_listen = “0.0.0.0”
* Restart `libvirt` with:
sudo systemctl restart libvirtd
* Then for testing, set up a local VM with `virt-install` and in particular set the graphics option as `vnc` (default port is `5900`):
virt-install –hvm –connect qemu:///system –name testvm –ram 4096 –vcpus 4 –network=bridge:virbr0 –pxe –osinfo detect=on,require=off –disk path=/home/howard/images/testvm.qcow2,size=20 –graphics vnc ```
- Connect to the host that has the VM via its IP address and port
5900like so: IP:PORT