I run Linux as my primary operating system, and I start FreeDOS in my virtual machine. Most of the time, I use QEMU as my PC emulator, but sometimes I run other experiments using GNOME Boxes (which use QEMU as a back-end VIRTUAL machine) or VirtualBox.

I like to play classic DOS games, and sometimes I bring up a favorite DOS application. I teach the history of computers in my MIS classes, and sometimes I record a demo using FreeDOS and a traditional DOS application, such As As-Easy-As (my favorite DOS spreadsheet — once released As “shareware” but now available for free from TRIUS).

But using FreeDOS this way means I need to transfer files between my FreeDOS VIRTUAL machine and my Linux desktop. Let me tell you how I did it.

Access the image using GuestMount

I used to access my virtual disk image by calculating the offset of the first DOS partition and then calling the Linuxmount command with the correct combination of options to match that offset. This is always error prone and not very flexible. Fortunately, there’s an easier way to do this. The Guestmount program from the libGuestFs-tools software package allows you to access or mount virtual disk images from Linux. You can install libGuestfs-tools on Fedora with this command.

$ yum install libguestfs-tools libguestfs
Copy the code

Using Guestmount is not as simple as double-clicking a file from the GNOME File Manager, but using the command line is not difficult. The basic usage of Guestmount is

$ guestmount -a image -m device mountpoint
Copy the code

In this usage, _image_ is the virtual disk image to use. On my system, I created my QEMu virtual disk image with the qemu-img command. The GuestMount program can read this disk image format, as well as the QCOW2 image format used by GNOME Boxes, or the VDI image format used by VirtualBox.

The _ device _ option indicates the partition on the virtual disk. Imagine using this virtual drive as a real hard drive. You can access the first partition with /dev/sda1, the second partition with /dev/sda2, and so on. This is the syntax of Guestmount. By default, FreeDOS 1.3 RC4 creates a partition on an empty drive, so the partition is accessed as /dev/sda1.

And _mountpoint_ is where the DOS file system is “loaded” on your local Linux system. I usually create a temporary directory to work with. You only need to use this mount point when accessing virtual disks.

Putting it all together, I use this set of commands to access my FreeDOS virtual disk image from Linux.

$ mkdir /tmp/freedos
$ guestmount -a freedos.img -m /dev/sda1 /tmp/freedos
Copy the code

After that, I was able to access my Freedos files through the/TMP /freedos directory, using the normal tools on Linux. I might use ls/TMP /freedos from the command line, or open the/TMP/Freedos mount point using the desktop file manager.

$ ls -l /tmp/freedos total 216 drwxr-xr-x. 5 root root 8192 May 10 15:53 APPS -rwxr-xr-x. 1 root root 85048 Apr 30 07:54  COMMAND.COM -rwxr-xr-x. 1 root root 103 May 13 15:48 CONFIG.SYS drwxr-xr-x. 5 root root 8192 May 15 16:52 DEVEL drwxr-xr-x. 2 root root 8192 May 15 13:36 EDLIN -rwxr-xr-x. 1 root root 1821 May 10 15:57 FDAUTO.BAT -rwxr-xr-x. 1 root root 740 May 13 15:47 FDCONFIG.SYS drwxr-xr-x. 10 root root 8192 May 10 15:49 FDOS -rwxr-xr-x. 1 root root 46685 Apr 30 07:54 KERNEL.SYS drwxr-xr-x. 2 root root 8192 May 10 15:57 SRC -rwxr-xr-x. 1 root root 3190 May 16 08:34 SRC.ZIP drwxr-xr-x. 3 root root 8192 May 11 18:33 TEMPCopy the code

Accessing virtual disks with GNOME File Manager (Jim Hall, CC-by SA 4.0)

For example, to copy a few C source files from my Linuxprojects directory to C:\SRC on my virtual disk image so that I can use them later under FreeDOS, I can use the Linuxcp command.

$ cp /home/jhall/projects/*.c /tmp/freedos/SRC
Copy the code

Files and directories on a virtual drive are technically _ case insensitive _, so you can refer to them in upper or lower case letters. However, I find it more natural to use all capital letters to enter DOS files and directories.

$ ls /tmp/freedos
APPS         CONFIG.SYS  EDLIN       FDCONFIG.SYS  KERNEL.SYS  SRC.ZIP
COMMAND.COM  DEVEL       FDAUTO.BAT  FDOS          SRC         TEMP
$ ls /tmp/freedos/EDLIN
EDLIN.EXE  MAKEFILE.OW
$ ls /tmp/freedos/edlin
EDLIN.EXE  MAKEFILE.OW
Copy the code

Use guestmount uninstall

Before you use a virtual disk image in a virtual machine again, you should always uninstall it. If you leave the image hanging while running QEMU or VirtualBox, you run the risk of messing up your files.

The guestmount command is supported by guestunmount, which is used to uninstall disk images. Just give the mount point you want to unload.

$ guestunmount /tmp/freedos
Copy the code

Note that the spelling of this command is slightly different from the Linux umount system command.