Differences between revisions 1 and 15 (spanning 14 versions)
Revision 1 as of 2017-10-12 20:28:58
Size: 1102
Editor: shran
Comment:
Revision 15 as of 2017-11-11 22:23:26
Size: 1938
Editor: shran
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
A domain is really the virtual machine. Creating a new domain is just one simple command. `virt-install`. It takes a lot of parameters though, so I created a script to make domain creation a bit easier. 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.
Line 5: Line 5:
{{{ == Creating ==
Use the following script to create your domains.

`domain_create.sh`
{{{#!highlight bash
Line 7: Line 11:
Line 15: Line 20:
if [ $# -eq 0 ] if [ $# -gt 0 ]
Line 17: Line 22:
        echo "${0}: domain-name"
else
Line 25: Line 28:
Line 28: Line 30:

# create the virtual machine
        # create the domain
Line 32: Line 33:
        echo "${0}: refusing to overwrite existing domain";         echo "${0}: refusing to overwrite existing domain"
Line 35: Line 36:
== Parameters ==
||`--name`||Give the domain its name. This name is used by the virsh software as a reference to the domain.||
||`--memory`||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.||
||`--disk`||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.||
||`--os-variant`||Determines the OS running in the domain.||
||`--network`||Configure the network interface.||
||`--cdrom`||Set the installation media.||
||`--graphics`||Configure the domain console.||
||`--noautoconsole`||Do not try to connect to the guest console, just start the domain.||
||`--virt-type`||Set the hypervisor.||

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.

Creating

Use the following script to create your domains.

domain_create.sh

   1 #!/bin/sh
   2 
   3 NAME="stretch-template"
   4 RAM="1024"
   5 LVM_SIZE="4G"
   6 LVM_GROUP="vg2"
   7 GRAPHICS_PROTOCOL="spice" #spice, vnc
   8 OS="debian9"
   9 MEDIA="/mnt/media/debian/stretch/debian-9.1.0-amd64-netinst.iso"
  10 
  11 if [ $# -gt 0 ]
  12 then
  13         NAME=${1}
  14 fi
  15 LVM_NAME="kvm_${NAME}_vda"
  16 
  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=192.168.1.33,password=${NAME} --noautoconsole --virt-type kvm
  23 else
  24         echo "${0}: refusing to overwrite existing domain"
  25 fi

Parameters

--name

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

--memory

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.

--disk

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.

--os-variant

Determines the OS running in the domain.

--network

Configure the network interface.

--cdrom

Set the installation media.

--graphics

Configure the domain console.

--noautoconsole

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

--virt-type

Set the hypervisor.

None: Domain Creation (last edited 2021-12-31 11:56:37 by Kristian Kallenberg)