How to install FreeDOS in QEMU

By using the QEMU emulator, you can run FreeDOS inside a window on a host operating system. QEMU will emulate a typical x86 PC so that FreeDOS can run. FreeDOS is mostly compatible with MS-DOS, so you will be able to use FreeDOS and QEMU to run some old MS-DOS programs. You could even put FreeDOS and QEMU on your Apple Macintosh.

This howto will guide you through the process of installing FreeDOS within QEMU.

Preconditions

 * Your computer can run QEMU.
 * There are ports of QEMU to both Microsoft Windows and Mac OS X.
 * You can also run QEMU on Unix (including BSD and Linux) but only if QEMU supports your processor architecture. QEMU can run on x86, x86_64 (also known as AMD64), and PowerPC machines, and possibly others; check the status page.
 * You have installed QEMU.
 * You know how to use the command line (or if you have it, a QEMU graphical user interface) on your computer.

Download FreeDOS
First obtain a copy of FreeDOS.
 * 1) Visit http://www.freedos.org/freedos/files/
 * 2) Follow the instructions and download fdbootcd.iso


 * 1) * Make sure to obtain the newest version (as of this writing, Beta9 Service Release 2).
 * 2) Put fdbootcd.iso in an empty folder with plenty of disk space. You do not need to burn it to CD!

Create disk images
Now we need to create drive A and drive C for FreeDOS. From the command line, cd into the directory with your fdbootcd.iso, and use the following commands:

after cd to the directory with fdbootcd.iso $ qemu-img create a.fd 1440K Formating 'a.fd', fmt=raw, size=1440 kB $ qemu-img create c.hd 100M Formating 'c.hd', fmt=raw, size=1048576 kB

(One hundred megabytes, 100M, should be plenty for drive C, but you can use more or less if you want.)

Boot from CD, run FDISK
Now use QEMU to boot the CD for installing FreeDOS onto drive C. (We ignore our drive A for now.)

$ qemu -hda c.hd -cdrom fdbootcd.iso -boot d



Just press ENTER or choose option 1 to start booting the CD.



Just press ENTER or choose option 1 (again) to pick the "Load XMSdriver" option and continue booting.



Now our new "c.hd" has no data on it, so FreeDOS correctly suspects that you need to format the disk. Choose option 1 to start FDISK. (You must use FDISK to create a partition for drive C before you can create a filesystem.)


 * Do you want to use large disk (FAT32) support (Y/N).[Y]?

The default option of "Y" is okay here.



Choose option 1 to create a partition.



Choose option 1 for the "Primary DOS Partition". (FDISK supports up to four primary partitions. If you want more, then you would create three primary partitions and one extended partition, then add logical drives to the extended partition.)



The easiest thing to do now is to say "Y" to make one large partition. (The partition that you install FreeDOS onto must be active so that it boots.)



Now that your disk has a partition for drive C, press Escape twice to exit FDISK. The system will reboot.

Boot from CD, run SETUP
As before, choose option 1 (twice) to boot FreeDOS Setup and Load XMSDriver.



Now that drive C has a partition, you must still format the disk, which creates a FAT filesystem on it. Answer YES.

At this point, FreeDOS formats drive C. (One can put files in C:\ now.) The installer now begins. If you choose option 0 or wait 5 seconds, the installer will proceed to install FreeDOS from the CD.



From the menu, choose option 1 to "Configure FreeDOS installation settings".



Then choose option 1, "Start installation of FreeDOS beta9". (Optionally, you could adjust the other settings.)



Eventually you will reach the "DETAILED INSTALLATION INSTRUCTIONS". They are outdated. You can ignore them. Just press Escape.



For the install location, enter C:\FDOS so that the screen looks like this:



Now allow the FreeDOS installer to proceed. If it stops at an error like the following:



Just say "Yes" to continue installing. This error involving MODE.COM does not prevent your FreeDOS install from working.

Allow the installation and the post-installation steps to finish.

Boot the hard disk
After the installation, the installer will reboot your computer. However, in this QEMU configuration, any attempt to boot the hard disk will stop at the following screen:



This is a unique problem caused by running FreeDOS in an emulator instead of a hard disk. The FreeDOS kernel sees that there are no disks before C and moves drive C to drive A. (The FreeDOS installer uses drive A for something else, which is why you had to install onto drive C.) Then it stupidly fails to find the system on drive C; the Command Interpreter is at A:\COMMAND.COM now.

The best way to fix this is to close QEMU. Now start QEMU again, but this time put the disk image a.fd into drive A while leaving out the CD:

$ qemu -fda a.fd -hda c.hd

Unfortunately, now if you boot the system, AUTOEXEC.BAT</tt> might crash the QEMU emulator on a MODE command.

Fixing AUTOEXEC.BAT
You can bypass AUTOEXEC.BAT</tt> by choosing "3 - Load FreeDOS without drivers" from the boot menu. If necessary, close QEMU and restart it again (with qemu -fda a.fd -hda c.hd</tt>), then choose option 3 when booting. You will reach the FreeDOS shell:

C:\>

Since it loaded no drivers, you might as well load the mouse driver. QEMU emulates a PS/2 mouse. To load the driver:

C:\>mouse CuteMouse v1.9.1 alpha 1 [FreeDOS] Installed at PS/2 port Now edit the C:\AUTOEXEC.BAT</tt> file. (DOS is case insensitive and the current directory is already C:\</tt> so autoexec.bat</tt> is the same file.)

C:\>edit autoexec.bat

This opens the editor. (You might notice that the clock in the lower-right is running in UTC time.)



Scroll down to "MODE CON..." line and comment it by prepending "REM ", like this:



Now save the file and exit the editor. (You should be able to use the mouse with the File menu; you may need to first click the window for QEMU to grab the mouse and move the DOS mouse cursor.)

C:\>

Back at the prompt, you can safely close your QEMU window. (This is the equivalent of flipping the power switch on a real DOS computer. DOS does not require you to sync the disks, unmount the filesystems, or use a command to halt the system.) Use qemu -fda a.fd -hda c.hd</tt> again to restart the system.

If option 1 "with maximum RAM free, using EMM386" does not work, you should now be able to boot FreeDOS with option 2 "including HIMEM XMS-memory driver". Using option 1 or 2 will automatically load all of the normal drivers, including the mouse driver.

Booting your system for normal use
To boot your installed FreeDOS system for normal use:

cd to the directory with a.fd and c.hd $ qemu -fda a.fd -hda c.hd choose option 2, "including HIMEM XMS-memory driver"

Links
From time to time, you might want to copy files between FreeDOS and the host system. To do this, you might want to mount a raw disk image:

From HowTo Wiki, a Wikia wiki.
 * Howto see the content of a Qemu image on a linux-based OS