Domain Creation

A domain is where the KVM Guest is running. Creating a new domain is just one simple command. virt-install. It takes a lot of parameters though, so it is adviseable to read the virt-install manpage.


Use the following script to create your domains.

   1 #!/bin/sh
   3 NAME="stretch-template"
   4 RAM="1024"
   5 LVM_SIZE="4G"
   6 LVM_GROUP="vg_storage"
   7 GRAPHICS_PROTOCOL="spice" #spice, vnc
   8 OS="debian9"
   9 MEDIA="/mnt/media/debian/stretch/debian-9.1.0-amd64-netinst.iso"
  11 if [ $# -gt 0 ]
  12 then
  13         NAME=${1}
  14 fi
  15 LVM_NAME="kvm_${NAME}_vda"
  17 if [ ! -e /dev/${LVM_GROUP}/${LVM_NAME} ]
  18 then
  19         # create lvm partition
  20         lvcreate --size ${LVM_SIZE} --name ${LVM_NAME} ${LVM_GROUP}
  21         # create the domain
  22         virt-install --name ${NAME} --memory ${RAM} --disk /dev/${LVM_GROUP}/${LVM_NAME},bus=virtio,format=raw --os-variant ${OS} --network bridge=br0,model=virtio --cdrom ${MEDIA} --graphics ${GRAPHICS_PROTOCOL},listen=,password=${NAME} --noautoconsole --virt-type kvm
  23 else
  24         echo "${0}: refusing to overwrite existing domain"
  25 fi



Give the domain its name. This name is used by the virsh software as a reference to the domain.


The amount of memory for the domain. Setting a high value to make the installation run smoother can be a good idea. It is possible to lower the memory later on.


The place where the domain has its virtual disk. Here it is an lvm volume using the raw format, but other formats can be used.


Determines the OS running in the domain.


Configure the network interface.


Set the installation media.


Configure the domain console.


Do not try to connect to the guest console, just start the domain.


Set the hypervisor.

None: Domain Creation (last edited 2018-01-03 21:05:30 by Kristian Kallenberg)