Note
|
These ancient notes are from 1999 when I cared about DOS. There are probably much better ways to do everything today. Off the top of my head, FreeDOS. |
Overview
dosemu is a pretty clever program, but its documentation is a big pile of monkey shit. It is hard to believe that the creators of this program could make something this complicated while so badly neglecting the documentation. It looks like there were several attempts to simplify the usage of dosemu. Unfortunately as new versions came out, new simplifications and installation notes were written. Consequently, the information about how to get dosemu to do something useful on a normal system is totally chaotic. Another big problem is that the dosemu documentation was written by guys who always compiled their own stuff. Having an rpm package just wasn’t a concept for them. The rpm package that came with Red Hat 5.1 is a total mess. And lastly for major problems, the /etc/dosemu.conf file that is in the Red Hat package is a total mess. It checks for the same variable in redundant places and uses the negative "if variable is NOT defined, then A, else B" construction which I think is just confusing. Why not just "if variable IS defined, then B, else A"? So I completely redid it and the major name of the game is simplification.
The General Steps To Running Dos In Linux
-
We Need An OS
dosemu is not really a DOS emulator, it is a DOS "environment" emulator. It provides the environment and you provide the DOS. This means that you need to have the kernel to a DOS lying around somewhere. This isn’t really such a big deal since everyone on the planet has some old DOS disks lying around - 1 old DOS boot disk is all it takes. It’s a damn shame that all of the DOS’s worth using are proprietary; that’s why the dosemu team can’t just set you up with a nice DOS environment. They do provide FREEDOS, but apparently, at this time, it sucks, so it’s best to use your own IBM DOS or DR-DOS…You woudn’t use a DOS by that other company would you!? Whew! I hope not.
So I prefer DR-DOS (which you can buy at a used software store for less than $10 - I did). I own DR-DOS, but it was not in the same country as I was when I needed this disk. No problem! Just have a friend who has access to your DR-DOS disks make a disk image file and email it to you. The best disk to use is the disk #1 of the installation set, but any bootable DOS disk that contains the sys.com program should work. Once you have such a disk, here’s what you do: Have your friend put the DR-DOS bootable disk in the floppy drive while running Linux and type the following command:
# dd if=/dev/fd0 of=~/drdos.img bs=72k
Easy! Now have your friend mail you the file "drdos.img". This should be 1474560if it’s a normal disk or 737280 if it’s a "high density" disk like the old DR-DOS disks were. Oh ya, if you really are mailing it, don’t forget to compress it before mailing:
# gzip ~/drdos.img
And when you receive such a file:
# gunzip drdos.img.gz
-
Get Your Images Ready
You already have one DOS image - this is the file that was made by doing the raw copy off the disk, drdos.img. You will need another image if you want to do anything useful. There are two strategies for this. One is to use a DOS partition that already exists on your drive. The other is possible even if you have no DOS partitions on your drive. The second method involves creating a file in your Linux filesystem that DOS treats as if it were an entire hard drive. This is the method I’m doing here. I did this setup work as root and I had my file ~/drdos.img in my /root directory. That’s a fine place to keep a backup of this, but it works out better if you copy that file here:
# cp ~/drdos.img /var/lib/dosemu/imageA
Next you need to create another that you will really use. Think of this as creating a virtual disk drive on your Linux filesystem. You could set up a big file filled with zeros, but this doesn’t work. The DOS utilities need these hard drive images to have the special formats of real DOS hard drives. There is a program that comes with dosemu (or did when I got it!) called "mkfatimage16". To use it, issue the following command:
# mkfatimage16 -b ./imageA -k 20000 -f ./imageC -p
This assumes that you are in the directory /var/lib/dosemu. The ‘-b ./imageA’ flag tells mkfatimage16 to copy the boot information from your DRDOS image file thereby giving the new image the same low-level boot characteristics - this doesn’t put the system files on the new image!, it just gives it a sensible boot structure. The ‘-k 20000’ is the number of kilobytes to make the virtual drive. I made this one 20MB. The ‘-f ./imageC’ is the output file. You can use ‘>’ redirectors if it makes you happy, but this works. The ‘-p’ flag tells the program to fill the rest of the empty virtual hard drive with zeros (pad). This may not truly be necessary, but at this stage it certainly can’t hurt.
There might already be an image file in /var/lib/dosemu. Maybe something like "hdimage". I would rename it:
# mv ./hdimage ./imageD
This is the file that contains the little FREEDOS distribution and some handy utilities. Now you have 2 virtual hard drives - a 20MB one that is empty and a 2MB one that has the FREEDOS distribution on it. You also have a virtual floppy disk that contains the image of your real DOS disk. All of these components will behave just like their physical counterparts.
-
Fix Your Broken /etc/dosemu.conf
Like I said, this file’s a mess "out of the box". I totally trimmed it down. Here it is in it’s entirety:
# Linux dosemu 0.66 configuration file.
# cxe- Heavily modified for full access or none.
ifdef h_oddhost.hell.com ### 1+ ## host-allowed checking
abort "This host is not allowed to use dosemu."
endif ###1-
define vbootfloppy ## to boot from a virtual floppy
debug { off }
dosbanner on
timint on
terminal { charset latin updatefreq 4 color on }
X { updatefreq 8 title "DR-DOS" icon_name "xdos" }
mathco on
cpu 80586
xms 1024
ems 1024
keyboard { layout us keybint on rawkeyboard on }
HogThreshold 1 ##cxe- Important!! Stops massive CPU Hogging
#serial { mouse com 1 device /dev/mouse }
ttylocks { directory /var/lock namestub LCK.. }
video { vga }
sound_emu off
secure off
dexe { allowdisk }
ifdef vbootfloppy ### 2+
bootA
floppy { heads 2 sectors 18 tracks 80 threeinch file /var/lib/dosemu/imageA }
disk { image "/var/lib/dosemu/imageC" }
disk { image "/var/lib/dosemu/imageD" }
else ### 2e
bootC ## Startup drive valid values: bootA bootC
ifndef c_dexerun ### 3+
disk { image "/var/lib/dosemu/imageC" }
disk { image "/var/lib/dosemu/imageD" }
endif ### 3-
floppy { device /dev/fd0 threeinch }
endif ### 2-
dpmi 4086 ## DPMI size in K, or "off"
irqpassing off ## this disables IRQ monitoring
speaker native ## or "off" or "emulated"
ipxsupport off
printer { options "%s" command "lpr" timeout 20 }
Note that the important things are the disk images. The general strategy of this file is to boot from a "floppy", real or virtual, or boot from a "hard drive", real or virtual. This descision is done manually buy commenting out the line that "defines vbootfloppy". If you put a # at the beginning of that line, it won’t try to boot from a floppy image (on a floppy or otherwise). In this particular file, I have it set up to boot from the floppy image we created - imageA. I also want the imageC and imageD to show up too.
-
Use dosemu To Finish The Dos Work
Now we would like to do something useful with our big empty virtual DOS partition. The ‘mkfatimage16’ program creates a file that is like a DOS partition that has just been formatted, but without the /S switch that copies over the bootable system files. If we had such a situation with a real DOS partition, one would just have to put in a DOS bootable system disk that contained the SYS.COM program. This is simply a DOS program that when run, copies all of the system files necessary for a stand-alone DOS system to the target. Remember I said to make sure that file was on your DOS floppy image? We’re going to use it now.
SYS.COM is a DOS program and at the moment, it’s hiding in your imageA file. That’s just right for the /etc/dosemu.conf file above. Go ahead and run dosemu with this command:
# dos -X
I get a couple of errors that complain about not having the right fonts - I think they were supposed to come with the dosemu distribution - good job Red Hat. Anyway, if you’re lucky like me, a readable DOS box will pop up anyway and you are now running DOS as if you had put that disk on a computer with the 2 hard drive partitions that we created (imageC & D). Since my imageA disk image was from the DR-DOS intall disk, right away, the activity in the dosemu is trying to "install" DR-DOS. Uh, no thanks… So I shut that down and get to a A> prompt. Once at the DOS prompt, I check out my other letters by typing ‘C:’ and then ‘D:’.
Ok, if all that works, you’re in good shape. Go back to the A> prompt by typing ‘A:’. Now if you really have SYS.COM on your A image, you should be able to type:
A>sys c:
Which returns this for me:
Destination Disk was not formatted under current Operating System.
Writing new boot sector.
System files copied
This message says that it’s a little confused that the partition was initially formatted by something other than itself. I suppose if you think it would make things go smoother, you could have your DOS reformat the imageC at this point. You could use the /S switch and skip the SYS command. But DR-DOS has a weak formatting program so this way is better for me.
-
Finish With The Floppy Boot Image
Ok, now the boot floppy has done it’s work. It has passed on it’s ability to boot a DOS kernel to a virtual hard drive image on your Linux file system. Now we’ll want to have that virtual hard drive do the booting from now on when we use dosemu. Simply edit the /etc/dosemu.conf file and put a &8216;’ in front of this line:
# define vbootfloppy ## to boot from a virtual floppy
as shown. This now causes dosemu to boot the actual DOS kernel from your imageC file. Now the next time you run dosemu, you should see a C: and D: drive. Any reference to A: will actually go out to the real disk drive which will deal with DOS floppys seamlessly.
Give it a try by shutting down the dosemu (if you haven’t already). This is done with the key combination Ctrl+Alt+PgDn. I will warn you that I had trouble gettin a console dosemu session to die with this method. You can always open another window somewhere and kill its process. No problem there. After you shut it down, and the /etc/dosemu.conf is edited, fire it back up. A: should go for a real disk, C: should be mostly empty with one visible file, and D: should have the FREEDOS package.
-
Setting Up mtools
By itself, these partitions aren’t too useful. Basically, we need to load them with STUFF. Remember that DOS is a little toy that runs in the Linux universe. There is no good or easy way to give the DOS programs you want to run access to your Linux world. But since it’s a toy that Linux created, it can play with the contents of the DOS subset quite easily. The package that allows Linux to speak to DOS systems is mtools. The mtools allow Linux to basically have all of the commands of DOS for mounted DOS filesystems. It also applies to DOS image files too. So pretending that your imageC file is really a C: DOS drive, you can copy files right to it that way using mtools. But it has to be setup first. Here is my /etc/mtools.conf file:
drive a: file="/dev/fd0" exclusive
#dosemu floppy image
drive b: file="/var/lib/dosemu/imageA"
#dosemu hdimage
drive c: file="/var/lib/dosemu/imageC" partition=1 offset=128
drive d: file="/var/lib/dosemu/imageD" partition=1 offset=128
mtools_lower_case=1
Basically, what’s going on here is that you are defining alias for mtools to work with. You tell it that whenever you mention a: you really mean a real DOS floppy in the real drive device. Further, you specify that if you say B:, C:, or D:, you mean images A, C, & D respectively. Don’t worry about imageA being called B by mtools. It’s just a name and to dosemu, imageA is nothing anymore.
Now we can issue very DOS-like commands that can perhaps reference our new virtual harddrives or perhaps our real Linux file system. It doesn’t matter. Here’s an example:
# mcopy ./* c:
This just copied the entire contents of my current Linux directory into my C disk image.
Oviously, there’s a bunch more cool stuff that can be done with dosemu, but to just get it running your favorite simple DOS application, this seems to be the way to go.