How to run DOS programs in Linux

QEMU and FreeDOS make it easy to run old DOS programs under Linux.
543 readers like this.
An introduction to GNU Screen

Opensource.com

The classic DOS operating system supported a lot of great applications: word processors, spreadsheets, games, and other programs. Just because an application is old doesn't mean it's no longer useful.

There are many reasons to run an old DOS application today. Maybe to extract a report from a legacy business application. Or to play a classic DOS game. Or just because you are curious about "classic computing." You don't need to dual-boot your system to run DOS programs. Instead, you can run them right inside Linux with the help of a PC emulator and FreeDOS.

FreeDOS is a complete, free, DOS-compatible operating system that you can use to play classic DOS games, run legacy business software, or develop embedded systems. Any program that works on MS-DOS should also run on FreeDOS.

In the "old days," you installed DOS as the sole operating system on a computer. These days, it's much easier to install DOS in a virtual machine running under Linux. QEMU (short for Quick EMUlator) is an open source software virtual machine system that can run DOS as a "guest" operating system Linux. Most popular Linux systems include QEMU by default.

Here are four easy steps to run old DOS applications under Linux by using QEMU and FreeDOS.

Step 1: Set up a virtual disk

You'll need a place to install FreeDOS inside QEMU, and for that you'll need a virtual C: drive. In DOS, drives are assigned with letters—A: and B: are the first and second floppy disk drives and C: is the first hard drive. Other media, including other hard drives or CD-ROM drives, are assigned D:, E:, and so on.

Under QEMU, virtual drives are image files. To initialize a file that you can use as a virtual C: drive, use the qemu-img command. To create an image file that's about 200MB, type this:

qemu-img create dos.img 200M

Compared to modern computing, 200MB may seem small, but in the early 1990s, 200MB was pretty big. That's more than enough to install and run DOS.

Step 2: QEMU options

Unlike PC emulator systems like VMware or VirtualBox, you need to "build" your virtual system by instructing QEMU to add each component of the virtual machine. Although this may seem laborious, it's really not that hard. Here are the parameters I use to boot FreeDOS inside QEMU:

qemu-system-i386

QEMU can emulate several different systems, but to boot DOS, we'll need to have an Intel-compatible CPU. For that, start QEMU with the i386 command.

-m 16

I like to define a virtual machine with 16MB of memory. That may seem small, but DOS doesn't require much memory to do its work. When DOS was king, computers with 16MB or even 8MB were quite common.

-k en-us

Technically, the -k option isn't necessary, because QEMU will set the virtual keyboard to match your actual keyboard (in my case, that's English in the standard U.S. layout). But I like to specify it anyway.

-rtc base=localtime

Every classic PC provides a real time clock (RTC) so the system can keep track of time. I find it's easiest to simply set the virtual RTC to match your local time.

-soundhw sb16,adlib,pcspk

If you need sound, especially for games, I prefer to define QEMU with SoundBlaster16 sound hardware and AdLib Music support. SoundBlaster16 and AdLib were the most common sound hardware in the DOS era. Some older programs may use the PC speaker for sound; QEMU can also emulate this.
-device cirrus-vga To use graphics, I like to emulate a simple VGA video card. The Cirrus VGA card was a common graphics card at the time, and QEMU can emulate it.

-display gtk

For the virtual display, I set QEMU to use the GTK toolkit, which puts the virtual system in its own window and provides a simple menu to control the virtual machine.
-boot order= You can tell QEMU to boot the virtual machine from a variety of sources. To boot from the floppy drive (typically A: on DOS machines) specify order=a. To boot from the first hard drive (usually called C:) use order=c. Or to boot from a CD-ROM drive (often assigned D: by DOS) use order=d. You can combine letters to specify a specific boot preference, such as order=dc to first use the CD-ROM drive, then the hard drive if the CD-ROM drive does not contain bootable media.

Step 3: Boot and install FreeDOS

Now that QEMU is set up to run a virtual system, we need a version of DOS to install and boot inside that virtual computer. FreeDOS makes this easy. The latest version is FreeDOS 1.2, released in December 2016.

Download the FreeDOS 1.2 distribution from the FreeDOS website. The FreeDOS 1.2 CD-ROM "standard" installer (FD12CD.iso) will work great for QEMU, so I recommend that version.

Installing FreeDOS is simple. First, tell QEMU to use the CD-ROM image and to boot from that. Remember that the C: drive is the first hard drive, so the CD-ROM will show up as the D: drive.

qemu-system-i386 -m 16 -k en-us -rtc base=localtime -soundhw sb16,adlib -device cirrus-vga -display gtk -hda dos.img -cdrom FD12CD.iso -boot order=d

Just follow the prompts, and you'll have FreeDOS installed within minutes.

Starting FreeDOS installation

opensource.com

Select your keyboard layout

opensource.com

Selecting which packages to install

opensource.com

Rebooting after installation

opensource.com

After you've finished, exit QEMU by closing the window.

Step 4: Install and run your DOS application

Once you have installed FreeDOS, you can run different DOS applications inside QEMU. You can find old DOS programs online through various archives or other websites.

QEMU provides an easy way to access local files on Linux. Let's say you want to share the dosfiles/ folder with QEMU. Simply tell QEMU to use the folder as a virtual FAT drive by using the -drive option. QEMU will access this folder as though it were a hard drive.

-drive file=fat:rw:dosfiles/

Now, start QEMU with your regular options, plus the extra virtual FAT drive:

qemu-system-i386 -m 16 -k en-us -rtc base=localtime -soundhw sb16,adlib -device cirrus-vga -display gtk -hda dos.img -drive file=fat:rw:dosfiles/ -boot order=c

