DOSBox Part 2: Creating, Handling, and Booting from Floppy Images


Table of Contents

Continuing on from the previous tutorial, we move on to boot DOS systems from floppy images. Many floppies contained games or other software that would have automatically booted once the system started (using the autoexec.bat script). This can be simulated by using a floppy image which is simply a file that represents an entire floppy disk drive.  

Obtaining a Bootable Image

There are places you can visit on the Internet where you can download DOS systems in the form of bootable disk images. To start with, all that is needed is a disk image that will boot into MS-DOS. This guide will also show you how to load several floppies at once using the “boot” command in DOSBox. Look for an MS-DOS 6.22 boot disk as an example.  

Booting the Image

Once the floppy image has been obtained, open up the DOSBox config file and scroll to the bottom of the autoexec section to insert some commands that will allow you to easily boot from an image. My recommendation is to mount the directory where you intend to keep your floppies first, then navigate to them to reference the floppy image file.

mount Y: /home/unix_allsort/.dosbox/floppies
Y: Now run the boot command to boot from the image as well as specifying the drive to boot from. boot “MSDOS622.IMG” -l a DOSBox should successfully boot the floppy image.

Note that “-l a” simply tells “boot” to boot from the A: drive.

boot dosbox floppy image

Multiple Floppies

DOSBox can take multiple floppy images as parameters for the boot command. Again, it is recommended to put these floppies in the same directory as the boot image just to make it easier down the track, but that is entirely up to you.

boot “MSDOS622.IMG” “documents.img” “games1.img” “games2.img” -l a 

This will boot into MS-DOS 6.22 with the option to cycle through the images. DOSBox will treat the DOS 6.22 image as the A: drive and the “documents.img” file as the B: drive.

To cycle through the loaded images, press Ctrl-F4 to put the next set of floppies into their drives, so “documents.img” goes into A: and “games1.img” into B: Pressing Ctrl-F4 again will put “games1.img” into A: and “games2.img”. Ctrl-F4 will then go back to the beginning of the floppy list.

boot multiple floppies dosbox

Creating Blank Floppy Images

The command line will be used to create the images. The tools needed are ‘dd’, ‘fdisk’, and ‘mkfs.fat’. On systems like Ubuntu, you should already have these tools installed. First, let’s create the actual file itself using ‘dd’:

$ dd if=/dev/zero of=documents.img bs=1K count=1440 
burn image to floppy using dd

A standard 1.44MB floppy image has been created using ‘dd’. Next step is to run fdisk on the image itself to create the FAT16 partition:

$ fdisk documents.img 

Press ‘n’ to create the new partition. Accept the default settings. Then change the partition type to FAT16. Press ‘L’ to find the code to enter for FAT16 (not <= 32M). Print the partition type using ‘p’ to see the change, and then press ‘w’ to write the changes to the image.

Now that the partition is defined, it needs to be formatted. Simply run ‘mkfs.fat’ on the image to create the filesystem.

$ mkfs.fat documents.img 

By now the floppy image should be ready to use.

mount floppy disk dosbox

Retrieving and Writing Files To And From The Images

You are able to mount floppy images like any other filesystem. Again, Linux provides the tools to achieve this. Run ‘losetup’ to create a loop device to represent the single partition on the floppy image. Next, run ‘kpartx’ to create the loop device for you to use with the mount command. Note that if you don’t have ‘kpartx’ installed, you can install it by installing the ‘multipath-tools’ package.

$ sudo losetup -Pf documents.img
$ sudo kpartx -av documents.img 

The ‘-P’ parameter of ‘losetup’ tells the kernel to scan the partition table once the loop device is completed, and the ‘-f’ parameter instructs it to find the first unused loop device.

For ‘kparted’, the ‘-a’ parameter simply means add the loop devices. The ‘-v’ parameter simply tells ‘kparted’ to be verbose with any output to the terminal.

kparted dosbox

Now you should be able to mount your image to retrieve files and even put some programs in there as well.

mount dosbox image in linux

If you’re finished with the image, you can simply use ‘kpartx’ to disconnect the loop device

$ sudo kpartx -dv documents.img   

In The Next Guide

The next tutorial will explore how to create a hard drive image, attach it to DOSBox, and install a DOS system onto it using its boot floppies. It will, of course, draw upon the knowledge provided in this article to boot disks from.