How To Install KVM On Ubuntu
How To Install KVM On Ubuntu
In this tutorial, you will learn how to install and set up KVM on Ubuntu.
Prerequisites
• A system running Ubuntu.
• An account with root privileges.
• Access to the terminal.
Provide the root password and wait for the apt package manager to complete the
process.
1. Use the egrep command to check if your CPU supports hardware virtualization. Run
the following command:
If the command returns a value of 0, your processor is not capable of running KVM. On
the other hand, any other number means you can proceed with the installation.
sudo kvm-ok
4. When the installation completes, rerun the command to check KVM acceleration
availability, and if everything is ok, you are ready to start installing KVM.
1. Add the user you want to run the virtual machines to the libvirt group:
For example:
Note: If you need to remove a user from the libvirt or kvm group,
just replace adduser with deluser in the command above.
Step 5: Verify the Installation
Confirm that the KVM installation was successful with the virsh command. The virs
h command is a command-line tool for managing virtual machines on Linux systems.
Run the command below:
The command lists all active and inactive virtual machines on the system. You can
expect an output similar to the one below if you have not yet created any VMs:
Alternatively, use the systemctl command to check the status of libvirtd, the
daemon that provides the backend services for the libvirt virtualization
management system:
If the virtualization daemon is not active, activate it with the following command:
sudo systemctl enable --now libvirtd
Download the ISO with the OS you wish to install on a VM and proceed to pick an
installation method below.
sudo virt-manager
Note: If you are using a bare metal server to run VMs and you want to
connect via SSH, specify the -Y option when establishing the
connection. It enables trusted X11 forwarding, which allows you to run
graphical applications on a remote server and display them on your
local machine securely.
The syntax is:
ssh -Y username@hostname
2. In the Virtual Machine Manager window, click the computer icon in the upper-left
corner to create a new VM.
3. Select the option to install the VM using an ISO image and click Forward.
4. In the next dialogue, click Browse... and navigate to the path where you stored the
ISO you wish to install. Select the ISO and click Forward to continue.
5. Enter the amount of RAM and the number of CPUs you wish to allocate to the VM
and click Forward to proceed to the next step.
6. Allocate sufficient hard disk space to the VM. Click Forward to go to the last step.
7. Specify the name for your VM and click Finish to complete the setup.
The VM starts automatically, prompting you to start installing the OS that's on the ISO
file.
The options behind the command serve to define the parameters of the installation.
Option Description
Conclusion
After reading this guide, you should know how to install KVM on Ubuntu. Additionally,
the article describes two methods of setting up virtual machines, using the virt-
manager GUI and the virt-install command.
Marko Aleksic
Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all
things IT, combined with over a decade long background in writing, teaching and
working in
IT-related
fields, led
him to
technical
writing,
where he
has an
opportunity
to employ
his skills
and make
technology
less
daunting to
everyone.