Once you're booted in FreeDOS, any files you save to the D: drive will be saved to the dosfiles/ folder on Linux. This makes reading the files directly from Linux easy; however, be careful not to change the dosfiles/ folder from Linux after starting QEMU. QEMU builds a virtual FAT table once, when you start QEMU. If you add or delete files in dosfiles/ after you start QEMU, the emulator may become confused.

I use QEMU like this to run my favorite DOS programs, like the As-Easy-As spreadsheet program. This was a popular spreadsheet application from the 1980s and 1990s, which does the same job that Microsoft Excel and LibreOffice Calc fulfill today, or that the more expensive Lotus 1-2-3 spreadsheet did back in the day. As-Easy-As and Lotus 1-2-3 both saved data as WKS files, which newer versions of Microsoft Excel cannot read, but which LibreOffice Calc may still support, depending on compatibility.

As-Easy-As spreadsheet program

opensource.com

I also like to boot FreeDOS under QEMU to play some of my favorite DOS games, like the original Doom. These old games are still fun to play, and they all run great under QEMU.

Doom

opensource.com

Heretic

opensource.com

Jill of the Jungle

opensource.com

Commander Keen

opensource.com

QEMU and FreeDOS make it easy to run old DOS programs under Linux. Once you've set up QEMU as the virtual machine emulator and installed FreeDOS, you should be all set to run your favorite classic DOS programs from Linux.

All images courtesy of FreeDOS.org.

photo of Jim Hall
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.

16 Comments

Why do this instead of using dosbox?

DOSBox is a good system too. But I think of DOSBox as being just for games.

DOSBox provides a great platform if you just want to run games. It's not great for doing other work in a DOS environment. On their wiki, DOSBox says "DOSBox also comes with its own DOS-like command prompt. It is still quite rudimentary and lacks many of the features found in MS-DOS, but it is sufficient for installing and running most DOS games."

With FreeDOS and a PC emulator you can do more than just play games. We've added more features in FreeDOS than what classic "DOS" provided, while remaining compatible with DOS. The FreeDOS "Base" includes those programs and utilities that replace the original MS-DOS behavior. Our other packages include compilers / software development, editors, archivers, music players, text processing, and other things that make FreeDOS more than just "DOS." We also have games.

In reply to by Andrew Patterson (not verified)

These are, actually, not the best way to run DOS applications on Linux (or Windows for that matter). I recommend anyone with legacy DOS applications, games or business production issues, investigate DOSBOX. It not only provides all of the features of the other solutions, but sound and speed scaling support as well.

hehe freedos is good, that's right. Tho the easiest is still DOSbox.

Better way to run Doom or Heretic is using gzDoom with original WADs :) Good article though :)

Another option: the HP 15.6" ZBook 15u G4 Mobile Workstation, which comes loaded with FreeDOS 2.1 AS ITS OPERATING SYSTEM!
Installing Linux as a 'Dual Boot' should be a no-brainer. 750 at B&H.

HP and Dell are two PC manufacturers that provide a FreeDOS option on (some of) their systems. It's very cool to see FreeDOS used this way. :-)

I assume you meant "1.2" instead of "2.1". FreeDOS 1.2 is the latest release. We are currently discussing "2.0".

In reply to by robertservice (not verified)

Thanks for the correction (I suppose this doesn't count as a "contribution" or "help" in getting FreeDOS to 2.1, does it? I didn't think so!).
Keep up your great work. And, can one easily dual-boot Linux on this H-P machine, you think?

In reply to by Jim Hall

This is a terrific write-up!

I have DOS running a couple of ways, via: DOSBox and dosemu. Was never interested in Virtualbox for running DOS since I need more direct (and natural) access to shared data.

QEMU sounds like a great 3rd option. The "-drive file=fat:rw:dosfiles/" convinced me, as well as the sound support.

I'm excited to give this a try soon.

Thanks!

I used to do a lot of my FreeDOS development via DOSEMU. It's a great little system. But then I found QEMU and I really like using that now. Makes it really easy to boot FreeDOS, especially to do test installs of the new releases.

In reply to by jake (not verified)

MANY THANKS Jim!!! :-)
This was a great guide!

Personally for using DOS on my system, I was using (with this order) 1) DOSBox (adding locally, several FreeDOS utilities), 2) DOSEMU (which comes with FreeDOS preinstalled, although one can install updated versions for some FreeDOS tools) and 3) FreeDOS installed on VirtualBox.

I'll install QEMU asap.
THANKS AGAIN!!! :-)
G.

There is a way of using Freedos under dosemu.
I tried, but never was able to make it work or find a step by step tutorial
If you are interested or know a good how to, I would ove to read about it and try again.

I dunno, but maybe its because I'm studying to be a programmer, that I don't see the value of this? I mean I get the whole "nostalgia" vibe thing, but in a practical world? this doesn't seem like its worth the effort. Not when there are so many other endeavours one can undertake, such as building a NoSQL database, connecting it to it from a remote/satellite Linux machine, learning programming like C++....Python...and Ruby On Rails...etc. I guess there's something for everyone out there in Cyber-verse! Great and informative article though!

Unfortunately one critical thing is missing from Freedos in terms of game support. SoundBlaster.
Please add classic sound emulation. The only missing piece.

Heh, this method works terribly. Glitches in the 2d games, Vanilla Doom does not start at all.

I got this error and couldn't figure out how to enable GTK support:

qemu-system-i386: -display gtk: GTK support is disabled

However, I just left out the -display gtk option and it worked.

BTW, if anyone is thinking of trying this in VirtualBox, you can't add the guest additions (no support pre Win 2000) so you can't scale the window.

Not that I have figured out how to make the display resolution bigger anyway. I can stretch the Window, which is OK for now I guess. Not sure how it will impact games until I get one working.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.