Be the first to know and get exclusive access to offers by signing up for our mailing list(s).

Subscribe

We ❤️ Open Source

A community education resource

4 min read

How I run virtual machines with QEMU

Use this lightweight open source emulator to run classic DOS programs on today’s Linux systems.

I don’t run Linux all the time. Sometimes, I like to run other operating systems too, like FreeDOS, an open source implementation of the classic DOS operating system. My quad-core Intel i3-8100T CPU (3.10GHz) with 32GB and 256GB Solid State Drive from December 2019 is probably just a tad overpowered to run a DOS operating system designed for the 1980s and early 1990s when computers had just one CPU and counted memory and disk space in mere megabytes instead of gigabytes. That’s why I don’t run FreeDOS on real hardware; instead, I boot FreeDOS in a virtual machine on my Linux system, so I can run FreeDOS in a “window.”

I like the QEMU virtual machine emulator. It’s open source, and runs great on Linux. Here’s how I use QEMU to boot FreeDOS on Linux:

Booting the LiveCD

If I want to boot the FreeDOS LiveCD without installing it, I could just run QEMU with the LiveCD. Let’s do that, to test that we can actually run QEMU as a virtual machine.

Where other virtual machine applications like VirtualBox use a graphical interface to provide settings, QEMU does everything on the command line. Fortunate, we only need a few command line options to get started:

  • qemu-system-i386 emulates a 32-bit system.
  • Use -cdrom to specify a path to the FreeDOS LiveCD.
  • Add -enable-kvm to use the Linux kernel’s Virtual Machine subsystem. Technically, you don’t need to provide this, but QEMU will run really slow without it.
$ qemu-system-i386 -enable-kvm -cdrom FD14LIVE.iso

And that’s all we need to start. The virtual machine will look for a bootable device, which is usually the first floppy drive (which isn’t defined in this command line) and then the first hard drive (also not listed on the command line). As a fallback, the system will boot from the first bootable CD-ROM drive, which we’ve provided as the LiveCD.

Boot sequence output from a liveCD
Booting the FreeDOS LiveCD in QEMU

After FreeDOS boots from the LiveCD, you’ll find yourself at a DOS command line where you can use FreeDOS from the CD-ROM filesystem.

Read more: 5 FreeDOS editors I love

Build a virtual machine at the command line

I like using QEMU to boot my virtual machine because the command line makes it possible to create any configuration I want. For example, after I installed FreeDOS 1.4 on a virtual disk in QEMU, I added other command line options to emulate an old-style PC speaker, using the Linux PulseAudio system to make the monaural beeps. I also added other options to emulate a classic Sound Blaster 16 sound card, and Ad Lib digital music card, also using Linux PulseAudio for the output:

-audiodev pa,id=snd -machine pcspk-audiodev=snd -device sb16,audiodev=snd -device adlib,audiodev=snd

I found that QEMU works great for almost every classic DOS application. The only exception was the legacy Borland compilers; using the arrow keys on my keyboard is like a “double tap” in DOS. I was able to fix this using a QEMU keyboard throttle:

-global i8042.kbd-throttle=on

I have other command line options to do other things. My full command line also defines the memory with -m, uses a real time clock with -rtc, and adds two hard disks with -hda and -hdb:

$ qemu-system-i386 -enable-kvm -m 32 -rtc base=localtime -audiodev pa,id=snd -machine pcspk-audiodev=snd -device sb16,audiodev=snd -device adlib,audiodev=snd -global i8042.kbd-throttle=on -hda freedos.qcow2 -hdb files.qcow2 -cdrom T2506BNS.iso

That’s quite a long command line, so I saved it in a Bash script called freedos. Now, whenever I want to run FreeDOS in a “window” on Linux, I just run the freedos command, and I can run my favorite DOS programs, or write new ones.

Example output from a FreeDOS program using FED
Writing a program in FreeDOS using FED

More from We Love Open Source

About the Author

Jim Hall is an open source software advocate and developer, best known for usability testing in GNOME and as the founder + project coordinator of FreeDOS. At work, Jim is CEO of Hallmentum, an IT executive consulting company that provides hands-on IT Leadership training, workshops, and coaching.

Read Jim's Full Bio

The opinions expressed on this website are those of each author, not of the author's employer or All Things Open/We Love Open Source.

Want to contribute your open source content?

Contribute to We ❤️ Open Source

Help educate our community by contributing a blog post, tutorial, or how-to.

We're hosting two world-class events in 2026!

Join us for All Things AI, March 23-24 and for All Things Open, October 18-20.

Open Source Meetups

We host some of the most active open source meetups in the U.S. Get more info and RSVP to an upcoming event.