Project

General

Profile

Actions

Provision KVM VM without DHCP

This method is similar to the gPXE provisioning method, but the parameters are passed as kernel boot options.

Prerequisites

In order to use direct kernel booting, the vmlinuz and initrd.img files need to exist in a storage pool.

I downloaded the two available for CentOS 6.0.

cd /var/lib/libvirt/images
wget http://mirror.centos.org/centos/6/os/x86_64/isolinux/vmlinuz
wget http://mirror.centos.org/centos/6/os/x86_64/isolinux/initrd.img

Using virt-manager

From within the virtual machine's details, select the Boot Options. Expand Direct kernel boot and enter the following information. Replace the IP addresses with those specific to your setup

Kernel path: /var/lib/libvirt/images/vmlinuz
Initrd path: /var/lib/libvirt/images/initrd.img
Kernel arguments: ks=http://foremanserver.tld/unattended/provision?static=yes ksdevice=bootif network kssendmac ip=192.168.1.2 netmask=255.255.255.0 gateway=192.168.1.1 dns=192.168.1.1

command line using virsh

To make these changes edit the virtual machine's XML file through virsh

virsh edit domain

Below are the relevant lines, replace the IPs with those of your setup


  <os>
    <type arch='x86_64' machine='rhel6.0.0'>hvm</type>
    <kernel>/var/lib/libvirt/images/vmlinuz</kernel>
    <initrd>/var/lib/libvirt/images/initrd.img</initrd>
    <cmdline>ks=http://foremanserver.tld/unattended/provision?static=yes ksdevice=bootif network kssendmac ip=192.168.1.2 netmask=255.255.255.0 gateway=192.168.1.1 dns=192.168.1.1</cmdline>
    <boot dev='hd'/>
  </os>

Updated by Leos Stejskal over 2 years ago · 5 revisions