Monday, January 29, 2018

How to run FreeDOS on Raspberry Pi

I got a Raspberry Pi as a Christmas gift, so naturally one of the first things I did with it was install FreeDOS. Here's how I did that.

As a DOS-based operating system, FreeDOS carries with it certain assumptions about its operating environment: FreeDOS currently requires an Intel x86 CPU, and a BIOS. So that means you can't run FreeDOS on bare metal on different architectures like the Raspberry Pi.

But it is still possible to run FreeDOS on the Raspberry Pi, if you use emulation.

This is really no different than running FreeDOS in a virtual machine on your regular desktop computer. All that's changed is the host platform. Instead of running FreeDOS in a virtual machine on an Intel-based computer running Linux or WIndows or Mac, you are running FreeDOS in a virtual machine on an ARM-base computer running 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. On the Raspberry Pi, QEMU is available for Raspbian, the Linux distribution I'm using on my Pi.

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. Under QEMU, virtual drives are disk image files. To initialize a file that you can use as a virtual C: drive, use the qemu-img command. For example, to create a disk image file that's about 200MB, type this:
qemu-img create dos.img 200M
Compared to modern computing, 200MB may seem small, that's more than enough to install and run DOS, and several applications.

Step 2: QEMU options

In QEMU, you need to "build" your virtual system by instructing QEMU to add each component of the virtual machine. Although this may seem hard, it's actually pretty easy. 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.
-k en-us
Technically, the -k option isn't necessary, because QEMU should 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 set the virtual RTC to match the local time.
-soundhw sb16,adlib
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 for DOS systems, so they work pretty much everywhere.
-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.
-boot order=
You can tell QEMU to boot the virtual machine from a variety of sources. To boot from the floppy drive, specify order=a. To boot from the first hard drive, use order=c. Or to boot from a CD-ROM drive, 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 can install FreeDOS. Download the FreeDOS 1.2 distribution from the FreeDOS website. The FreeDOS 1.2 CD-ROM "standard" installer (FD12CD.iso) works great in QEMU, so I recommend using that.

Follow the usual prompts to install FreeDOS, and you're good to go.


However, it takes forever to install FreeDOS on the Raspberry Pi. I think this is because of the heavy disk I/O when you install the operating system, and the micro SD card isn't exactly fast. I didn't record how long it took to install FreeDOS, because when I saw it was taking a long time, I did something else and waited for it to finish. It certainly took more than twenty minutes to install. It might have been closer to thirty minutes.

The speed problem here isn't with FreeDOS and it isn't with QEMU; it's because the Raspberry Pi uses a micro SD card as its boot device and main filesystem.

But once I installed FreeDOS, things ran just fine. I was even able to play games. But be aware that if you install FreeDOS on the Raspberry Pi, no matter if you use QEMU or some other emulation environment, it takes a long time.

No comments:

Post a Comment