Making a start with qemu

I have tried Virtualbox and Gnome Boxes in Linux and would have to say I am far from satisfied with the experience. So I decided to have a look at qemu.

Browsing around looking at help documents for qemu is a rather frightening experience. They tend to lay out all the options ( and there are many, it is like rsync) and delve into a range of sophisticated applications, without giving a novice the slightest idea where to start.

I finally found a document which gets you started with only half a page of instructions. It is here
So I am going to follow that and see if I can find what the bare minimum is to get a qemu virtual machine started

First I have to install qemu. I am in Void Linux so I do

[nevj@trinity qemu]$ xbps-query -Rs qemu
[-] aqemu-0.9.4_1            GUI to QEMU and KVM emulators, written in Qt4
[-] novaboot-20191023_2      Tool that automates booting of operating systems...
[-] qemu-7.1.0_2             Open Source Processor Emulator
[-] qemu-ga-7.1.0_2          QEMU Guest Agent
[-] qemu-user-static-7.1.0_3 QEMU User-mode emulators (statically compiled)
[-] qemuconf-0.2.1_3         Simple qemu launcher with config file support
[-] virtme-0.1.1_5           Easy way to test your kernel changes in qemu/kvm

Those are all the packages that involve qemu. I am only going to install qemu so

# xbps-install qemu

and we are ready to go.

One has to decide where (on disk) to put images of virtual machines. I decided to dedicate a spare 350Gb partition called /dev/sdb14. It has an ext4 filesystem. So I made a mount point and mounted it

# cd /
# mkdir qemuvm
# chmod 777 qemuvm
# mount /dev/sdb14 /qemuvm

I now need to make, in that /qemuvm filesystem a file to contain the virtual hard disk for a Debian VM. II am going to make a Debian 11 VM).

$ qemu-img create -f qcow2 /qemuvm/debian.qcow2 30G
Formatting '/qemuvm/debian.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=32212254720 lazy_refcounts=off refcount_bits=16

So it makes a 30Gb file in qcow2 format

Now I simply follow the help doocument and give the qemu command to install Debian in a VM

[nevj@trinity Downloads]$ qemu-system-x86_64 -enable-kvm -m 1G -nic user,model=virtio -drive file=/qemuvm/debian.qcow2,media=disk,if=virtio -cdrom debian-live-11.6.0-amd64-gnome+nonfree.iso -sdl
qemu-system-x86_64: -sdl: invalid option

So there is some problem with -sdl option.
I used qemu-system-x86_64 --help to find out that sdl is a display option

-display spice-app[,gl=on|off]
-display sdl[,gl=on|core|es|off][,grab-mod=<mod>][,show-cursor=on|off]
-display gtk[,full-screen=on|off][,gl=on|off][,grab-on-hover=on|off]
-display vnc=<display>[,<optargs>]
-display curses[,charset=<encoding>]
-display egl-headless[,rendernode=<file>]
-display none

and after a few trials and errors I settled on

qemu-system-x86_64 -enable-kvm -m 5G -nic user,model=virtio -drive file=/qemuvm/debian.qcow2,media=disk,if=virtio -cdrom debian-live-11.6.0-amd64-gnome+nonfree.iso -display sdl,gl=on,show-cursor=on

If you want to understand the options, look at the document link.
Now I get a screen from the Debian live .iso offering a few options including, Live System, Install, Graphical Install, …
I choose Live System , and Debian runs… I get a conventional Gnome screen.

OK, so having seen the live system will work, I click the install button and get the Calamares installer.
So I answer all the install questions, let it write Debian to the virtual hard disk setup, shut it down, and restart with

qemu-system-x86_64 -enable-kvm -m 5G -nic user,model=virtio -drive file=/qemuvm/debian.qcow2,media=disk,if=virtio -display sdl,gl=on,show-cursor=on

That is you leave out the -cdrom option to tell it to boot from the created VM.
Now it boots first to a grub screen, then goes straight to a full screen window with the login manager, then when you login it goes to a full screen window with Debian/Gnome booted.
It looks like this

I can start up a terminal window and run Firefox straight away,

So there is Firefox looking at the FOSS site, and the terminal window has an ip command showing that the network interface is ens3.

So how easy is that for a first try? The only hitch was the startup document had one error ( the sdl option)

Now, that is the way to learn some complicated command… start with the absolute minimum working system.

