box.matto.nl

home/

Install a KVM guest over PXE

Last edited
Installing a KVM guest over PXE is very easy.

KVM is the hypervisor that is build into the Linux kernel. It is a great method to run virtual machines on your Linux box.

KVM makes it possible to run multiple virtual machines running unmodified Linux, OpenBSD, Free-BSD, or Windows or even Debian GNU/kFreeBSD images. Each virtual machine has private virtualized hardware: a network card, disk, graphics adapter, etc.
I am a great fan of KVM.

A great start to learn more about KVM is http://www.linux-kvm.org

Install over PXE

A "normal" way of installing an operating system on a KVM guest is to download the ISO image of the installation CD or DVD and point your kvm to it. However sometimes you may want to install your guest over PXE.

Install a pxe-server

If you don't have a PXE-server running, you first must install one. Yes, we do that on a KVM guest too.

It is not very difficult to create a PXE-server with Debian and KVM. See this great howto: debian-administration.org

Boot kvm with pxe-rom

Once you have a PXE-server running, it is easy to install your KVM guests over PXE. The trick is to add the argument "-option-rom /usr/share/kvm/pxe-rtl8139.bin" to your kvm command line.

That is all! See this command line for example:

kvm  -vnc 192.168.1.2:0 -hda guest.img -boot n -option-rom /usr/share/kvm/pxe-rtl8139.bin  -net nic,model=rtl8139,vlan=0,macaddr=00:16:5e:25:05:17 -net tap,ifname=tap1,script=/etc/qemu-ifup-br0

In this example:

  • 192.168.1.xxx
    This is the local network, change according to your own local network
  • -vnc 192.168.1.2:0
    Make it possible to connect with vncviewer to this guest (run this on your desktop: vncviewer 192.168.1.2:0)
  • guest.img
    The name of the image on which you want to install. Create this image with: qemu-img create -f qcow2 guest.img 4G
  • -net nic,model=rtl8139,vlan=0,macaddr=00:16:5e:25:05:17
    Boot kvm guest with virtual RTL8139 network card with mac-address 00:16:5e:25:05:17
  • -net tap,ifname=tap1,script=/etc/qemu-ifup-br0
    Use the tun/tap-network system, with interface /dev/tap1 and the standard bridge-scripting