How to setup KVM full virtualization solution

Today I want to install Debian on an older but quite capable Dell machine so I will shortly describe how to setup KVM full virtualization solution.

Preparations

At first you need to confirm that CPU has the Virtualization Technology capability. You can do this by looking for vmx (Intel VT-x) or svm (AMD AMD-V) flag in the /proc/cpuinfo file.

If you want to investigate this part further then I strongly suggest to look at the CPU Checker source code.

Step 1

Perform minimal Debian installation. Create separate partition mounted at the /var/lib/libvirt/ directory. It will be used to store settings and storage pools so allocate most of the free space to it.

Step 2

Install sshd server.

# apt-get install openssh-server

Disable root login over ssh protocol and reload configuration.

# sed -i "/PermitRootLogin/ s/yes/no/" /etc/ssh/sshd_config
# service sshd reload		

Step 3

Install sudo utility.

# apt-get install sudo 	

Add regular user created during installation process to the sudo group.

# adduser milosz sudo

Now you are able to use sudo utility to perform administrative tasks instead of root account.

Step 4

Install software essential to the full virtualization.

$ sudo apt-get install kvm libvirt-bin virtinst bridge-utils

Add regular user to the libvirt group.

$ sudo adduser milosz libvirt

Now you are able to manage virtual machines as regular user.

Step 5

Edit network configuration file to create initial bridge.

$ sudo vi /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 
  address 192.168.1.10
  netmask 255.255.255.0
  gateway 192.168.1.1

Edit /etc/resolv.conf file to apply DNS configuration.

$ sudo vi /etc/resolv.conf
nameserver 192.168.1.1	

Reboot system, verify network settings and ssh availability.

Step 6

Install virt-manager package on remote system and use it to manage virtual machines.

References

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system. He is also open for new opportunities and challenges.

Gdansk, Poland https://sleeplessbeastie.eu