Transmission Zero

Installing MS-DOS in DOSBox



Introduction

This article explains how to install a DOS operating system and run it using DOSBox. I’m using MS-DOS 6.22 in this article, but it should work for other versions of DOS, and for DOSes from vendors other than Microsoft. You might be wondering why you would want to do this. It’s a fair question, because DOSBox has its own DOS-like environment, and supports the DOS API which allows many applications such as classic games to be run without the user needing to own a copy of DOS. But maybe there is something which is not currently supported by the DOSBox environment, or perhaps you just want to create a more authentic DOS experience. In my experience, DOSBox does run DOS much better than various virtualization products on the market, plus it emulates hardware such as an OPL3. But whatever your reasons may be, the fact that you’re reading this article suggests that this is something you want to do, so let’s get started.

There are some details in this article which are specific to DOSBox running under Microsoft Windows, for example the paths in the screenshots and configuration files. However, the instructions should be easily adaptable for those who are using other operating systems such as Linux and Mac OS. Additionally, some of the commands and configuration files contain paths specific to my Windows installation, for example the user profile directory varies between versions of Windows—you’ll need to adjust these paths to suit your PC setup.

What You’ll Need

There are a few things you’ll need in order to install a DOS OS in DOSBox. All of these can be freely downloaded from the internet, except for MS-DOS, which you’ll need to have your floppy disk images handy for. You’ll need:

If you haven’t done so already, you’ll need to create the floppy disk images using a disk imaging tool and your original DOS installation disks.

Creating A Hard Disk Image

Installing DOS in DOSBox requires that DOS be installed on a hard disk image. You will then use DOSBox’s internal boot command to boot from this image. The disk image can be created using bximage from the Bochs binary distribution (see the the “Advanced Topics” section for alternative methods):

C:\Program Files (x86)\Bochs-2.4.5>bximage -q -hd -mode=flat -size=250 "u:\mpayne\DOSBox\Images\Hard Disks\MS-DOS 6.22.img"
========================================================================
                                bximage
                  Disk Image Creation Tool for Bochs
        $Id: bximage.c,v 1.34 2009/04/14 09:45:22 sshwarts Exp $
========================================================================

I will create a 'flat' hard disk image with
  cyl=507
  heads=16
  sectors per track=63
  total sectors=511056
  total size=249.54 megabytes

Writing: [] Done.

I wrote 261660672 bytes to u:\mpayne\DOSBox\Images\Hard Disks\MS-DOS 6.22.img.

The following line should appear in your bochsrc:
  ata0-master: type=disk, path="u:\mpayne\DOSBox\Images\Hard Disks\MS-DOS 6.22.img", mode=flat, cylinders=507, heads=16, spt=63
(The line is stored in your windows clipboard, use CTRL-V to paste)

Press any key to continue

The above command line tells bximage to use quiet mode (don’t prompt the user to confirm the details already provided), to create a hard disk image, to use a flat image file format, to give it a size of 250 MB, and to create the image at “u:\mpayne\DOSBox\Images\Hard Disks\MS-DOS 6.22.img”. Using a flat image is very important, as this is the only format supported by DOSBox—growing images are not. Although a flat image results in the image taking up disk space equal to the size of the image, you can use NTFS compression if your disk is formatted using the NTFS filesystem. In fact, bximage will use NTFS compression by default if it’s supported, and it’s a great space saver.

You should also avoid creating a disk image larger than 504 MB, as this results in the number of cylinders being greater than 1024—above the limit which is supported by the disk access methods used by MS-DOS. If you try to do this then certain nastiness will happen, such as the disk appearing to be much smaller than it actually is. There is a workaround for this which is mentioned in the “Advanced Topics” section.

Setting Up DOSBox

I would recommend creating a new DOSBox configuration file for your MS-DOS installation, so that you can easily switch between configurations. It’s probably also a good idea to use your existing DOSBox configuration as a starting point for the new one. On my computer running Windows 7 Home Premium (x64 version), the default user configuration file is located under “C:\Users\mpayne\AppData\Local\DOSBox”, but the exact location may depend on factors such as your operating system version and language. You should also remove everything under the “[autoexec]” section of your new configuration file (or comment it out if you haven’t created a new config file). We will be specifying our own configuration there later.

Once you’ve created the new configuration file, you’ll probably want to create a copy of the DOSBox shortcut and modify the target so that it uses your new configuration file:

[Windows Explorer shortcut properties for DOSBox]

