Example walkthrough of KVM guest creation
Create LCFG profile
A sample KVM guest profile :-
/* circlevm1.inf.ed.ac.uk */
#define FIRST_INSTALL
#include <dice/os/sl7.h>
#include <dice/hw/kvm.h>
#include <dice/options/small-server.h>
#include <dice/options/serialconsole.h>
#include <live/wire_at1.h>
dhclient.mac 00:16:3E:ee:23:4E
Notes:
- Don't just cut and paste the sample profile above - remember to use the correct live/wire header, for example.
- The
small-server.h
header shrinks the root partition to 10GB, and /var/cache/afs to 2GB. This means that for
guests with 4GB of allocated main memory, a disk of 20GB is sufficient (this is kvmtool's default disk size).
-
FIRST_INSTALL
is definitely necessary for the first install of a VM: without it, you'll get the error
[INFO] install: Calling fstab preparedisks /root
[FAIL] fstab: device node /dev/vda1 does not exist (udev problem?)
[FAIL] install: install method failed
sh-4.1#
The define should be removed after the first installation.
- If the wire you require for your guest isn't the default for the host server, you will need to specify the --bridge option to kvmtool when creating the guest
Create KVM guest using kvmtool
The following will create a KVM guest called "circlevm20" on the KVM host "circle" for running SL7. The guest will have
a virtual disk of 20GB (default size) and the default allocation of main memory (currently 4GB). kvmtool will auto-generate (and display) a
MAC address for the guest.
[zip]ascobie: kvmtool create --host circle --name circlevm20
MAC address is 00:16:3E:ee:23:49
Creating image file (this may take some time) ...Vol circlevm20 created
Registering machine
[zip]ascobie:
Remember to copy the generated MAC address into your KVM guest's LCFG profile.
Install the KVM guest
Note that the escape (to the shell) character is ^]
[zip]ascobie: kvmtool start --name circlevm11 --console
Domain circlevm11 started
Connected to domain circlevm11
Escape character is ^]
(usual output for rest of install)
Possible problems
The install fails, but attempts to boot off disk instead of PXE
The default boot order for a KVM guest is "hd,network" (ie disk,PXE). At the initial install, there is no bootloader on the disk so the KVM BIOS skips to booting from PXE. If an install fails once the disk has been partitioned (?), subsequent boots will hang on booting off the disk and the BIOS won' skip to PXE. The solution to this is to temporarily change the bootorder for the KVM guest to "network,hd" :-
kvmtool setbootorder --host circle --name circlevm11 --bootorder "network,hd"
Topic revision: r11 - 27 Apr 2020 - 09:19:16 -
ChrisCooke