How to Install KVM on Ubuntu Server Latest
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.
Prerequisites
- A server running Ubuntu Latest with root access.
- At least 1 GB of RAM.
- A processor with virtualization extensions enabled.
Step 1: Update the System
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
Step 2: Install KVM and Virtualization Tools
Now, install KVM and related packages using the following command:
sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
qemu-kvmprovides hardware emulation to launch virtual machines.libvirt-daemon-systemprovides a full virtualization service on the host.libvirt-clientsprovides clients to access the daemon using rpc.bridge-utilsinstalls utilities to enable network bridging.
Step 3: Verify Installation and Start LibVirt service
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
Step 4: Check KVM Hardware Support
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
Step 5: Create a Virtual Machine
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.
Conclusion
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.