The “-userconf” option from the original shortcut has been replaced with “-conf "U:\mpayne\DOSBox\conf\MS-DOS 6.22.conf"”, and should point to the location of your configuration file. I also specified the “-noconsole” switch to hide the console window, but this is just a personal preference of mine and is not essential here.

From this point onwards in the article, all configuration changes are made to this new configuration file.

Installing MS-DOS

In order to install MS-DOS, we need to tell DOSBox to mount our disk image. You can do this by putting something similar to the following under the “[autoexec]” section of your configuration file:

imgmount 2 "U:\mpayne\DOSBox\Images\Hard Disks\MS-DOS 6.22.img" -size 512,63,16,507 -fs none

REM The following is wrapped because it is a long line. You should put this "boot" command all on the same line!
boot "U:\mpayne\DOSBox\Images\Floppy Disks\MS-DOS 6.22 - 1.img" "U:\mpayne\DOSBox\Images\Floppy Disks\MS-DOS 6.22 - 2.img"
"U:\mpayne\DOSBox\Images\Floppy Disks\MS-DOS 6.22 - 3.img"

The imgmount command tells DOSBox to mount your disk image, and specifies the type of disk and its geometry. You will need to change the size parameter so that the number of cylinders matches that of the output of the bximage command—notice that the “507” in “-size 512,63,16,507” from the above matches the “cylinders=507” in the bximage command output, and this value depends on the size of the image you created.

The boot command tells DOSBox to boot from the floppy image “U:\mpayne\DOSBox\Images\Floppy Disks\MS-DOS 6.22 - 1.img”, which is an image of the first of the three MS-DOS setup disks. DOSBox will boot from the first disk specified here, but you will need to specify the paths of all of the setup disks in order to switch disks once DOSBox is up and running.

Now the configuration is ready, you can start DOSBox up using the shortcut we created earlier. The MS-DOS setup should start:

[MS-DOS Setup screen]

If your disk hasn’t been already partitioned or formatted (as is the case if you created the image using bximage), the MS-DOS setup will perform this task for you. Alternatively, you can shell out to DOS, run fdisk, reboot, run format, and then resume with the setup. Once the disk is formatted, the setup will run, and after a short while you’ll be requested to insert the second floppy disk:

[MS-DOS Setup asking the user to insert the second disk]

You can switch disks by hitting Ctrl + F4. Each time you switch disks, it will mount the next image you passed to the boot DOSBox command, until you cycle around to the first disk again. The setup will now complete itself, prompting only when it requires the next floppy disk to be mounted.

Booting MS-DOS

Now that MS-DOS has been installed on your disk image, all that remains is to boot from the disk image rather than the floppy images. You can remove (or comment out) the existing boot command from the “[autoexec]” section of the configuration file, and add a new boot command telling DOSBox to boot from the first hard disk. It should now look something like this:

imgmount 2 "U:\mpayne\DOSBox\Images\Hard Disks\MS-DOS 6.22.img" -size 512,63,16,507 -fs none
boot -l c

You can start DOSBox up again, and MS-DOS will now boot on its own. You are now free to perform tasks such as installing the MS-DOS supplementals, tune your autoexec.bat and config.sys to load additional drivers and optimise the memory usage, or install applications.

[DOSBox running Magic Land Dizzy under MS-DOS 6.22]

Things To Be Aware Of

By running MS-DOS from a disk image, you will lose some of the niceties of the DOS environment which DOSBox provides. Some such examples are the ability to mount and unmount drives whenever you like, and the ability to run DOSBox’s internal commands. Also, if you need to use the mouse in MS-DOS you will need to load a suitable mouse driver.

DOSBox does not emulate CD-ROM hardware, so you won’t be able to load CD-ROM drivers and access a CD-ROM drive or ISO image. An alternative could be to use a hard disk image and attach an additional IDE drive to DOSBox. You will still be unable to switch between disk images while DOSBox is running, however.

One thing to be very careful of is to avoid having multiple DOSBox instances mounting the same disk image. Writing to a disk image simultaneously from different DOSBox instances can cause the disk image to become corrupted. I would also recommend always specifying the disk geometry when mounting disk images. Failing to do this can result in DOSBox being unable to determine the disk geometry under certain circumstances, for example in the case that the number of heads is not 16.

Advanced Topics

These are some topics which I didn’t mention in this article because they are more advanced than I intend to cover here. You might want to investigate these further:

I hope that this article has helped you get MS-DOS up and running under DOSBox. If you have any questions or suggestions, don’t hesitate to get in contact.