Dosemu is a project to create a ‘virtual machine’ inside Linux, in which you can run ms-dos and ms-dos programs. It does not emulate ms-dos itself, so you still need a copy of ms-dos or one of its clones (like freedos). Dosemu is not yet quite perfect, still having some problems with a few kinds of graphics and sound, but it runs many programs very well.
The main problem with dosemu is its lack of documentation — a very common problem with free software, unfortunately. However, dosemu is not difficult to install, and it is a nice thing to have around. That’s why I wrote this ‘dosemu for dummies’. I’d be grateful for comments and additions: firstname.lastname@example.org .
NOTE: This article applies to the latest stable dosemu version, 1.2.0. If you have an older version, e.g. 18.104.22.168, you should definitely upgrade, because the new version is much improved. Many things which work in dosemu according to this article, do not work in version 22.214.171.124.
2. The dummy method for setting up dosemu
There are many ways in which dosemu may be installed. In this document I describe a method in which the dosemu program itself is installed in a central location on the system, while users each have a sub-directory called ~/dos in their home directory which acts as their ‘C: drive’. This ‘pseudo C: drive’ has DOS (and other programs) installed in it. If there is more than one user on the system, each has his/her own, private ‘pseudo C: drive’.
This method is not standard. RPM and Debian packages put the C: drive by default somewhere else in the filesystem, in a location which is not writable by ordinary users (who normally have write permission only inside their own home directory). So for doing actual work, installing programs, etc, you must use another (writable) location, which under MS-DOS will be the ‘D:’ drive. I never liked this (several programs which I moved from an old DOS system assumed they were running from C:). ‘Standard’ distributions can be set up, however, to give you a writable C: drive. This document describes how to do this.
This method supposes that all the programs and data which you want to use are in your own ~/dos directory. dosemu can use existing ‘MS-DOS partitions’ on your system (even to boot from), but finding out how to make it work, dealing with permission problems, etc., is more trouble than it’s worth (I think). So the ‘dummy method’ involves copying DOS itself, your DOS programs, and your data to ~/dos (a.k.a. the ‘pseudo C: drive’), in your home directory. This does cost disk space, but it greatly simplifies things, and disk space is very cheap nowadays. And if it works, of course, you can free the old disk space.
This method is aimed at ‘dummies’, ordinary home users. dosemu in fact has many capabilities for professional use, but I don’t know anything about them. Don’t look in this document for answers to problems about networking, record locking, Novell IPX, etc.
Finally, this method supposes that you run your DOS programs mostly in a window in X. Running dosemu on the console, as an ordinary user, is possible, but only in text mode; see section 7. Graphics display on the console is only possible when you are root. It is, however, not advisable to do actual work on a Linux system while being root.
NOTE: When you run dosemu as user in X, pressing control-alt-F switches dosemu to full-screen. This gives practically the same ‘look and feel’ as running it on the console. You need dosemu version 1.3.0 for this; at the moment this is a ‘compile-yourself’ version (see section 5.3).
3. Creating a clean system
If you are happy with your existing dosemu installation, fine. If not, it is best to start with a clean slate. So first, you should remove any trace of (possible older versions of) dosemu that might be present on your machine. E.g., in the case of Debian:
dpkg --purge dosemu
Follow this by eradicating all traces of freedos, if you’ve got it. To find such traces, you can run (as root) updatedb, then locate dosemu and locate freedos.
4. Before installing dosemu: preparing the ‘pseudo C: drive’
Next, you make a DOS subdirectory in your Linux home directory:
cd mkdir dos
This directory, ~/dos (with its subdirectories) will become your DOS ‘pseudo C: drive’. It is in your home directory, so only you can use it — for reading and writing. The point here is that an ordinary Linux directory can play the part of a DOS C: drive (the one you boot from, and that contains your applications) in modern versions of dosemu. In the past this was not the case, it seems. The man page of dosemu.bin gives no less than four different ways of creating a dosemu boot drive, but using a simple Linux directory is not one of them.
Now you can copy all the DOS stuff from your DOS partitions to this directory, maintaining a sensible subdirectory structure. For instance, to copy your old Wordstar, residing in directory ws on the DOS/Windows D: drive (mounted, say, as /dosd), you just type:
cd ~/dos cp -a /dosd/ws .
If you feel confident, you can remove Wordstar from its old location by means of rm -Rf /dosd/ws. It is not necessary to do this immediately (I assume you have no shortage of disk space!)
Copy all of your favourite DOS stuff to ~/dos. Not only text-mode programs! dosemu will also handle graphics programs (e.g. games) OK. However, you should do this only for applications, not yet for the MS-DOS operating system itself.
No DOS boot disk is complete without its AUTOEXEC.BAT and CONFIG.SYS files. Put them in your ~/dos directory. It is best not to put anything fancy in them at first (you may have to, later, but keep it simple at first). I started with the following:
@ECHO OFF PROMPT $p$g PATH C:\;C:\DOS;
The lines have to end, MS-DOS fashion, with CR+LF. Editing the files by means of joe -crlf <filename> will work OK.
NOTE: joe is the nicest text editor on a Linux system for people who got their first computer experience in (or even before) the MS-DOS era, because it works just like Wordstar and the ‘Borland Turbo’ editors. It has a lot of enhancements, making it thoroughly up-to-date. Of course Linux purists will advocate (horror) vi or (shudder) emacs. I swear by joe (I already used Wordstar on an Apple ][+).
4. Installing DOS
The ‘pseudo-C: drive’ in your home directory (~/dos) must be made ‘bootable’ under dosemu. This means that you have to install a version of DOS on it. There are several possibilities, of which I recommend the first two because they are the least complicated by far:
- You can install a ‘real’ MS-DOS which you have lying around somewhere. You need to put three files into the root directory of your ‘pseudo C: drive’ (i.e. into ~/dos) : io.sys, msdos.sys, and command.com. I had MS-DOS 6.00 still lying around, so I used the files from that.
NOTE: Installing DOS by just copying the files works with DOS 6 and up. It does not work with DOS 3.3, for instance. It is possible to boot DOS 3.3 under dosemu, but it is more complicated.
NOTE: It will work just as well with IBM’s own DOS version (PCDOS). The system files in PCDOS are called ibmbio.com (replaces io.sys) and ibmdos.com (replaces msdos.sys).
- If you have Windows 98 (or 95) you can make a bootable floppy, under Windows in DOS mode, with the sys a: command, and copy the three files from the floppy (ignore drvspace.bin which is also there). The DOS utilities belonging to Windows 95/98 are in c:\windows\command.
NOTE: To boot the DOS from Win98 neatly (without a Windows logo flashing by, and arriving at the correct prompt) it is best to edit msdos.sys. In ‘Windows DOS’ this is a text file, which originally has just one line in it:
You should edit it (with an MS-DOS editor, or for instance with joe -crlf) to read
[Options] Logo=0 ;SYS
- You can use freedos (an open-source MS-DOS clone). How to install this is covered in section 5.4 of this document.
NOTE: freedos does not have separate io.sys and msdos.sys files; the two of them are replaced by one file, kernel.sys.
NOTE: With freedos you may experience problems with some terminate and stay resident (TSR) programs; Borland Sidekick refuses to install. This problem has not yet been fixed.
- You may be successful with DrDOS. I have not tried this myself.
After making the ‘pseudo C: drive’ bootable in this way, it is useful to make a directory called dos inside it, containing the utilities that usually come with a DOS distribution (like more, debug, sys, etc.). So that directory will be ~/dos/dos.
5. Installing dosemu
Now we install dosemu itself. If possible, this should be done after preparing a pseudo-C: drive with DOS in it (but that may not be possible if you have to use freedos). There are several options for installation: below I mention ‘RPM’, ‘Debian’, and ‘source’. On www.dosemu.org a fourth method, ‘binary install’, is available, but there are some problems with it and I do not recommend it.
The different methods install dosemu’s files in different locations. The RPM version stores a lot of files in /usr/share/dosemu. Debian prefers /usr/lib/dosemu. The self-compiled ‘source’ version puts almost everything in /usr/local.
These differences are perhaps confusing, but they aren’t really a problem. As a user, you only have to deal with things in your own home directory. An exception is perhaps the main dosemu configuration file, dosemu.conf. But fortunately all installation methods put it in the same place (in /etc/dosemu). And you won’t even have to touch it, because in dosemu 1.2.0, all settings can be overruled (on a per-user basis) by means of a .dosemurc file in the user’s home directory.
5.1 RPM install
For users of RedHat and similar distributions, an RPM package with dosemu + freedos + dosemu fonts is available from www.dosemu.org (look for ‘stable releases’, ‘binaries’, ‘dosemu-1.2.0-1.i386.rpm (all-in-one RPM, includes FreeDOS)’. Download & install it in the usual way. When you are ready to run, skip to section 5.4.
5.2 Debian install
Much as I like Debian, I cannot honestly recommend the Debian version of dosemu, because of its bizarre tangle of symbolic links. That is, if you need freedos. Making freedos work with it is very complicated. Perhaps the best thing Debian users can do is to convert the RPM package to .deb format using alien, and then to install that. But true Debian diehards can proceed as follows:
Debian has dosemu 1.2.0 in the unstable (‘Sid’) distribution since 20 January 2004. You need the dosemu and xfonts-dosemu packages, and optionally dosemu-freedos (if you don’t want to use ‘real’ MS-DOS). If your sources.list file points at ‘unstable’, you can install everything by means of:
apt-get update apt-get install dosemu dosemu-freedos xfonts-dosemu xset fp rehash
(the xset command is necessary to make X aware of the recently installed fonts in the xfonts-dosemu package. This is probably a bug; the Debian installer itself should have taken care of this).
After installing the Debian package, you must create a file in your home directory called .dosemurc, which tells dosemu where your ‘pseudo C: drive’ is. .dosemurc must contain the line:
$_hdimage = "/home/yourname/dos"
(Of course you must replace yourname by your own login name on the system). When you are ready to run, skip to section 5.4.
5.3 Source install
Of course compiling and installing from source is also possible. This may not be entirely ‘for dummies’. Actually I think this is the easiest method. You can also use the very newest releases; version 1.3.0 has been available (as a ‘developer release’) since March 7, 2004.
- Get dosemu-1.3.0.tgz from www.dosemu.org (under ‘developer releases’) into your home directory. Then do:
- tar zfvx dosemu-1.3.0.tgz
- cd dosemu-1.3.0
- If all goes well (and it will, if you have the necessary compilation tools installed), become root and do make install.
5.4 Running dosemu the first time
Now try to run (as a normal user) xdosemu. What happens next, depends on how you installed things.
- RPM and source installations will ask you the location of your pseudo C: drive. Answer /home/[your-login-name]/dos.
- A Debian installation will not ask this; you must already have put the location of the pseudo C: drive into .dosemurc (see section 5.2).
- You will also be required to confirm, by typing “yes” (not just y or pressing Enter), that nobody except you is responsible for any possible damage caused by dosemu. dosemu then creates a subdirectory .dosemu in your home directory with some stuff in it, and then starts.
- If you have not installed a form of DOS in your pseudo-C: drive yet, a window will appear next, saying:
Sorry, there is no operating system.
If this happens, you must close the window by means of CTRL-ALT-PgDn, and fix the problem by putting freedos into the pseudo-C: drive. See the box below.
- If you do have a form of DOS in your ~/dos directory, then, with any luck, your DOS will start. You can play around with your old favourite DOS programs for a while. Wordstar, Wordperfect, Turbo C, Lotus Symphony, Symantec Q&A, and many games, will work. Well, they did when I tried it.
cd cd dos cp -a /usr/share/dosemu/freedos/* .
cd cd dos cp -a /usr/lib/freedos/* . rm autoexec.bat cp /etc/freedos/autoexec.bat . rm config.sys cp /etc/freedos/config.sys . cd dosemu rm * cp -a /usr/lib/dosemu/commands/* .
One big difference between the RPM and Debian versions of freedos is that the RPM has a real command.com, while Debian uses a command interpreter built (I assume for some valid, but now obscure historical reason) into dosemu itself. This complicates things (more symbolic links!).Both RPM and Debian install AUTOEXEC.BAT and CONFIG.SYS files which may be too complicated for your needs. If the boot-up messages are puzzling: simplify AUTOEXEC.BAT and CONFIG.SYS.
From time to time you should check the .dosemu directory. While dosemu is running it has a few things in it. For instance, in ~/.dosemu/run there are dosemu.2597, dosemu.dbgin.2597, dosemu.dbgout.2597, and dosemu.mapfile.2597 (the number will be different each time; it is the PID number of the running dosemu process).
These things should disappear when dosemu terminates. If they don’t, you should clean up the ~/.dosemu directory by hand.
6. The dosemu utilities
dosemu comes with a lot of utilities like emufs.sys, lredir, emumouse, etc. With the Debian/freedos and RPM/freedos install methods, they are already available to you. If you use MS-DOS or Windows DOS, you should make them available by means of a symbolic link. When in ~/dos (in Linux!), type
ln -s /usr/lib/dosemu/commands dosemu (for Debian)
ln -s /usr/share/dosemu/commands dosemu (for RPM)
Now there is what appears to be (to DOS) a directory dosemu of your ‘pseudo C: drive’, containing the utilities. You can add it to the path in autoexec.bat (add c:\dosemu; to the end of the PATH line). This way you won’t have to specify the full path name when calling a dosemu utility.
You do not need them for your first experiments with dosemu; I think it is better not to touch them at first (‘keep it simple’ principle). The only one which you might use often is exitemu, but it is quicker to close a dosemu session by pressing Control-Alt-PgDn.
The utility lredir can be used to ‘mount’ a Linux directory under DOS. It then gets a DOS ‘drive letter’ (such as D:). The command is:
lredir [driveletter]: linux\fs[directory]
This is useful e.g. to make the CDROM available under DOS. I put the following lredir command in my DOS autoexec.bat:
lredir d: linux\fs/cdrom
There is now a D: drive under DOS, which is the CDROM if a CDROM has been mounted (in Linux) at the /cdrom mount point. If no CDROM is mounted, D: is just empty (and non-writable).
7. What works and what doesn’t
- Text. The text display (under X) presents a nostalgic DOS appearance, by means of an old-style PC-like font complete with box characters.
- Graphics (VGA/EGA/CGA). The X window in which DOS runs is not just a text window. It can also display graphics. See screenshots below. Amazingly, the window, with its contents, can be made as big or as small as you like by dragging a corner (only when displaying graphics in version 1.2.0; in 1.3.0, you can do it with the text screen also).
- Printing. It worked straight out of the box; I did not have to change anything. Printing worked fine with all DOS programs I tried, including redirecting to LPT1. Of course I have a working Linux print setup (lprng, magicfilter). dosemu prints by using the standard lpr command. NOTE: The PrtSc key also works.
NOTE: If you use CUPS, and printing does not work, you may need to change the print command to lpr -l (according to a note in dosemu.conf). Edit /etc/dosemu/dosemu.conf, or add a line in ~/.dosemurc:
$_printer_command = "lpr -l"
NOTE: ‘out of the box’, you will print to your default Linux printer (lp), which is probably set up to use the Latin-1 character set, not the PC-DOS character set used in DOS. Often this does not matter: programs like Wordstar and Wordperfect send the correct initialisation codes to the printer anyway. But when text is copied directly to the printer, there will be problems with non-ASCII characters (accents and box characters).To solve this, you can define a new printer in /etc/printcap called, e.g., ‘dos’, with an ‘input filter’ (if) containing proper initialisation codes for printing the PC-DOS character set. E.g. in the case of Laserjets and such, the filter should specify \e(10U (PCL code for ‘PC-8 Character Set’) instead of \e(0N (‘Latin-1 Character Set’). Then specify the dos printer in ~/.dosemurc (or, if you like, /etc/dosemu/dosemu.conf):
$_printer = "dos"
I you do this, PrtSc in dosemu will produce screen prints with proper ‘box draw’ characters.
- The (three-inch) floppy drive. I had an ‘A:’ drive straight out of the box, available for reading and writing. I could probably use it to install programs from floppies, but haven’t tried this (I copied the programs from existing DOS partitions on my machines).
NOTE: to get read and write access to the floppy, as user, in dosemu, you must first have read and write access in Linux. This is probably distribution-dependent. E.g. in Debian, the user has to be a member of the floppy group. Root can make user john a member of the floppy group by calling
adduser john floppy
- Sound from the PC speaker. That is, it works (in my case) with the self-compiled version; with the Debian version, it works only when I am root on the console. No idea why, will investigate.
- Sound from the sound card. dosemu produces sounds (like speech and shooting sounds) in many games. Music is a different matter. See below.
- The mouse. dosemu itself can interpret ‘high level’ mouse commands (0x33 interrupts), without using a mouse.sys or mouse.com (as many older versions of MS-DOS needed).
- CDROM access as drive D: (see previous section).
What doesn’t (completely) work:
- Activating Borland Sidekick. Borland Sidekick can be installed if you use a ‘real’ DOS (not freedos), but since version 1.5 of dosemu it cannot be activated anymore. The reason is obscure, because some people report that Sidekick (on modern hardware) also does not work under ‘bare’ DOS. In the past it was a hugely popular program and it certainly did work.
- On X, the VGA emulation is not 100% complete. It is very good, but there are a few games which do not display entirely correctly. One example is Captain Comic. It works 100 % correctly on the console, but this requires being root. When you are root on the console, the actual VGA hardware (not an emulation) is used.
- Music. Sound is not yet completely developed in dosemu. With some contortions, it is possible to get midi music (but not FM music) out of dosemu. Try
- File attributes. The MS-DOS attrib command does not work. This is, perhaps, to be expected, because the filesystem isn’t really MS-DOS. So for instance io.sys and msdos.sys, which are supposed to be ‘hidden system files’, always show up in directory listings. Other things which are specific to the MS-DOS file system (like undeleting files) also do not work.
- The console. On the console, the command to start your DOS environment is dosemu (as opposed to xdosemu which is used in X). But it doesn’t work 100 %. It is useful to specify in ~/.dosemurc:
$_term_char_set = "ibm" $_rawkeyboard = (1)
This gives you display of IBM ‘box characters’ on the console in text-mode programs. You won’t get display of IBM ‘control characters’ like ↑ (up arrow), ↓ (down arrow), or the ‘card suits’ (♠ ♥ ♦ ♣). Display of the ‘control characters’ on the console requires being root.
Explanation: the console, when you are user, is just a terminal, to which characters are sent in a stream, one after another. Sending ‘control characters’ to a terminal does not result in characters being displayed, but in cursor movements and beeps. So if a DOS program wants to display such characters, dosemu translates them into something harmless (like ↑ into ⌠).
However, when you are root, the console does not act like a terminal, but like a random-access video memory, just as in an old-style DOS PC. Any character can be placed anywhere, in any order. DOS programs have direct access, without translation.
To experiment with using dosemu as root, you have to prepare a pseudo-C: drive for the root user first. You could, for instance, make a symbolic link to your own ~/dos directory.
Likewise, graphics on the console is out of the question, unless you are root. The rule is: root can do a lot more things on the console than an ordinary user, but being root on the console in dosemu is risky. Don’t do that. Or do it, experiment, but be prepared to encounter problems.
NOTE: If you get stuck somehow, go to another virtual terminal by means of CTRL-ALT-Fn, become root, and kill the dosemu.bin process. Then get back to X by means of CTRL-ALT-F7. But still, as a matter of principle, you should avoid being root.
dosemu still is a work in progress. Discussion of dosemu’s progress takes place on the mailing list email@example.com (archived here). Try it; the people there are very helpful.
8. Screenshots (dosemu on X)
- Z-Scope (VGA fractals program, available here)
- IBM Fixed Disk Organizer. Pretty much the ‘standard’ menu program in the heyday of MS-DOS. The program has the ‘millennium bug’, but that can be fixed using this patch; the screenshot shows it displaying a 2002 date correctly.
- Sokoban (CGA game, anno 1984)
- Wordstar 4, Minimon, Sidekick Calendar and Help, showing dosemu’s ability to run TSR programs. Note that Borland Sidekick (version 1.56, 1985) did not have a ‘millennium’ problem.
- The ‘Dialing Directory’ of Telix (by far the best serial communications program in the DOS/BBS era) displaying a list of Bulletin Board Systems in Tokyo (where I lived until 1995), using my own KDplus system which provided Japanese display and keyboard input on ‘IBM compatible’ PC’s. I expect that other systems for Japanese I/O on ‘IBM compatibles’, especially ‘DOS/V’, can also be made to work under dosemu.