How to transfer files to/from Linux and FreeDOS

The guestmount command makes this easy from the command line.

If you need to copy files to (or from) the FreeDOS virtual disk, you should only do this when the virtual machine is not running. Otherwise you will corrupt the virtual disk. I find the easiest way to do this is with the guestmount tool from libguestfs-tools. (If you don`t have this by default on your system, you can install it with your Linux package manager.)

The guestmount command has a particular command line. First, you "add" a virtual disk to work with, using the -a option. Then you need to give a partition in the virtual disk that you want to mount, using the -m option. Note that the -m option uses "/dev/sda1" notation to mean the first partition in the virtual disk, even though this isn't really your system's "/dev/sda1".

For a reasonably sized virtual disk like 20MB or 500MB, FreeDOS configures the disk with just one partition. That means if I wanted to exchange files with my freedos.qcow2 disk, I need to "mount" the "/dev/sda1" partition on that virtual disk to a directory (which I'll call freedos) like this:

$ mkdir freedos
$ guestmount -a freedos.qcow2 -m /dev/sda1 freedos

This might take a second, so don't panic if it doesn't return right away.

Now I can copy files to/from the FreeDOS virtual disk, using a Linux file manager or from the command line. If you want to preserve file timestamps, dont forget to use-p(preserve) with thecp` command on Linux.

Then unmount the directory, and you can use the virtual disk in QEMU as normal.

$ guestunmount freedos