Example walkthrough of KVM guest creation

Create LCFG profile

A sample KVM guest profile :-

  /* circlevm1.inf.ed.ac.uk */


  #include <dice/os/sl6_64.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  


  1. Don't just cut and paste the sample profile above - remember to use the correct live/wire header, for example.
  2. The small-server.h header shrinks the root partition to 10GB, and /var/cache/afs to 2GB. This means that for guests with less than 4GB of allocated main memory, a disk of 15GB is sufficient (this is kvmtool's default disk size).

  3. 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
    The define should be removed after the first installation.

  4. 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 64bit SL6. The guest will have a virtual disk of 15GB (default size) and the default allocation of main memory (currently 1024MB). kvmtool will auto-generate (and display) a MAC address for the guest.

[zip]ascobie: kvmtool create --host circle --name circlevm20 --flavour sl6_64 
MAC address is 00:16:3E:ee:23:49
Creating image file (this may take some time) ...Vol circlevm20 created

Registering machine

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 ^]
PXELINUX 4.03 2010-10-22  Copyright (C) 1994-2010 H. Peter Anvin et al

School of Informatics Linux Installer

The following boot options are available:

sl5:- boot to the sl5 install system

sl5serial:- boot to the sl5 install system (with serial console)

sl564:- boot to the sl5_64 install system

sl564serial:- boot to the sl5_64 install system (with serial console)

f13:- boot to the f13 install system

f13serial:- boot to the f13 install system (with serial console)

f1364:- boot to the f13_64 install system

f1364serial:- boot to the f13_64 install system (with serial console)

sl6:- boot to the sl6 install system

sl6serial:- boot to the sl6 install system (with serial console)

sl664:- boot to the sl6_64 install system

sl664serial:- boot to the sl6_64 install system (with serial console)

hdt:- Hardware Detection

hdtserial:- Hardware Detection (with serial console)

memtest:- Memory Tester

memtestserial:- Memory Tester (with serial console)

dban:- Disk Wipe Tool

dbanserial:- Disk Wipe Tool (with serial console)
boot: sl6serial
Loading /kernel-install-sl6/vmlinuz......
Loading /kernel-install-sl6/initram.img..............................ready.
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Linux version 2.6.32-131.6.1.el6.x86_64 (mockbuild@sl6.fnal.gov) (gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC) ) #1 SMP Tue Jul 12 17:12:20 CDT 2011

usual output for rest of install

Possible problems

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"

-- AlastairScobie - 15 Nov 2011 Updated ChrisCooke 18 Jul 2012

Edit | Attach | Print version | History: r14 | r12 < r11 < r10 < r9 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r10 - 29 Nov 2012 - 09:17:23 - StephenQuinney
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