Linux Virtualization Full Setup and Configuration Guide
Virtualization is a process of running a computer inside another computer. This is done by creating and running a VM (Virtual Machine). There are many ways to do this like VirtualBox, Gnome Box etc. But my preferred way to do it is by installing KVM/QEMU.
The reason for using KVM over others is because KVM can directly work on bare metal ie, it can directly talk to your computer hardware by working closely with the operating system kernel. This makes the VM fast and very responsive compared to others.
In this guide I’ll walk you through the process of installing KVM which stands for Kernel Based Virtual Machines.
Pre-requisites
- A running Linux desktop.
- ISO image of any Windows or Linux OS
Installation
First thing you need to do, is to check if your processor has virtualization support
To do that, run this command in your linux terminal,
LC_ALL=C lscpu | grep Virtualization
If nothing is displayed after running the command, then your processor does not support hardware virtualization, and you will not be able to use KVM. In that case, ensure that virtualization is enabled in your BIOS.
And if the terminal outputs “VT-x” or “AMD-V” then you are good to go!
Installing KVM packages
In the terminal give these commands depending on your linux distribution.
For Arch based distributions
sudo pacman -S qemu virt-manager ebtables
For Ubuntu/Debian based distributions
sudo apt-get install virt-manager
Now enable the “libvirtd” daemon by running
sudo systemctl enable --now libvirtd
Now check if “libvirtd” daemon is enabled by running the command
sudo systemctl status libvirtd
Now we need to make your current user a part of the “libvirtd” group. So use the command,
sudo usermod -a -G libvirtd your_username
In the “your_username” give your linux username.
Now Reboot your computer.
Creating a VM
To use the installed KVM package, open Virt Manager from your linux menu. Follow the below steps to setup your VM.
File > New Virtual Machine
In the popup that opens up select
Local install media (ISO image or CDROM)
click on “Forward” button.
Now click on
Browse
and in the popup choose
Browse Local
and in the popup choose your ISO image you have.
In “Choose the operating system your installing:” just choose
Generic Linux
click on “Forward” button.
In the next window type the amount of
RAM
and
CPU
cores to give your VM
click on “Forward” button.
Now give the VM a
Name
and click on “Finish”
Now a popup will open with your ISO loaded and prompt you to install the OS just like any other OS install.
Continue the OS install process and That’s it!. You now have your very first VM up and running running.
NOTE: If you want to customize or change settings of VM anytime later, you can do it by opening virt manager and then,
right clicking on your VM
Open
in the window that opens go to
Show virtual hardware details
Now u can customize every part of your VM in detail.
Troubleshooting
Here are some tips for combating common issues faced after install.
Resolution Fix
To fix Resolution, go to your VM window which is running the Virtual OS
View > Scale Display > Auto resize VM with window
Now just maximize your window and click on top right icon to make it full screen.
To exit full screen hold “CTRL + ALT” and move mouse to top middle and click on the first icon that appears to exit full screen.
UEFI Binary Missing Fix
To fix uefi binary missing issue in Arch based distributions, we need to install an ovmf package by running this in terminal,
sudo pacman -S ovmf
This is installed by default in Ubuntu/Debian based distributions.
Network default Inactive Fix
To fix network default inactive error, we need to enable the default NAT network of KVM to autostart by doing this,
sudo virsh net-autostart default
Now we start the same default network to work right away
sudo virsh net-start default
This should fix most issues people face at start.
If you still face some issues and your stuck, fill up this Contact form and i will help you out.