How to Install QEMU on Ubuntu to Set Up a Virtual Machine

May 2024 ยท 3 minute read

Virtualization is a neat way to use both Linux and Windows at once, getting the best of both worlds without having to tackle dual booting and all the issues that come with it.

VirtualBox and VMware are household names when it comes to the best virtualization solutions. But did you know that there are alternatives as well? QEMU is one such free and open-source alternative for you to try, should you wish to explore.

Prerequisites to Install QEMU on Linux

Before installing any software packages in Linux, it's important to update the repositories and upgrade the system. This decreases the chances of downloading insecure and incompatible software.

Fire up the terminal in Ubuntu and type in these commands to update the software repositories:

sudo apt update && upgrade 

Type in Y or Yes when prompted for permission and let the system upgrade finish up. Once you've updated and upgraded your system, there's just one more task to check off before installing QEMU.

To make sure you can set up VMs with QEMU, you need to install and enable the libvirt daemon that runs virtualization in the background. Without it, QEMU or any other hypervisor will refuse to work.

Launch the terminal and type in these commands to install and enable the libvirt daemon on your Ubuntu machine:

sudo apt install libvirt-daemon
sudo systemctl enable libvirtd
sudo systemctl start libvirtd

Once you're done with this step, you can move on to the QEMU installation process.

Download and Install QEMU on Ubuntu

You can install QEMU on your Ubuntu machine using the APT package manager. Fire up the terminal and issue the following command to install QEMU on Ubuntu:

sudo apt install qemu-kvm  

Enter Y or Yes when prompted for permission and wait until the installation process finishes. If you prefer a more hands-on approach, you can manually download the software source from the official QEMU website or GitHub repository and then compile it.

Open a new terminal and type in these commands one by one to build QEMU from the source:

sudo apt install git
git clone https://gitlab.com/qemu-project/qemu.git
cd qemu
git submodule init
git submodule update --recursive
./configure
make

After you've installed QEMU, it's time to install Virtual Machine Manager or, in short, virt-manager. It's a handy GUI tool for setting up and managing virtual machines on Linux.

If you're new to virtualization on Linux, it's highly recommended you install virt-manager as the graphical layout helps new users find familiarity with VirtualBox and VMware.

Download and Install Virtual Machine Manager

You can directly install Virtual Machine Manager from the terminal using the package manager of your choice. Launch a terminal and install the virt-manager package using the APT package manager:

sudo apt install virt-manager 

After the installation is finished, you will be able to access it from the command line by typing in virt-manager or searching for the application in the app menu.

Set Up a Linux Virtual Machine With QEMU/KVM

Now that QEMU is all set up, it's time for a test run. Install any operating system of your choice, and make sure to play around with the VM configurations to figure out what works best with your system. For starters, you can try installing a Linux distribution such as Manjaro.

ncG1vNJzZmivp6x7rq3KnqysnZ%2Bbe6S7zGifqK9dqbxutc2sq5qknGK%2BprnUZqybrZ6pwm6%2FxK1krqhdq7azwNSao2alkZi1qrrEaA%3D%3D