Setting up a Server with KVM

I am using kvm on my server to put the applications into different virtual machines. For this i currently try to setup my own tool Mission
that can be found on github.
This Tool is currently under development and is tailored for my special needs.

On all machines i install some default applications like

apt-get install screen vim-nox htop nmon strace update-manager-core logcheck rkhunter etckeeper logrotate

On the Main server you need to install

apt-get install libvirt-bin qemu-kvm python-vm-builder

I use a static ip for my virtual machines. For this i change the default network to have some spare addresses that are not used for dhcp.

Change the range of the dhcp from the default network. I changed the start from .2 to .150, so the first 149 addresses are not used for dhcp. After typing virsh -c
qemu:///system type:

net-edit default

And change:

<range start='' end='' />

I install my virtual machines into an lvm volume. This has higher performance than using a file but the disk space is directly fully used.

To get a new lvm volume you need to have a valid volume group. If your volume group is vg0, than just type:

lvcreate -L 40G --name app1 vg0

This will create a volume with 40GB space and name it app1. This will be available under /dev/vg0/app1

To create a vm inside it just type

vmbuilder kvm ubuntu –arch ‘amd64’  –mem ‘1024’  –rootsize ‘38912’  –swapsize ‘2048’  –kernel-flavour ‘virtual’ –hostname app1 –ip –raw
/dev/vg0/app1 –components ‘main,universe,restricted’ –mirror ‘’ –user www –addpkg
openssh-server,vim-nox,acpid,screen,htop,unattended-upgrades,puppet,linux-image-generic –libvirt qemu:///system –suite raring

The rootsize+swapsize must fit into the logical volume. If you are not using hetzner you can change the mirror or leave it empty. After this command finishes you have your vm
ready. The default password is ubuntu and should be changed directly afterwords. The server is accessible from the main server via ssh with

ssh www@

Mission Control does already some of these steps for me. It also tries to setup puppet and authorize it directly. But as stated before it is just under heavy development with
some static dependencies directly to Ubuntu.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *