Qemu transfer files between host and guest via the floppy drive

Howto transfer files using floppy images on QEMU

You have already created your virtual machine (the guest) using qemu. Now you want to transfer files from it to your desktop (the host), for example. In this article, we create an image of a floppy in a file and use it to store data on it. You will not need a physical floppy drive.

Create the folders and the floppy image
host system

su cd /root dd if=/dev/zero of=floppy bs=1440K count=1 mkfs.ext2 floppy mkdir /mnt/tmp mount -o loop /root/floppy /mnt/tmp copy files to /mnt/tmp umount /mnt/tmp

Explanation

We created a file called /root/floppy, sized it then formatted it to a floppy standard size.

We created a folder called /mnt/tmp and thru the magic of loopback filesystem made it accessible to the floppy image.

We then copied whatever files you like to the floppy image. So in copying files to /mnt/tmp you actually made changes to the floppy image at /root/floppy

Once the file and the mount point is created you can reuse it as you use the file manager to delete or copy files to /mnt/tmp for future use.

Note that we need to unmount the floppy image for when we want to do the actual transfer to the guest. Leave it mounted until you have all needed files to the floppy image.

Start the guest os
There are lots of instructions on how to make a qemu image.

This formula starts a image called s.img in the cwd.

qemu -boot c -net none -hda s.img -m 320 -fda /root/floppy

Explain

-boot c = boot the hard drive image

-net none = with no net access

-hda = change pathway to where you have stored your guest image

-m 320 = guest has 320 Megs of RAM

-fda = where qemu is to find the floppy image

Access the floppy image
First you need to mount the image as if it was a floppy disk.

su mount -t ext2 /dev/fd0 /mnt/floppy

Now you can use your file manager or command line interface to access the files inside the image.

Two way transfers
A host to guest has already been discussed

B guest to host.

Well you are in the guest with an already created floppy image that is mounted. So use the file manager etc to copy files to the floppy.

The trick with both A & B is to umount the original source before trying to access it with the other system.

So in guest

mount -t ext2 /dev/fd0 /mnt/floppy copy files umount /mnt/floppy

And in host

remount the floppy image with mount -o loop /root/floppy /mnt/tmp