Skip to content

Home Lab

Notes from my learning sessions

Menu
Menu

Installing KVM

Posted on September 27, 2021March 1, 2022 by sandeep

Pre-requisite

  • Install Debian 11 or Ubuntu 20.04 server as required.

Optional

  • I had upgraded the kernel version by compiling the kernel as explained in this how-to.

Installing KVM on Debian

Simple and easy – First, install the required packages

apt install -y qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon virt-manager

Additionally, I had installed  libguestfs-tools,  for customizing VMs before spinning up VMs

apt install -y libguestfs-tools

Bridge interfaces allow the guest VMs to communicate through the HOST., and connect to the real network. You will first need to allow IP forwarding in the kernel params. Edit /etc/sysctl.conf and uncomment the following configuration

net.ipv4.ip_forward=1 

Configure the bridge interfaces. In my case, I have four servers and all have 4 x 1 G NICs plus 2 x 10G NICs.

My choice: The first 1G NIC will not be bridged and used for server management.  All other 3 1G NICs would be bridged, for use by VMs hosted on the server. All VMs will be configured with a minimum of 1 bridged 1G NIC for management of the VM.  Contents of /etc/network/interfaces. Gateway Info, IP Adress used are based on my local setup.  DNS configuration is done as part for installing servers.

source-directory /etc/network/interfaces.d
auto eno1
iface eno1 inet static
address 10.99.1.3/16
gateway 10.99.0.1

auto eno2
iface eno2 inet manual

auto eno3
iface eno3 inet manual

auto eno4
iface eno5 inet manual

#10 G Ports - Set mtu to 9000 - supported by NIC
auto enp4s0

iface enp4s0 inet manual
mtu 9000

auto enp5s0
iface enp5s0 inet manual
mtu 9000

auto br2
iface br2 inet manual
bridge_ports eno2
bridge_stp off
bridge_waitport 0
bridge_fd 0

auto br3
iface br3 inet manual
bridge_ports eno3
bridge_stp off
bridge_waitport 0
bridge_fd 0

auto br4
iface br4 inet manual
bridge_ports eno4
bridge_stp off
bridge_waitport 0
bridge_fd 0

auto br5
iface br5 inet manual
bridge_ports enp4s0
bridge_stp off
bridge_waitport 0
bridge_fd 0

auto br6
iface br5 inet manual
bridge_ports enp5s0
bridge_stp off
bridge_waitport 0
bridge_fd 0


Optional: NIC bonding as required, click here for a how-to.  

Normally the config for a virtual network called “default” is installed as part of the libvirt package, and it is set up to autostart when libvirtd is started.  On reboots it is better to enforce auto start.

virsh net-start default
virsh net-autostart default

What is Vhost_net?
 
vhost-net is a character device that can be used to reduce the number of system calls involved in virtio networking. vhost-net moves network packets between the guest and the host system using the Linux kernel, bypassing QEMU
modprobe vhost_net
echo vhost_net | tee -a /etc/modules

Better to disable AppArmor – all service behind UTM device

systemctl stop apparmor
systemctl disable apparmor
apt remove -y apparmor

Recent Posts

  • Ceph + KVM: 4. Orchestrating Ceph RBD backed VMs on KVM Hosts
  • Rabbit MQ Cluster + HAProxy + Keepalived
  • Install and configure MariaDB / Galera cluster
  • Ceph + KVM : 3. Installing KVM, cutsomized monitoring scripts
  • Ceph + KVM : 5. Service checks and CLI commands
  • Ceph + KVM : 2. Installation – Ceph Storage
  • Ceph + KVM : 1. Planning and preparing for Ceph Storage
  • Openstack Xena on Ubuntu 20.04 – Cinder
  • Preparing custom Debian 11 MATE image
  • Setup Ubuntu 20.04 repository mirror server

Archives

  • April 2025
  • March 2025
  • October 2024
  • September 2024
  • April 2022
  • March 2022
  • February 2022
  • December 2021
  • October 2021
  • September 2021
  • October 2020
  • February 2020
  • January 2020
  • December 2019
© 2025 Home Lab | Powered by Minimalist Blog WordPress Theme