After playing with VirtualBox (see my posts), I’ve decided to try also KVM (based on QEMU) and Virtual Machine Manager (virt-manager).
The installation is straightforward.
In Ubuntu systems:
1 |
sudo apt install virt-manager bridge-utils |
In Arch-based systems:
1 |
sudo pacman -S virt-manager qemu edk2-ovmf |
Then, you need to add your user to the corresponding group:
1 2 |
sudo adduser ${USER} libvirt sudo adduser ${USER} libvirt-qemu |
Reboot, and you’re good to go.
In this post, I’m going to install Fedora 35 on a virtual machine through Virtual Machine Manager (based on KVM and QEMU).
So, first, download the ISO of this distribution if you want to follow along.
Let’s start Virtual Machine Manager (virt-manager):
Press the “+” button to create a new virtual machine, and we select the first entry since we have downloaded an ISO.
Here, we select the ISO and let the manager detect the installed OS. Otherwise, we can choose the OS manually (the manager might not catch the OS correctly in some cases: it happened to me with ArcoLinux, for example).
Then, we allocate some resources. Since I have 16GB and a quad-core, I give the virtual machine 8GB and two cores.
Then, we allocate storage for the machine. Alternatively, we can select or create a custom image file in another location. By default, the image will NOT occupy the whole space physically on your disk. Thus, I will not lose 60GB (unless I’ll effectively use such a space on the virtual machine). The file will appear of the specified size on your drive, but if you check the free disk space on your drive, you will note that you haven’t lost so many Gigas (more on that in the next steps).
In the last step, we can give a custom name to our machine and customize a few settings before starting the installation by selecting the appropriate checkbox (we also make sure that the network is configured correctly).
If we selected “Customize configuration before install,” by pressing “Finish,” we get to the settings of our virtual machine.
In this example, I’m going to change the chipset and specify a UEFI firmware:
We can also get other information, like the path of the disk image:
And we can click “Begin Installation.” After the boot menu, we’ll get to the live environment of the distribution ISO we chose:
You can also specify to resize the display of the VM automatically if you resize the window and when to do that. (WARNING: this will work correctly only after installing the OS in the virtual machine since this feature requires some software in the guest operating system. Typically, such a software, spice-vdagent, is automatically installed in the guest during the OS installation, from what I’ve seen in my experiments.)
And we can start the installation of the distribution (or try it live before the actual installation), as usual. Of course, the whole installation process will be a bit slower than on real hardware.
I’ll choose the “Automatic” choice for disk partitioning since the disk image will be allocated only to this machine, so I will not bother customizing that.
While installing, you might want to check the disk image size and the effective space on the disk:
1 2 3 4 5 |
$ sudo ls -l /var/lib/libvirt/images total 3161816 -rw------- 1 libvirt-qemu kvm 64434601984 mar 19 15:58 fedora-35.qcow2 $ sudo du /var/lib/libvirt/images 3161820 /var/lib/libvirt/images |
After a few minutes, the installation should be complete, and we can reboot our virtual machine
And upon reboot, we’ll get to our new installed OS on the virtual machine:
In the primary Virtual Machine Manager window, you can see your virtual machines, and, if they are running, a few statistics:
In the virtual machine window’s “View” menu, you can switch between the “Console” view (that is, the virtual machine installed and running OS) and the “Details” view, where you can see its settings, and change a few of them.
Note that now the automatic resize of the machine display and the window works: in the screenshot I resized the window (made it bigger) and the display of the machine resized accordingly.
When you later restart a virtual machine from the manager, you might have to double-click on the virtual machine element and possibly switch to the “Console” view.
After installing the OS, you might want to check the image file and the actual disk usage again. You will find that while the image file size did not change, the disk usage has:
1 2 3 4 5 |
$ sudo ls -l /var/lib/libvirt/images total 7994460 -rw------- 1 root root 64434601984 mar 19 16:31 fedora-35.qcow2 $ sudo du /var/lib/libvirt/images 7994464 /var/lib/libvirt/images |
What I’ve shown in this blog post was one of my first experiments with KVM and the Virtual Machine Manager. To be honest, I still prefer VirtualBox, but maybe that’s only because I’m more used to VirtualBox, while I’ve just started using virt-manager.
That’s all for now! Stay tuned for further posts on KVM and virt-manager, and happy virtualization! 🙂