Copy files between Linux and FreeDOS |

Copy files between Linux and FreeDOS

Here's how I transfer files between my FreeDOS virtual machine and my Linux desktop system.

Files in a folder

Subscribe now

Get the highlights in your inbox every week.

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

I like to play classic DOS games, and sometimes I'll bring up a favorite DOS application. I teach a Management Information Systems (MIS) class where I talk about the history of computing, and I'll sometimes record a demonstration using FreeDOS and a legacy DOS application, such as As-Easy-As (my favorite DOS spreadsheet—once released as "shareware" but now available for free from TRIUS, Inc).

But using FreeDOS this way means I need to transfer files between my FreeDOS virtual machine and my Linux desktop system. Let me show you how I do that.

Accessing the image with guestmount

I used to access my virtual disk image by calculating the offset to the first DOS partition, then calling the Linux mount command with the right mix of options to match that offset. This was always error-prone and not very flexible. Fortunately, there's an easier way to do it. The guestmount program from the libguestfs-tools package lets you access or mount the virtual disk image from Linux. You can install libguestfs-tools using this command on Fedora:

$ yum install libguestfs-tools libguestfs

Using guestmount is not as easy as double-clicking the file from the GNOME file manager, but the command line isn't too difficult to use. The basic usage of guestmount is:

$ guestmount -a image -m device mountpoint

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 in VirtualBox.

The device option indicates the partition on the virtual disk. Imagine using this virtual disk as a real hard drive. You would access the first partition as /dev/sda1, the second partition as /dev/sda2, and so on. That's the syntax for guestmount. By default, FreeDOS 1.3 RC4 creates one partition on an empty drive, so access that partition as /dev/sda1.

And mountpoint is the location to "mount" the DOS filesystem on your local Linux system. I'll usually create a temporary directory to work with. You only need the mount point while you're accessing the virtual disk.

Putting that 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

After that, I can access my FreeDOS files via the /tmp/freedos directory, using normal tools on Linux. I might use ls /tmp/freedos at 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 TEMP


GNOME file manager

Using GNOME file manager to access the virtual disk
(Jim Hall, CC-BY SA 4.0)

For example, to copy several C source files from my Linux projects directory into C:\SRC on the virtual disk image, so I can use the files under FreeDOS later, I can use the Linux cp command:

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

The files and directories on the virtual drive are technically case insensitive, so you can refer to them using uppercase or lowercase letters. However, I find it more natural to type DOS files and directories using all uppercase.

$ ls /tmp/freedos

$ ls /tmp/freedos/EDLIN

$ ls /tmp/freedos/edlin

Unmounting with guestmount

You should always unmount the virtual disk image before you use it again in your virtual machine. If you leave the image mounted while you run QEMU or VirtualBox, you risk messing up your files.

The companion command to guestmount is guestunmount, to unmount the disk image. Just give the mount point that you wish to unmount:

$ guestunmount /tmp/freedos

Note that this command is spelled slightly differently from the Linux umount system command.

Old UNIX computer

It looks like retro computing, but it's a modern OS you can use to get stuff done.
4 different color terminal windows with code

Armed with just two commands DIR and CD, you can navigate your FreeDOS system from the command line.
FreeDOS fish logo and command prompt on computer

If you're already familiar with the Linux command line, try these commands to help ease into FreeDOS.
Looking at a map for career journey

Environment variables are helpful in almost every command-line environment, including FreeDOS.
Tips and gears turning

Here's a helpful guide to batch files under FreeDOS.
Code going into a computer.

An overview of how your computer boots up and starts a simple operating system like FreeDOS.
Person using a laptop

Learn how to configure FreeDOS with FDCONFIG.SYS.
Package wrapped with brown paper and red bow

Get familiar with FDIMPLES, the FreeDOS package manager.
Person using a laptop

FreeDOS provides a user-friendly text editor called FreeDOS Edit.
FreeDOS fish logo and command prompt on computer

Here's how to set up your FreeDOS system manually without using the installer.
Woman programming

Mplayer is an open source media player that's usually found on Linux, Windows, Mac, and DOS.
Computer laptop in space

Many embedded systems today run on Linux. But once upon a time, embedded systems either ran on a custom, proprietary platform or ran on DOS.
Person typing on a 1980's computer

Why does text only come in this limited palette, and why does FreeDOS use those colors and shades, instead of some other colors? The answer, like many things in technology, is because of history.
Old UNIX computer

Edlin is a joy to use when I want to edit text the "old school" way.
Old UNIX computer

BASIC was my entry into computer programming. I haven't written BASIC code in years, but I'll always have a fondness for BASIC and GW-BASIC.
Typewriter in the grass

If you're already familiar with GNU Emacs, you should feel right at home in Freemacs.
woman on laptop sitting at the window

Install Bywater BASIC on your FreeDOS system and start experimenting with BASIC programming.


About the author

photo of Jim Hall
Jim Hall - Jim Hall is an open source software advocate and developer, best known for usability testing in GNOME and as the founder + project coordinator of FreeDOS. At work, Jim is CEO of Hallmentum, an IT executive consulting company that provides hands-on IT Leadership training, workshops, and coaching.