It is far from ideal. Here are some things I have to address

  • there is no root user. Calamares did not offer me the chance to setup a root password. I can use sudo, but I cant su because I dont know the password. Not sure if this is Calamares, or if the VM is suppressing root.
  • Firefox has internet connectivity… but I cant ping anything.
  • I cant see any of the Void hosts interfaces. I need to learn how to build a link to my local ethernet to access printers. I think I may need a bridge?
  • I cant see Void hosts devices. So I cant access a usb stick or a memory card or a DVD.
  • I cant see the Void hosts filesystems or any of the unmounted partitions on my disks.
    The way to deal with that is to attack issues one at a time and build on my minimal system.

There are other help documents

What is interesting to me is that I can now run Debian in this virtual machine, when it will not run natively in the computer because of graphics driver issues.

How does qemu compare with Vbox or Boxes? Well it is early days but I did not encounter anything like the Vbox Guest Additions nonsense. Boxes is just qemu with a gui anyway.

I would welcome any help or comments. It is going to be a long road getting qemu configured the way I need. I need to know about all the shortcuts and traps.


Qemu can also host foreign architectures, such as armhf on amd64, or x86 on aarch64…


QEMU is amazing, and it’s been around since forever - i.e. before CPU vendors chucked virtualization into their CPU architecture…

It’s what lets UTM on MacOS do it’s magic!

I’m yet to get around to it - but I found an amazing article / howto to :

Run AIX 6 on PowerPC via QEMU on x86_64 FreeBSD…

I remember some 20 years ago coming across PearPC which let me waste time running MacOS “Darwin” on pretend PPC… I think QEMU’s better than anything else…

Most of KVM and XEN started by leveraging (parasitizing) all the work the QEMU guys did…

Yes it has far more capablity than I have explored here
I dont understand how it deals with foreign architectures. It doesnt use source, so it cant cross-compile. It must cross-map machine instructions?


found an amazing article / howto to :

Run AIX 6 on PowerPC via QEMU on x86_64 FreeBSD…

Will it run non-unix guests?

I only used qemu with KVM. You can use it without, or with other things like Xen or LVM

Yeah, its a whole toolbag of goodies.
The only person I know who seriously uses it is @Rosika . If it is so versatile, why is it not widely used?


That is an easy one, mostly because it runs only on a Linux host, and .ext4. What host are you using? May give it a try, if I can dig up a spare drive.

Exactly. It emulates the foreign CPU with its registers, I/O and memory address map…
I’ve seen such thing way before I ever heard of Qemu. :slight_smile:
I was 13…14 years old, I had a ZX Spectrum. So when I found “FUSE”
I had a broad smile on my face for a few days :grin: because of some strange nostalgic feelings…
Sure, it is not Qemu (I just met this FUSE way before I ever heard of Quemu/VBox, it happened in my early Linux days), but I think it’s a special case of what Qemu does…


My host is Void. I only had Void or MX to choose from. I needed the large desktop with plenty of ram and disk .
It could be any host… Debian or Gentoo would be fine.

I dont think ext4 is essential for the vm space. I think it could be any filesystem Linux supports.

Qemu is not Linux specific… runs on BSD. Dont know about Win or DOS?

I know it does not run on Windows. A lot more users, where I live
will run VB on Windows.

Because , as you said, Vbox actually works well on Windows
From the Linux point of view, Vbox (like most Oracle stuff) has a bad case of Microsoft Disease… ie it does all sorts of things the Windows way and that makes it a poor fit in Linux.
That is why the interest in qemu. You can get gui for qemu, its called virt-manager, but that is not the place to start. You need to learn the nuts and bolts first.

There is also FUSE… see Reply 6 from @kovacslt . It is available for Win and Linux.

1 Like

I have heard of FUSE, just never found the reason to explore. One thing for sure, VB is a totally different animal when ran on Linux.
What is chmod 777 ?

It gives full permission to everyone on that dir.
Not a very secure operation in a muti-user context :wink:

1 Like

I have been using chmod 700?

That gives full permission to the owner, and no permession to anyone else.
Use chmod depending on your needs.

I used 777 because I was not sure what user qemu would run the VM as.
Last thing I need when learning is problems with permissions.
Who would want to look at a VM image anyway?

1 Like

None of my systems have multi users, so I doubt it really matters.

1 Like

Not login users.
Things like qemu, ssh, ftp, cups may operate as a non-login user. You will have some of those.
Dont get hung up on my 777… anything will probably work.

Do you think it will run in a Gentoo VB VM?

Can I setup qemu in that home partition?

Here are some videos of Chris Titus using qemu

1 Like

It will run, but when it comes to communicating with the outside world , I am not sure what will happen. It may not find an internet connection as easily as mine did.
The /home partition has plenty of space
Give it a try.