Category: Virtualization

March 30th, 2015 by ronny

virtual-dvd-drive-iconKVM virtualisation is a Kernel based virtualisation. It actually stands for Kernel-based Virtual Machine. It means that each of your virtual machine will have it´s own virtual hardware, such as network card, graphic card, memory and hard drive.

To setup KVM virtualisation it require a multicore cpu. And virtualisation needs to be activated in the BIOS. Look for virtualisation, Intel VT-x (vmx) or AMD-v settings, and enable it. You might be able to install KVM without virtualisation enabled in the BIOS. But the virtual machines will be extremely slow.

Here is how to install KVM on a minimal Debian installation.

First we assume a ssh server is installed, and sudo.

Step 1:
First we install the essential packages for KVM.
apt-get install kvm libvirt-bin virtinst bridge-utils

If you want to be able to controll the virtual machines from your own users instead of root. Add your user to the libvirt group.
adduser john libvirt

Step 2:
To be able to give network access to your virtual computers you will need to bridge your network card. To do this we will change the network interface file. (Change the ip´s to match your network)
nano /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
iface eth0 inet manual

# Initial bridge
auto br0
iface br0 inet static
bridge_ports eth0

Now you need to reboot your system and verify you can access from ssh and that it has the network accesses you need.

Check out my previous article about how to install libvirt manager on how to create and control the virtual machines.

That´s it for installing KVM on a Debian.

Happy virtualisation!

Posted in Debian, KVM, Linux, Ubuntu, Virtualization

December 28th, 2014 by ronny

virtual-desktop-2-iconI prefer using a gui when controlling my virtual machines. Learning how to control them in the most basic way from the command line or terminal is easy. It is very self explanatory once you know about the virsh command. I have made some examples below on how to use these commands.

Here is the list of basic commands to start, stop and reboot your virtual machines.

List your running guests

virsh list
[sourcecode language=”text”]
Id Name State
2 apt-cacher.home running

List all guests:

virsh list –all
[sourcecode language=”text”]
Id Name State
2 apt-cacher.home running
– db1.home shut off
– db2.home shut off
– devlab.home shut off
– minecraft.home shut off
– vault.home shut off
– web.home shut off

To start a vm

we can only use their vm name to start them.
virsh start db1.home

To reboot a vm

We can use name or id to reboot the vm.
virsh reboot 2
virsh reboot apt-cacher.home

To stop or shutdown a vm

virsh shutdown 2
virsh shutdown apt-cacher.home

To shutdown or stop an unresponsive or crashed vm

virsh destroy 2
virsh destroy apt-cacher.home

To get information about your vm

virsh dominfo 2
virsh dominfo apt-cacher.home
[sourcecode language=”text”]
Id: 2
Name: apt-cacher.home
UUID: f194bb17-5f0e-21f5-f712-8a98edd4f1d8
OS Type: hvm
State: running
CPU(s): 1
CPU time: 332.8s
Max memory: 262144 KiB
Used memory: 262144 KiB
Persistent: yes
Autostart: enable
Managed save: no
Security model: apparmor
Security DOI: 0
Security label: libvirt-f194bb17-5f0e-21f5-f712-8a98edd4f1d8 (enforcing)
Happy controlling!

Posted in Debian, KVM, Linux, Linux Mint, Ubuntu, Virtualization

June 11th, 2014 by ronny

kvm-logoThe Virtual Machine Manager is a small powerful tool when it comes to handling your kvm guests. To install the Virtual Machine Manager we do:
apt-get install virt-manager

It is now ready to run. However to connect to your KVM hosts you need also to install a ssh askpass software.
apt-get install ssh-askpass

First time you connect to your host you need to confirm the fingerprint. If you have accessed the host via ssh, and done re-installs, chances are the fingerprint won’t match. One simple solution to this is to delete the known_hosts file, or modify it if you are comfortable doing that. Normally on a Debian based system it’s located (example assume user is jondoe): /home/jondoe/.ssh/known_hosts

Happy Virtualization!

Posted in Debian, KVM, Linux Mint, Ubuntu, Virtualization

November 4th, 2013 by ronny


Create the virtual machine, named MySQL in this example:
VBoxManage createvm –name “MySQL” –register

We give it 512MB ram, enable acpi, boot on dvd and a bridged network card:
VBoxManage modifyvm “MySQL” –memory 512 –acpi on –boot1 dvd –nic1 bridged –bridgeadapter1 eth0

Create the virtual hard drive (Size in MB):
VBoxManage createhd –filename MySQL.vdi –size 10000

Set up the IDE controllers for the DVD player and the hard drive. We also mount an Debian 7 iso image into the dvd player:
VBoxManage storagectl “MySQL” –name “IDE Controller” –add ide

VBoxManage storageattach “MySQL” –storagectl “IDE Controller” –port 0 –device 0 –type hdd –medium MySQL.vdi

VBoxManage storageattach “MySQL” –storagectl “IDE Controller” –port 1 –device 0 –type dvddrive –medium /home/debian-7.1.0-i386-netinst.iso

The virtual machine should now be ready to run.
If you haven’t allready, installing screen would be handy. So you can free up your console if you like. apt-get install screen


To run the virtual machine from our example.
screen vboxheadless –startvm “MySQL”
You can now press ctrl+a and then ctrl+d to deattach from the process and have access to console again.

To stop the virtual machine you can do this.
vboxmanage controlvm “MySQL” poweroff

To unmount the installation iso, you can do that like this.
VBoxManage storageattach “MySQL” –storagectl “IDE Controller” –port 1 –device 0 –type dvddrive –medium none

To have your virtual machine to start up automaticly on boot. Add this to your boot script: vboxmanage startvm “MySQL” –type headless


If you need for some reasons to remove your virtual machine. You need to start with unregistering the hard drive, and then delete it. Then you can unregister the virtual machine and remove it. Here is how.
To list the hard drives: vboxmanage list hdds
Remove the hard drive: vboxmanage modifyvm “MySQL” –hda none
Find the UUID for the hard drive: vboxmanage showvminfo “MySQL” | grep vdi*
Unregister the hard drive: vboxmanage unregisterimage disk f3620364-399d-413b-b08e-d8b2f13392f0
Delete the hard drive file (of course use your own location): rm -rf /home/MySQL.vdi
Unregister the virtual machine: vboxmanage unregister vm MySQL

Your virtual machine and virtual hard drive is now gone.

Happy imagining!

Posted in Debian, Linux, VirtualBox, Virtualization

November 4th, 2013 by ronny

virtualbox_logoI find Virtualbox easy to work with, and usually stable. For performance I would check out KVM or XEN HVM instead. Update! The larger Linux distros are skipping XEN for KVM in latest versions.

Anyway, let’s get it in there.
Add it to the repository:
vim /etc/apt/sources.list

Add this line to the bottom of the sources file:
deb wheezy contrib

To add the public key:
wget -q -O- | apt-key add –

Time to update package list:
apt-get update

Ready to install VirtualBox:
apt-get install linux-headers-$(uname -r) build-essential virtualbox-4.2 dkms

VirtualBox is now installed. We want to add the extention pack, so we can install guest systems via remote desktop. Download current version of the extionpack:

If you need to run on another use than root:
adduser hostman(or any user you want) vboxusers

Your system is now ready to run. Ready to create and start guest systems.

Happy computing!

Posted in Debian, Linux, VirtualBox, Virtualization