Example walkthrough of KVM guest creation

Create LCFG profile

A sample KVM guest profile :-

  /* fargovm1.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_s32.h>

  dhclient.mac       00:16:3E:ee:23:4E  

Create KVM guest using kvmtool

The following will create a KVM guest called "fargovm20" on the KVM host "fargo" 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 fargovm20 --bridge (as appropriate - see notes below)
MAC address is 00:16:3E:ee:23:49
Creating image file (this may take some time) ...Vol fargovm20 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 fargovm11 --console 
Domain fargovm11 started
Connected to domain fargovm11
Escape character is ^]
(usual output for rest of install)

Notes

  1. If the wire which your guest will use is not the same as its KVM server's default wire, remember to specify the --bridge option to kvmtool when creating the guest. If you don't, there will be a mismatch between the wire the guest wants, and the wire it gets.
  2. Don't just cut and paste the sample profile above - remember to use the correct live/wire header, for example.
  3. 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).
  4. 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.

Possible problems

You start up the VM, but get no output.

You may have got the networking wrong. Does the wire file you've included in the profile match the wire which the machine is using in the DNS? And did you remember to specify this with the --bridge option in the kvmtool create command line? (You can miss out the --bridge option if your VM is on that KVM server's default wire - but if it's not, you must use --bridge.)

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 fargovm11 --bootorder "network,hd"
Edit | Attach | Print version | History: r14 < r13 < r12 < r11 < r10 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r13 - 27 Apr 2020 - 14:19:45 - IanDurkacz
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
This Wiki uses Cookies