- How To Install KVM On Ubuntu 20.04 / Linux Mint 20
- Prerequisites
- VT Support
- Create Network Bridge For KVM
- Install KVM
- Create Virtual Machine
- User Permission
- Create VM
- Command Line
- Graphical Mode
- Manage Virtual Machine
- Conclusion
- How to Install KVM on Linux Mint 21?
- Guide
- How to Create a Virtual Machine(VM) in KVM?
- Conclusion
- About the author
- Karim Buzdar
- Linux mint qemu kvm
- Problem
- Solution
- Share this:
- Like this:
- Related
- About krzysztoftomaszewski
- 4 Responses to How to install KVM/QEMU on Linux Mint 20.1
How To Install KVM On Ubuntu 20.04 / Linux Mint 20
KVM is a hypervisor module in the Linux Kernel that helps you run multiple virtual machines on a Linux machine with the help of virtualization extensions.
KVM supports the wide variety of guest operating systems such as Linux, Windows, Unix family OSes, and much more. You can manage virtual machines using the command line or available graphical tools.
Virt-Manager (Virtual Machine Manager) is the graphical application for managing KVM based virtual machines. It supports creating, starting, stopping, and managing virtual machines, as well as the migration of virtual machines between KVM hosts.
Prerequisites
VT Support
KVM will work only if the system CPU has the support of hardware virtualization, either Intel VT or AMD-V.
To find out whether your CPU supports VT features, run the following command.
egrep -c '(vmx|svm)' /proc/cpuinfo
If the above command returns nonzero, then your hardware supports VT else it does not.
Create Network Bridge For KVM
The bridged network is a dedicated network interface to a virtual machine that helps virtual machines to connect outside the host machine.
Let us list the available network connections.
NAME UUID TYPE DEVICE Wired connection 1 fbbdd6f9-0970-354e-8693-ff8050a85c77 ethernet enp0s3
Now, we will create a virtual bridge network br0 with the help of physical interface enp0s3 .
sudo nmcli con add ifname br0 type bridge con-name br0 sudo nmcli con add type bridge-slave ifname enp0s3 master br0
Next, we will assign the IP address of the physical interface to the bridge interface as the Bridge network interface will act as the primary network interface of your host system.
sudo nmcli con mod br0 ipv4.addresses 192.168.0.10/24 sudo nmcli con mod br0 ipv4.gateway 192.168.0.1 sudo nmcli con mod br0 ipv4.dns "8.8.8.8","192.168.0.1" sudo nmcli con mod br0 ipv4.method manual
KVM requires a few additional network settings. So, set them.
sudo nmcli con modify br0 bridge.stp no sudo nmcli con modify br0 bridge.forward-delay 0
Disable the physical interface and enable the network bridge.
sudo nmcli con down "Wired connection 1" && sudo nmcli con up br0
Run the above command in the system terminal as you may lose SSH sessions when running them remotely.
Finally, check the network connections.
Output: NAME UUID TYPE DEVICE br0 ee117099-4935-4dde-a1f5-4981b0d9585e bridge br0 bridge-slave-enp0s3 492b5c81-e59d-4150-9b24-0348cd0dd87c ethernet enp0s3 Wired connection 1 fbbdd6f9-0970-354e-8693-ff8050a85c77 ethernet --
Install KVM
Update the repository cache.
Install the below packages for KVM set up.
sudo apt install -y virt-manager virt-viewer qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
Create Virtual Machine
User Permission
Ensure users are part of the libvirt group to create virtual machines. Use id command to check if the user is part of the libvirt group.
uid=1000(raj) gid=1000(raj) groups=1000(raj),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(lxd),132(sambashare),134(libvirt)
If the user is not part of libvirt group, follow anyone the steps to fix it.
To add an existing user to libvirt group.
sudo usermod -aG libvirt raj
If you are creating a new user, use the below command.
sudo useradd -m -d /home/user_name -s /bin/bash -G libvirt user_name
Create VM
Once you have installed KVM and other tools, it is all set to start our first virtual machine.
Command Line
virt-install --name=centos_8_2 --ram=2048 --vcpus=1 --os-type=linux --os-variant=centos8 --cdrom=/tmp/CentOS-8.2.2004-x86_64-minimal.iso --network bridge=br0 --graphics vnc,listen=0.0.0.0 --noautoconsole --disk path=/var/lib/libvirt/images/centos_8_2.qcow2,size=10
Starting install. Allocating 'centos_8_2.qcow2' | 10 GB 00:00:00 Domain installation still in progress. You can reconnect to the console to complete the installation process.
You can use the VNC viewer to connect to the virtual machine console and complete the OS installation.
You can also use Virtual Machine Manager to take a virtual machine console.
Graphical Mode
Activities » Search for Virtual Machine Manager.
Run virt-manager command in the terminal and bring up the Virtual Machine Manager.
Once it is opened, go to File » New Virtual Machine. The Virtual Machine Manager will start a new virtual machine wizard.
Choose how you would like to install the operating system. Here I chose to install it from ISO image or CD-ROM.
Browse to the location of the ISO image by clicking on Browse and then Browse Local and select the ISO image.
The new virtual machine wizard will try to detect the operating system based on your OS image. If not, search for an operating system version by typing the OS version.
Configure CPU and memory allocation for the virtual machine.
Here, mention the amount of storage you want to assign to a virtual machine. Additionally, you can change the location of the disk image as per your requirement.
On this page, you will get a summary of the virtual machine.
Click the Network selection and ensure the bridged adaptor we created earlier is chosen for the virtual machine. Finally, click on Finish.
Virtual Machine Manager will begin the creation of a virtual machine depends on our input. Once the VM is created, Virtual Machine Manager will start the console for OS installation.
Manage Virtual Machine
With the help of Virtual Machine Manager, you can perform a virtual machine’s life cycle actions such as start, power off, reset, clone, and migration by right-clicking on the selected virtual machine.
You can view and manage a virtual machine by clicking the info icon in the virtual machine console. Here you can add, remove, and modify devices connected to a virtual machine.
Conclusion
That’s All. I hope you have learned how to install KVM on Ubuntu 20.04 / Linux Mint 20 and create a virtual machine with Virtual Machine Manager and command-line mode.
How to Install KVM on Linux Mint 21?
“Today, we will learn how to install KVM on Linux Mint 21 using the command line. KVM is a complete virtualization solution for Linux on x86 hardware. Using this, we can easily create Virtual Machines just like we do in VMware or VirtualBox. The best part about KVM is that it is open source and more efficient than its rival virtualization solutions.”
We have used basic Linux commands implemented on Linux Mint’s Terminal to install KVM. Let’s see how it is done!
Guide
Following are the steps involved in installing KVM on Linux Mint 21:
Step 1: Update and Upgrade Linux Mint
Before installing KVM, it is recommended to update your system and upgrade it. The following commands will help us in updating and upgrading our Linux Mint machine:
Step 2: Check System Compatibility With KVM
Next, we need to check whether KVM is compatible with our system or not. If it is not compatible, then we’ll keep running into errors.
If you get an output above 0, that means KVM is compatible with your system and can be easily installed. In our case, we got an 8. This means we can install KVM on our system.
Step 3: Install KVM
Now that we have made sure that KVM can be installed, let’s install it by executing this command:
Step 4: Add Your User to the KVM and Libvirt Group
It is now time to add your user to KVM and libvirt group to set up KVM so that you don’t run into any permissions-related errors. Add the user to the KVM group like this::
Add the user to the libvirt group with this command:
How to Create a Virtual Machine(VM) in KVM?
Now that we have installed KVM let’s see how we can create a VM on it. First, download the iso you want to create a VM of. We have downloaded an iso for Ubuntu 20.04.
Now open Virtual Machine Manager on your machine. This is how the interface will appear:
Click on File; you will see a list of options to choose from. Now click on New Virtual Machine:
This window will open with a list of options to choose from for your VM:
Please select the first option, as it allows you to create a VM using an ISO image. Once selected, click Forward.
Now select the iso that you downloaded, as shown below:
After that, allot memory and CPU utilization for the VM like this:
Next, allot storage to the VM:
Now, give the VM a name. For example, if the VM is Ubuntu, you can name it Ubuntu, followed by its version.
These are all the settings that were required. Click on Finish to finish the VM setup. The VM creation process will begin after that.
Once the VM is created, a new window will open for OS installation. You can then install the OS easily.
Conclusion
In today’s guide, we saw in detail how to install KVM on Linux Mint 21. We began by updating and upgrading the system. Then we verified KVM compatibility. Afterward, we installed KVM on our machine. In the end, we also saw how to create a Virtual Machine on KVM.
About the author
Karim Buzdar
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.
Linux mint qemu kvm
From time to time I want to run a virtual machine on my computer, a sandbox containing another operating system with some programs running in total isolation. Under Linux my answer for this need is a set of three components:
- KVM – a virtualization module in the Linux kernel that allows the kernel to function as a hypervisor. (Wikipedia)
- QEMU – a machine emulator and virtualizer that can perform hardware virtualization. It can cooperate with KVM to run virtual machines at near-native speed (Wikipedia)
- Virtual Machine Manager – a nice GUI to use above things as simply as possible.
Problem
How prepare all above components on a fresh installation of Linux Mint 20.1?
Solution
This solution is based on the article “Install KVM Virtualization on Linux Mint 20” with my additions.
First execute following commands:
sudo apt-get install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager sudo adduser $USER libvirt sudo adduser $USER kvm sudo adduser $USER libvirt-qemu
Here the above-mentioned article claimed everything is ready and working. But it wasn’t in my case. So just restart Linux now. Then proceed with verification steps:
systemctl status libvirtd.service
The output should start with following lines:
● libvirtd.service - Virtualization daemon Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2021-02-03 22:54:41 CET; 31s ago
Then start Virtual Machine Manager. It should show that it is connected to KVM/QEMU. It should look like this:
Share this:
Like this:
Related
About krzysztoftomaszewski
I’ve got M.Sc. in software engineering. I graduated in 2005 at Institute of Computer Science, Warsaw University of Technology, Faculty of Electronics and Information Technology. I’m working on computer software design and engineering continuously since 2004.
This entry was posted in Linux and tagged kvm, qemu, virt-manager, virtual machine. Bookmark the permalink.
4 Responses to How to install KVM/QEMU on Linux Mint 20.1
Hello To share the libraries such as copy/paste, devices, folders, etc, from the virtualized machine wath the main system, what else should I do? Greetings
This works except all I had to do was “sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager”, reboot, and it just worked. @ Dero ; I had the same issue and while I suspect it’s possible to get other methods working I just setup a basic Samba share on the host Mint 20 machine and then from the Windows (Win10) virtual machine I just did the following (without the “) on the section you can type stuff in bottom left area of screen… “\\192.168.1.100\” (or whatever is the IP of the machine running Samba) and it showed the folder name I was sharing and I select it and it just worked (since I did not setup any username/password stuff anyone on my network can access that share straight up). because trying to setup a more standard way of sharing seems more difficult on this QEMU/KVM than in VirtualBox.
You don’t have to reboot. Just log out of the GUI and log back in and your user’s groups will be refreshed and you’re GTG.