KVM Virtualization

From New IAC Wiki
Revision as of 23:02, 16 December 2009 by Buckminst (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

KVM Virtualization

Example vmbuilder Commands

The following vmbuilder example will configure a 32bit test VM with 256mb of ram, set up partitions, set up the VM's hostname, set a static IP that's on the virtual bridge for NAT purposes, set up a default user and password, install the 'unattended-upgrades' and 'acpid' packages by default, and run first-boot commands as specified in the filename listed.

The templates used for the VM are stored in the directory the VM is housed in, and can be named whatever, you just need to change the --templates= line to reflect the actual directory.

The vmbuilder.partition and boot.sh files will need to be built and tailored to each VM, or if all of the VMs will use the same settings, you can always just make copies or symlink.

vmbuilder with NAT addressing
vmbuilder kvm ubuntu --suite=karmic --flavour=virtual --arch=i386 --mirror=http://192.168.122.1:9999/ubuntu -o --libvirt=qemu:///system \
  --tmpfs=- --ip=192.168.122.2 --part=vmbuilder.partition --templates=templates --user=superuser --name=Administrator --pass=Phaeyu3u \
  --addpkg=unattended-upgrades --addpkg=acpid --firstboot=boot.sh --mem=256 --hostname=testvm1
vmbuilder with bridged public access
vmbuilder kvm ubuntu --suite=karmic --flavour=virtual --arch=i386 --mirror=http://134.50.87.179:9999/ubuntu -o --libvirt=qemu:///system \
  --tmpfs=- --ip=134.50.87.180 --part=vmbuilder.partition --templates=templates --user=superuser --name=Administrator --pass=Phaeyu3u \
  --addpkg=unattended-upgrades --addpkg=acpid --addpkg=htop --firstboot=boot.sh --mem=1024 --hostname=testvm1 --bridge=br0 --cpus=1
vmbuilder.partition
root 10000
swap 4000

This sets up a 10GB root and a 4GB swap partition for the VM.

boot.sh
passwd -e superuser
apt-get update
apt-get install -qqy --force-yes openssh-server

'passwd -e' expires the user's password, requiring it be changed on first login.

External Links