kvm/qemu pxe boot setup on fedora.

kvm support disk less booting of operating systems over network, kvm default network can be configured to act a pxe server.

packages required to setup pxe boot, tfp is a udp based file sharing service used to push the required files for pxe boor, /var/lib/tftpboot will be directory for tftp server.
we need to copy syslinux files to this location by creating a directory called pxelinux.

As the vm boot up with option from network boot , it will be able to fetch intial files required to boot from pxelinux.0 , installation files of iso can be fetched from http , nfs , or ftp over network.

i am running http server to provide files for installation

for creating a grub menu, create a directory pxelinux.cfg with file default

cat default 
default vesamenu.c32
prompt 1
timeout 600

display boot.msg

label linux
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img inst.repo=
label vesa
  menu label Install system with ^basic video driver
  kernel vmlinuz
  append initrd=initrd.img xdriver=vesa nomodeset
label rescue
  menu label ^Rescue installed system
  kernel vmlinuz
  append initrd=initrd.img rescue
label local
  menu label Boot from ^local drive
  localboot 0xffff
label memtest86
  menu label ^Memory test
  kernel memtest
  append -
# sudo cp /usr/share/syslinux /var/lib/tftpboot/pxelinux/
here is the contents of /var/lib/tftpboot/pxelinux/
 tree  -d /var/lib/tftpboot/pxelinux/
├── com32
│   └── include
│       ├── bitsize
│       ├── bitsize32
│       ├── bitsize64
│       ├── gplinclude
│       │   ├── acpi
│       │   ├── disk
│       │   ├── dmi
│       │   ├── vpd
│       │   └── zzjson
│       ├── hw
│       ├── klibc
│       │   ├── i386
│       │   └── x86_64
│       ├── linux
│       ├── netinet
│       ├── sys
│       │   ├── i386
│       │   └── x86_64
│       └── syslinux
├── diag
├── dosutil
└── pxelinux.cfg
# dnf install syslinux-tftpboot syslinux-devel syslinux-common tftpd 

After the packages are installed , enable and run tfp service.

#systemctl start tftp
#systemctl enable tftp

here is my default network xml file configured for pxe install.

# virsh net-dumpxml default 
  <forward mode='nat'>
      <port start='1024' end='65535'/>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:d9:5b:b9'/>
  <ip address='' netmask=''>
      <range start='' end=''/>
      <host mac='52:54:00:d8:a0:f4' name='centosext' ip=''/>
      <host mac='52:54:00:2d:07:d3' name='centosext1' ip=''/>
      <host mac='52:54:00:17:1a:99' name='centosext2' ip=''/>
      <host mac='52:54:00:7b:f9:f3' name='centosext3' ip=''/>
      <host mac='52:54:00:df:5f:2f' name='centosext4' ip=''/>
      <host mac='52:54:00:d8:a0:f4' name='centosext5' ip=''/>
      <host mac='52:54:00:82:18:49' name='chefnode1' ip=''/>
      <host mac='52:54:00:8d:10:87' name='chefnode2' ip=''/>
      <host mac='52:54:00:c6:41:eb' name='chefnode3' ip=''/>
      <host mac='52:54:00:7a:73:a0' name='chefnode4' ip=''/>
      <bootp file='/pxelinux/pxelinux.0' server=''/>

Setting up a lvm partition for the new vm,

#sudo virsh vol-create-as  store pxe1 10G 
Vol pxe1 created

Lets install os from pxe, after executing the below virt-install command , connect from any vnc client on host ip address port 5900

#virt-install --name pxe1 --ram 512 --disk path=/dev/store/pxe1 --vcpus 2  --pxe --os-type linux --os-variant rhel7 --network network=default  --graphics  vnc,listen=   --accelerate

Starting install...