DEV Community


Posted on

Running Fedora 37 on QEMU x86_64 machine

In my previous post, I played with QEMU by installing Debian on an emulated arm machine. It was challenging and I ended up spending a lot of time for it. But I think it was a good exercise nevertheless.

However, as my mentors suggested, it's much better to use the same QEMU target architecture as your host. Therefore, here I'll describe the steps I followed to run Fedora 37 on QEMU x86_64 machine.

But first, here's a little bit about KVM.

What is KVM and how does it relate to QEMU?

KVM (Kernel-based Virtual Machine) is an open source full virtualization solution for Linux on x86 machine with virtualization hardware extension (Intel VT or AMD-V). To see if the virtualization extension exists, run the following to look for svm (for AMD-V) or vmx (for Intel VT) flags.

grep -E 'svm|vmx' /proc/cpuinfo
Enter fullscreen mode Exit fullscreen mode

On my computer, the result contains svm which means I have a AMD-V.

Image description

To see if KVM is enabled, run the following:

Image description

Hypervisor is a software that provides the virtualization to the underlying hardware; it creates and runs Virtual Machines. This IBM tutorial was a great read to understand about virtualization and hypervisors. KVM is a type 1 (bare metal) hypervisor which means that it has a direct access to the hardware resources.

Whereas, QEMU is a type 2 hypervisor which means it runs on top of the host OS. QEMU is also tightly integrated with KVM. If KVM is enabled on the host, and guest and host OS have the same architecture, QEMU can have KVM to translate some of the instructions (CPU and memory calls) making it much faster.

Image description
Source: Researchgate


Libvirt is collection of software that provides a convenient way to manage virtual machines and other virtualization functionality.
Tools such as virt-builder, virt-install and virt-manager that are based on libvirt make building and installing virtual machines much easier.


Virt-builder is a tool a tool that quickly builds virtual machine images. It's part of libguestfs which is a set of tools to build, access, modify virtual machine disk images and more.

First, install libguestfs.

sudo apt install libguestfs-tools
Enter fullscreen mode Exit fullscreen mode

The following will list all the virtual machine images you can create:

virt-builder --list
Enter fullscreen mode Exit fullscreen mode

Build Fedora image. The size specified with -size 30G will not be the actual size of the image. It just means that the newly created image can be expanded up to 30G.

virt-builder  \
    --ssh-inject=root:file:/home/amar/.ssh/  \ 
    --root-password=password:vm_root_password   \
    --output=fedora37.qcow2 --format=qcow2   \
    --selinux-relabel --size 30G fedora-37
Enter fullscreen mode Exit fullscreen mode

Virt-install and Virt-manager

Create a VM using the disk image created above with virt-builder:

    --connect qemu:///system --name f37-vm–import \
    --ram 2048 --vcpus 2 --cpu host   \
    --disk bus=virtio,path=fedora37.qcow2   \ 
    --network network=default,model=virtio  \
    --os-variant fedora37
Enter fullscreen mode Exit fullscreen mode

Or use virt-manager which is a GUI tool that allows you to create a VM with one-click.

However, when I try to use virt-install or virt-manager, I got the following error even though virtualization hardware is present and enabled.

ERROR Host does not support any virtualization options

Direct install

I had a network problem when I tried direct install with qemu-system-x86_64. Therefore, first install slirp, configure and build QEMU again with --enable-slirp.

sudo apt install libslirp-dev
../configure --enable-slirp
Enter fullscreen mode Exit fullscreen mode

Then directly run VM with QEMU:

qemu-system-x86_64 -smp 2 -m 1G -M q35,accel=kvm   \
    -drive file=fedora37.qcow2,format=qcow2,if=virtio  \   
    -nic user,model=virtio
Enter fullscreen mode Exit fullscreen mode

When the VM runs, login using the root password set when building the disk image.

Image description

Top comments (0)