TheBlackzone Logo

Installing MS-DOS in QEMU

Posted on Monday, April 23 2018

MS-DOS iconRecently I was sorting through a bunch of old stuff in the attic when I stumbled across a box with some old diskettes. Most of these diskettes where from my early days with PC computers and amongst them I found the installation disks for the MS-DOS operating system. I wondered if could get it to run on the QEMU emulation and as it turned out, it's actually quite easy...

I have several versions of MS-DOS on diskette, the latest one being MS-DOS 6.22 and the oldest one being MS-DOS 3.30. For this little experiment version 3.30 from 1987 was my choice...

Typically the most difficult part is to create images from the physical disks. Luckily I bought an USB diskette drive a while ago (for reasons I don't even remember anymore), so it was easy to create the images with dd.

dd if=/dev/sdf of=msdos.img bs=512K

Setting up the emulation is straightforward and, to my surprise, turned out easier than I thought at first.

First I created a virtual hard disk for the installation:

qemu-img create msdos.disk -f qcow 512M

Note that MS-DOS 3.30 has a limit of 32MB for a partition size but it was already capable of handling extended partitions. I used 512MB here because I wanted to do some experiments with partitioning, but 32MB would have been sufficient for the installation.

Then I started QEMU, booting from the first floppy image:

qemu-system-i386 -hda msdos.disk -L . -fda msdos33-1.img -boot a

And voila:

First boot from floppy
First boot from floppy

Since there is no installer program in earlier versions of MS-DOS, there are some steps that need to be performed manually within the emulated environment in order to install it on the hard disk drive.

I created the partition:

fdisk

Then formatted the hard disk drive:

format c:

Transfered the boot system:

sys c:

Copied the content of the first diskette to the harddrive

copy a:*.* c:

In order to copy the content of the second diskette, the images can be switched in the QEMU console by pressing ALT-CTRL-2 in QEMU and entering

change floppy0 /path/to/image/msdos33-2.img

then switching back to the emulated OS by pressing ALT-CTRL-1 and repeat the copy command for the second disk.

Now that everything was copied to the harddisk, I started QEMU with just the hard disk and no floppy image:

qemu-system-i386 -hda msdos.disk -L .

And there I had a nicely emulated DOS environment:

Booting from hard disk
Booting from hard disk

Now, at this point there is of course not much you can do with the OS. Maybe an interesting part to look at is GW-BASIC which was quite capable back then. You can start it by simply typing gwbasic and exit again by typing system within the GW-BASIC IDE.

A look at the GW-BASIC IDE
A look at the GW-BASIC IDE

Funnily, I still got a programming book for GW-BASIC in my shelf.

So, all in all this was a neat little experiment and I was surprised how easy it was to get MS-DOS working with QEMU.

Interestingly, still today there are DOS applications in use in the real world. From my own experience, for example, a company I formerly worked for had its complete phone system managed by a DOS based application. Another company I know ran parts of its warehouse application on mobile DOS terminals until recently.

If, for whatever reason, you are further interested in DOS emulation (for example to run legacy games or applications), you might want to look into the DOSBOX emulator, or if you are looking for modern DOS compatible environment into FreeDOS.

Maybe I'll pick up this topic again if I find something worthwile in my pile of old computer stuff.


Update 2018-10-04:

Microsoft has set up repositories of older MS-DOS versions on github

They are, however, very limited and should more be seen for educational purposes, rather than to be used in some kind of emulation. For example, the majority of files included in version 1.25 are BASIC programms that can only be run on the hardware of that time as the BASIC interpreter needs functionality of the IBM PC ROM.

Related resources:

Tags: ancient msdos