How to run DOS apps on Linux

0

The classic DOS operating system sported an expansive variety of great applications and games. If you are of a certain age like me, you probably remember some of the classics like WordPerfect, PC-Write, WordStar, Lotus 1-2-3, As-Easy-As, Quattro Pro, and games like DOOM, Commander Keen, and Jill of the Jungle.

There are many reasons to run an old DOS application in 2024. I have a few favorites that I like to use; for example, I find that the As-Easy-As spreadsheet on DOS does pretty much everything that a “modern” spreadsheet can do, even if it does things a little differently (like conditional formatting). I also like to go back and play some of my favorite DOS games – just because they are old doesn’t mean they aren’t fun to play.

You don’t need to dual-boot your computer to run these classic DOS programs. Instead, you can run them from inside Linux using a PC emulator and FreeDOS.

FreeDOS is a complete, free, open source, DOS-compatible operating system that you can use to run DOS applications and games. Any DOS program that ran on MS-DOS should also run on FreeDOS. Here are a few steps to set up FreeDOS with QEMU on Linux:

1. Create a virtual disk

You’ll need somewhere to install FreeDOS inside QEMU, and that means you’ll need to create a virtual hard drive. In DOS, drives are named as letters: “A” and “B” are always reserved as floppy drives, “C” is the first partition on the first hard drive connected to the first drive controller, and so on.

Under QEMU, virtual drives are just “image” files. To create an image file for a virtual hard drive, run this qemu-img command:

$ qemu-img create -f vmdk dos.vmdk 200M
Formatting 'dos.vmdk', fmt=vmdk size=209715200 compat6=off hwversion=undefined

This uses the VMDK disk image format, which is supported by a variety of virtual machine systems like QEMU, VMWare, and VirtualBox.

2. Install FreeDOS on the virtual disk

Unlike other graphical virtual machines like VirtualBox, QEMU requires that you “build” or configure the virtual machine using the command line. These are the options I tend to use to run FreeDOS in QEMU. See the qemu(1) man page for full details on the command line.

OptionWhat it means
qemu-system-i386QEMU can emulate several different machine systems, but to boot DOS, we’ll need an i386 Intel system
-enable-kvmUse the Linux kernel KVM support to make QEMU run at almost native speeds
-m 32Defines the virtual machine with 32 MB of memory
-hda imageSets the disk image for the first hard drive
-cdrom imageSets the CD ISO image for the CD-ROM drive
-boot order=Tells QEMU to boot from different media (c for the hard drive, d for the CD-ROM drive)

Download the FreeDOS 1.3 install LiveCD from the FreeDOS website and extract the zip file to get the CD ISO image, then boot QEMU with this command line to start the install process:

$ qemu-system-i386 -enable-kvm -m 32 -hda dos.vmdk -cdrom FD13LIVE.iso -boot order=d

For full instructions for how to install FreeDOS 1.3 under QEMU, see my other article about Running FreeDOS on Linux.

Once you have installed FreeDOS on the virtual disk, use the FreeDOS shutdown command to halt the FreeDOS instance and exit QEMU.

3. Copy over your DOS applications

Next, you’ll need to copy and DOS applications or files that you want to use into the virtual disk, so you can use them under FreeDOS. The guestmount command makes this really easy. If you don’t have the guestmount command on your system, you’ll need to first install the libguestfs package using your package manager. On Fedora Linux or other systems that use DNF, you can type:

$ sudo dnf install libguestfs

The guestmount command can access a variety of virtual disk images, including QCOW2, IMG, VMDK, and others. The command line requires the disk image you want to access using the -a option, the partition you want to mount using the -m option, and the directory where you want to access the data. Like other DOS systems of the era, FreeDOS usually makes one partition on the disk, which guestmount will address as /dev/sda1.

Let’s say you wanted to access the dos.vmdk virtual disk image from a directory called dos. You can type these commands to first create the new directory then “mount” the partition:

$ mkdir dos
$ guestmount -a dos.vmdk -m /dev/sda1 dos
$ ls dos
COMMAND.COM  FDAUTO.BAT  FDCONFIG.SYS  FREEDOS  KERNEL.SYS

You can find many DOS applications and games as zip files. The shareware model was quite popular on DOS; shareware meant you could download a DOS program or game, and use it for a limited time before deciding to buy it. You could also share the program with others (which is why they called it “shareware”).

I’ve downloaded a copy of Commander Keen, a popular shareware game. Once I’ve used guestmount to make my virtual disk accessible as a directory, I can just copy the Commander Keen installer using cp or my graphical file manager. Or in this case, I’ll save a step and just unzip the Commander Keen installer into a new TEMP directory on my FreeDOS virtual disk:

$ unzip 1keen.zip -d dos/TEMP
Archive:  1keen.zip
  inflating: dos/TEMP/INSTALL.EXE    
  inflating: dos/TEMP/CK1SW131.SHR   
  inflating: dos/TEMP/FILE_ID.DIZ

Then use the guestunmount command to unmount the virtual disk from the dos directory:

$ guestunmount dos

4. Boot FreeDOS from the virtual disk

Now you’re ready to use your favorite DOS applications and games, right from Linux, without having to dual-boot your system into DOS. From Linux, run QEMU with this command line. It’s basically the same command line as before, but uses order=c to tell QEMU to boot from the virtual disk instead of the LiveCD:

$ qemu-system-i386 -enable-kvm -m 32 -hda dos.vmdk -cdrom FD13LIVE.iso -boot order=c
screenshot of FreeDOS 1.3 booting on QEMU
FreeDOS 1.3 booting on QEMU

You can run any DOS application on FreeDOS the same way you would run DOS programs on MS-DOS. By its nature, FreeDOS (like any DOS) is a command line operating system, so you’ll type commands like CD to change to a new directory and DIR to list the contents of a directory. For example, use CD and DIR to navigate to the TEMP directory, and find the Commander Keen installer:

Run any DOS program by typing its name. DOS programs always have an EXE or COM extension; “batch” files have a BAT extension. For example, to run the installer for Commander Keen, just type INSTALL:

And once you’ve installed the game, you can use CD to change the working directory to wherever you installed the game, and run it there:

Again, to exit FreeDOS and shut down QEMU, use the shutdown command at the FreeDOS command line prompt.

Supporting sound

Most DOS applications will work just fine using the command line shown above. However, DOS games will usually expect to use a sound card like the SoundBlaster 16 for digital sounds, AdLib for digital music, or the PC speaker for monotonal beeps. You will need to modify the QEMU command line to add these devices.

The QEMU team has changed how users must configure sound from the command line. It used to be as simple as -device sb16 to add SoundBlaster 16 support, and -device adlib for AdLib digital music. In more recent versions, QEMU has dropped default support for the PC speaker. Instead, you now need to redirect sound devices to use your Linux system’s sound system.

My Fedora Linux system uses PulseAudio, so I need to add the -audiodev pa,id=snd option to configure an audio device using the PulseAudio back-end, and naming that connection snd. You can use another ID name if you like. With that sound connection, I can add PC speaker, SoundBlaster 16, and AdLib devices using these options to QEMU:

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

The updated QEMU command line is quite long, but works great to support sound in classic DOS games:

$ qemu-system-i386 -enable-kvm -m 32 -audiodev pa,id=snd -machine pcspk-audiodev=snd -device sb16,audiodev=snd -device adlib,audiodev=snd -hda dos.vmdk -cdrom FD13LIVE.iso -boot order=c

But I don’t type that all the time. I saved that long command line in a script called freedos so whenever I want to run DOS programs, I just type freedos and it runs QEMU with all the options I need.

Classic DOS games and applications

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.