Site icon LinuxAndUbuntu

DOSBox Part 3: Installing DOS Onto A Virtual Hard Drive

dosbox Installing DOS Onto A Virtual Hard Drive

dosbox Installing DOS Onto A Virtual Hard Drive

The previous tutorial demonstrated the simplicity of ​booting from floppy images and creating other images using the tools provided by Linux. This guide continues on from that as it goes through step by step how to properly create a hard disk image, hook it up to DOSBox, and install whichever DOS you want, be it MS-DOS, PC-DOS, or DR-DOS.  

Creating the DOS Image

​This step would have to be the most complicated as it involves not only creating the image but also gathering a few details of the image such as disk information. There are at least two ways to do this. The first is using the disk image generator that comes with Bochs PC (bximage) to create the disk image. The other (which is covered here) is using ‘dd’ and fdisk.  

Using ‘dd’ Or ‘bximage’

A hard drive with a reasonable capacity should be created. 256MB should suffice for this tutorial.  To do this, run dd:

$ dd if=/dev/zero of=./256MBHDD.img bs=1M count=256

This creates a 256MB file to work with. The other program you can use is bximage. You can download and install this without having to download Bochs itself. All you do is run the command in the terminal and accept all of the defaults, but you may, of course, want to change the filename.

Take note of the number of cylinders from bximage. You will need it for the DOSBox IMGMOUNT command as it requires data about the disk structure. If you used ‘dd’ instead, you can calculate the number of cylinders by multiplying the size of the image in megabytes by 2.03125 (C = S * 2.03125).

​I have used random cylinder numbers without issue; however, I would still recommend that you follow what the DOSBox Wiki recommends to ensure that you run into a few problems as possible. ​

Modifying the Config File

Open the DOSBox config file, go to the ‘autoexec’ section, and insert the IMGMOUNT command that needs to run.

imgmount 2 “256MBHDD.IMG” -size 512,63,16,520 -t hdd -fs none

The numbers ‘512,63,16’ can remain unchanged. 520 is the calculated number of cylinders. Now add the relevant floppy images to the “BOOT” parameter so that DOSBox will boot from the first installation disk to install MS-DOS 6.22.

Launching DOSBox To Install DOS

You may now launch DOSBox from the terminal, which will boot from the first floppy image referenced so make sure it’s the correct disk. Then all you need to do is follow the prompts on the screen. The installation will prompt you to change disks. The reason why this tutorial recommends to run DOSBox from the terminal so you can see which floppies are currently loaded in the A: and B: drives. To change disks simply press Ctrl-F4 until the next disk is in the A: drive.

After the installation is complete, you will be asked to remove any floppies and restart. DOSBox will simply shut down if a reboot is requested.

When DOSBox has closed, edit the config again to have the boot command boot from the C: drive by changing the ‘-l’ parameter from ‘a’ to ‘c’. Also, change the ‘imgmount’ parameters like so:

imgmount C “256MBHDD.IMG” -size 512,63,16,520 -t hdd -fs fat

This isn’t absolutely necessary, but that is what the DOSBox Wiki has suggested. Relaunch DOSBox to boot your new DOS installation. If all went well, DOSBox will boot into the DOS system.

Transferring Files To And From the Image

The previous tutorial demonstrated how to mount individual floppy images in Linux to transfer files to and from them. We can do the same thing with hard disk images. Assuming that you ended up creating only one partition on the disk, you can simply run these commands to mount the virtual partition (where ‘loopX’ is the loop device assigned and ‘/mount/folder’ is the mount directory):

$ sudo losetup -Pf --show 256MBHDD.img
$ sudo mount -t vfat -o uid=$UID /dev/loopX /mount/folder
$ sudo umount /mount/folder

Keep in mind that you may be able to mount and unmount it in your file manager instead of running the ‘mount’ command.

This way you can easily place your downloaded DOS software into the image wherever you please. It is strongly recommended that you do this when DOSBox is not running and to unmount the image from Linux before connecting it to DOSBox.  

What Next?

Now that you have a working DOS installation, you can now obtain whatever DOSBox games and programs you fancy placing in your image. The next tutorial will show you how to install and run Windows 3.11 using DOSBox.

Exit mobile version