Must Know Tweaks For Virtual Machines Running On QEMU KVM

KVM / QEMU Virtual Machines

Virtual Machines (VMs) are an essential tool for modern computing due to their versatility and ability to create isolated, simulated computer environments within a host system. They enable users to run multiple operating systems simultaneously, test software without affecting the main OS, or even serve as a sandboxed environment for potentially risky activities.

Quick Fixes

Every distribution does this slightly different. When using Ubuntu, the steps are:

Reboot the computer and check to make sure that the libvirtd service is running:

The output should be:

libvirtd.service - Virtualization daemon
     Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; preset: enabled)
     Active: active (running) since Mon 2024-03-04 15:53:46 PST; 7s ago
TriggeredBy: ● libvirtd-ro.socket
             ● libvirtd.socket
             ● libvirtd-admin.socket

Ubuntu stores the qcow2 images in /var/lib/libvirt/images
It is possible to copy a distroname.qcow2 file to a different computer and install the same virtual machine with Virtual Machine Manager > Import existing disk image.
*Understand the storage requirements before you copy or transfer a *.qcow2 file.

Creating a bootable USB stick in Linux doesn’t require the installation of new software. For GNOME users, simply insert your USB stick into a fast USB3 port and open the Disks application. Next, delete all existing partitions on the flash drive by selecting each partition individually, clicking the red minus sign, and repeating this process until there are no more partitions left. Once that’s done, click the menu (three dots) in the top-right corner of the window and select “Restore Disk Image” to proceed with creating your bootable USB stick.

After selecting “Restore Disk Image” from the Disks application menu, a new window will open prompting you to choose your downloaded ISO image. Locate and select the file, then click “OK” to begin writing the disk image to your USB flash drive. You’ll see a progress graph as this process takes place. Once it is completed, your bootable USB stick will be ready for use in installing Linux on another computer or performing a fresh installation on your current machine.

Depending on the Linux distribution, it might be necesarry to edit the Video Virtio tab XML code. To do so, select the VM from your Virtual Machine Manager and double-click it to open but don’t start it yet. Then click on the second icon to show virtual hardware details > Video Virtio > XML. Compare the code below and add the new resolution as shown.

<video>
  <model type="virtio" heads="1" primary="yes">
    <acceleration accel3d="yes"/>
    <resolution x="3440" y="1440"/>
  </model>
  <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0"/>
</video>

After adding the new resolution as described earlier, go ahead and start your VM. Once it’s running, log in and navigate to Gnome > Settings > Display. You should see the newly added resolution listed among the available options. Please note that you can also add additional resolutions for other devices such as 1440p laptops or other ultra-wide monitors by adding the desired resolution as a new entry below.

*Fedora and OpenSUSE do not need this tweak as the VMs ill automatically resize including when the window is maximized.