Tech/HowTo/PXE boot with Libvirt
Using tools like libvirt, virt-manager to network boot (PXE) systems.
- TL;DR;
mkdir -p /srv/tftp cp -r your_pxelinux_stuffs /srv/tftp/ virsh net-edit default
replace
<dhcp>
with
<tftp root='/srv/tftp'/> <dhcp> <bootp file='pxelinux.0'/>
then
virsh net-destroy default && virsh net-start default
Profit
- Howto
Install libvirt Create /srv/tftp directory Download http://cdn-fastly.deb.debian.org/debian/dists/testing/main/installer-amd64/current/images/netboot/netboot.tar.gz Unpack the netboot.tar.gz in /srv/tftp Look at the current libvirt config (removed uuid and MAC)
virsh net-dumpxml default
<network>
<name>default</name>
<uuid>snip</uuid>
<forward mode='nat'/>
<bridge name='virbr0' stp='on' delay='0'/>
<mac address='snip'/>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/>
</dhcp>
</ip>
</network>
Edit the config with *virsh net-edit default* and add
<tftp root='/srv/tftp'/>
in the *ip* section just before the *dhcp* section and also add
<bootp file='pxelinux.0'/>
inside the *dhcp* section, save and restart the network in virsh
virsh net-destroy default
virsh net-start default
virsh net-dumpxml default
<network>
<name>default</name>
<uuid>snip</uuid>
<forward mode='nat'>
<nat>
<port start='1024' end='65535'/>
</nat>
</forward>
<bridge name='virbr0' stp='on' delay='0'/>
<mac address='snip'/>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<tftp root='/srv/tftp'/>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/>
<bootp file='pxelinux.0'/>
</dhcp>
</ip>
</network>
At this point everything is ready, just select PXE install in virt-manager or do a command line setup with the pxe option and you have an install.
Auto Install Debian
cd /srv/tftp wget http://deb.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/gtk/netboot.tar.gz tar -xf netboot.tar.gz
Edit debian-installer/amd64/boot-screens/adtxt.cfg adding the url to the auto option and you can read the Infrastructure/Preseed
url=https://lathama.net/Preseed/test?action=raw
Next set auto as the default by editing pxelinux.cfg/default
default auto