KVM (Kernel Virtual Machine) is a full virtualization solution for Linux on x86 hardware. It consists of a loadable kernel module, kvm.ko, that provides the core virtualization infrastructure and a processor-specific module, kvm-intel.ko or kvm-amd.ko.
This tutorial will guide you through the steps to install KVM on Ubuntu Server Latest.
Before installing KVM, ensure that your system is up to date. Run the following command on your terminal to update the system packages:
sudo apt update && sudo apt upgrade -y
Now, install KVM and related packages using the following command:
sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
qemu-kvm
provides hardware emulation to launch virtual machines.libvirt-daemon-system
provides a full virtualization service on the host.libvirt-clients
provides clients to access the daemon using rpc.bridge-utils
installs utilities to enable network bridging.Verify the installation of KVM and its related tools by checking the service status:
sudo systemctl status libvirtd
Make sure that the service is running. If not, start the service using the following command:
sudo systemctl start libvirtd
And enable it to start automatically upon boot:
sudo systemctl enable libvirtd
To ensure that KVM is working correctly and the processor has the virtualization extensions enabled, run the following command:
lsmod | grep kvm
The output should display something similar to this:
kvm_intel 274432 0
kvm 663552 1 kvm_intel
After installing KVM and verifying its support, it's time to create a virtual machine to test it. You can use any operating system ISO image.
First, create a new virtual network:
sudo virsh net-create network.xml
Replace network.xml
with the name of the XML configuration file.
Next, create a virtual machine using the following command:
sudo virt-install --name=name_of_vm --ram=2048 --vcpus=2 --cdrom=/path/to/iso --os-variant=ubuntu20.04 --network=default --graphics=vnc
Replace name_of_vm
with the desired name for your virtual machine, and /path/to/iso
with the path to the operating system ISO image.
That's it! You have successfully installed KVM on Ubuntu Server Latest and created a virtual machine. Now you can launch and manage your virtual machine with ease.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!