Setup guide for advanced users and ambitious beginners (using Ubuntu) - dosemu2/dosemu2 GitHub Wiki

Dosemu2 works correctly out of the box, and needs no customization. However, this guide may be useful for advanced users or for curious and ambitious beginners.

This page is written so that it is usable by people who have never used Linux, but have recently installed Ubuntu and want to run DOS applications. Any experienced Linux user will NOT need most of these instructions, but beginners may find them useful. Except for the first section ("Initial installation") all of these procedures are optional; you may not need to install a printer, change screen size, add drive letters, create a config.sys or autoexec.bat, etc., etc.

This procedure has been tested on Ubuntu 20.04 and (briefly) 18.04. It may not work with other Ubuntu versions, and will absolutely not work with non-Ubuntu-based distros.

Note: dosemu2 is the name of the package, but you launch it in the Linux terminal or elsewhere with the command dosemu.

Warning: These instructions apply only to a new system that does not have the original DOSEMU installed. If you use the instructions on a system with the original DOSEMU installed, you may make both the old DOSEMU and the new dosemu2 unusable.

Initial installation (the only essential steps)

All these steps are essential, and will give you a working dosemu2 system. All the remaining sections on this page are optional.

  1. Click on Activities, search for Terminal; when the Terminal icon appears, right-click on it and select Add to Favorites from the pop-up menu. You can press Esc to exit the Activities menu.

  2. Click on the Terminal icon in the sidebar and enter these commands, responding to any prompts as they appear (you will need to enter your password):

sudo add-apt-repository ppa:dosemu2/ppa
sudo apt update
sudo apt install dosemu2

  1. Click on Activities again, search for dosemu; an icon labeled DOS emulator will appear; right-click on it and select Add to Favorites from the pop-up menu.

  2. Click once on the dosemu2 icon on the sidebar; dosemu2 will open; enter the command exitemu to close it.

  3. Click on the desktop icon with your home folder to open it (or open the Nautilus file manager from the file-folder icon in the sidebar and click on the Home folder in the sidebar). Click on the options menu on the toolbar (the "hamburger" or three-line icon), and select Show Hidden Files.

  4. In the folders shown inside the Home folder, click on .dosemu (note the initial dot) to open it. The folder named drive_c is the C: drive in dosemu2. You can copy files or folders into that folder (perhaps dragging them from your Downloads folder or anywhere else).

  5. At any time, you can update dosemu2 (and all other updatable packages) to the latest version by entering this command in the Terminal:

sudo apt upgrade

Add drive letters

If you want to have more than one available drive in your system (for example, drives D: and E:), then click on the options button again, and then click on the "new folder" icon (the icon with the folder and plus sign near the top of the menu); enter the name drives to create a folder named drives at the same level as the folder named drive_c. Click on the drives folder to open it; when you are in the empty drives folder, click on the options button again, click on the "new folder" icon and create a folder named drive_d; repeat with drive_e if you want a drive E:, etc. Close the file manager.

See below for assigning a Linux directory (for example, your home folder) to a dosemu2 drive letter.

Modify dosemu2 configuration

Main dosemu2 config file is located at /etc/dosemu/dosemu.conf. It has all settings commented out (prepended with #), which means that the default values are used. You don't need to modify that file (unless you want to change some setting for all users). Just find an option in it that you want to change, and put it into ~/.dosemu/.dosemurc without a leading # and set it to any value you need.

If you created additional drive letters in the step above, then find the line (around 117) that reads

# $_hdimage = "+0 +1"

in /etc/dosemu/dosemu.conf, put it into ~/.dosemu/.dosemurc, remove leading # and change the setting value:

$_hdimage = "+0 drives/* -18 +1"

If you created two additional drives in step 8, this will cause those drives to be mounted as drives D: and E:, and will mount the three drives used internally by dosemu2 as drives X:, Y:, and Z:. You may want to experiment with the "-18" number, or you can omit it entirely if you want dosemu2 to set its internal drive letters to the ones that follow the letters created in "drives/*". (The "-nn" number tells dosemu2 how many drive letters to skip before creating the subsequent drive letters.)

You can also assign a Linux directory as a dosemu2 drive letter. For example, if you wanted to mount your Linux home directory as drive H:, use this syntax (replacing YOURUSERNAME with your user name):

$_hdimage = "+0 -4 /home/YOURUSERNAME/ +1"

This will assign drive_c as drive C:, then skip four drive letters, and assign your home folder as drive H:.

When you have finished modifying the configuration file, save and close it.

Install a printer

To install a printer in Ubuntu Linux, click Activities, search for Printers, and select Printers. When the Printers window opens, click Add a Printer. When CUPS-BRF-Printer appears, ignore it, and enter the address of a network in the field at the bottom of the dialog box (for example, http://192.168.1.99). Your printer may appear with two or more different names; choose the friendliest name and click Add.

When the printer appears in the printer list, click on the gear icon and add a check mark next to Use Printer by Default. You may want to look other options on this menu. When you are done, close the Printers window.

Replace the icon

If you don't like the default dosemu2 icon, download this file to your Downloads folder:

dosemu.xpm

Then, open the terminal and enter this command:

sudo cp -i ~/Downloads/dosemu.xpm /usr/share/dosemu/icons

You will need to log out and in again to see the new icon.

Create an autoexec.bat and config.sys

The default dosemu2 uses the fdpp (FreeDOS Plus Plus). Under fdpp you can create an equivalent of autoexec.bat and config.sys (where you can set, for example, files=255).

To create a user-level autoxec.bat, start dosemu2 and create a file named C:\USERHOOK.BAT and enter commands into it. You can create and add to the file from the dosemu2 prompt by entering commands like this

echo CD \WP51>C:\USERHOOK.BAT
echo WP>>C:\USERHOOK.BAT

Notice the two greater-than signs in the second line. When you restart dosemu2, these commands will run automatically. Of course, you can create or edit this file in a text editor, for example, by entering this command in the Terminal:

gedit ~/.dosemu/drive_c/userhook.bat

You can use the same technique to create a config.sys, by using the filename C:\USERHOOK.SYS.

Note: The autoexec.bat used by default for dosemu2 is /usr/share/dosemu/commands/fdppauto.bat. You can edit it by opening it with sudo gedit [filename] in the terminal but you shouldn't need to. The commands in C:\USERHOOK.BAT are run after the default autoexec.bat is finished. Similarly, the config.sys used by default for dosemu2 is /usr/share/dosemu/commands/fdppconf.sys, and the items in C:\USERHOOK.SYS are processed together with the commands in the default config.sys; highest-priority items (in either file) are processed before lower-priority ones.

Access non-Linux drives in a dual-boot system.

If you want dosemu2 to access (for example) an NTFS partition on a dual-boot Linux/Windows system, do the following. This is only one of many possible ways to do this, but it seems reasonably easy for beginners.

For convenience, first make certain that you have given your Windows partitions descriptive labels like "WinDrive" or anything else, and that they do not appear in Windows Explorer as "Local Disk (C:)" or something similar.

This procedure requires that you add one or more Linux commands to your .dosemurc file. In the terminal, enter:

gedit ~/.dosemu/.dosemurc

Insert a line that begins

$_unix_exec = ""

and then edit that line by adding these commands ("ls" is there for convenience; "gio" is needed for this procedure):

$_unix_exec = "/usr/bin/ls /usr/bin/gio"

Save the file; but you may want to leave it open for further editing.

In debian-based Linux, either search for the Disks command and launch it, or, from a terminal, run the command gnome-disks to open the Disks window. If gnome-disks is not installed on your system run sudo apt install gnome-disk-utility to install it (notice that the package that you install with this command has a different name from the gnome-disks command that you will run.)

In the Disks window, find the partition that you want to access from dosemu2 and write down its device name or, if you prefer, its UUID. The device name might be something like /dev/sda4 and the UUID will be a string of 16 hex digits. For convenience, keep the Disks window open when performing this procedure for the first time.

Start dosemu2 and enter this command, replacing DEVICENAME (or UUID) with the device name or UUID that you wrote down earlier.

unix gio mount -d DEVICENAME [or UUID]

In the Disks window, you should see the Linux path of the newly mounted partition. If the volume label of your Windows disk is WinDrive, you will see something like /media/YOURUSERNAME/WinDrive.

You almost certainly do not want to map your entire Windows drive to a drive letter in dosemu2, so choose a folder inside your Windows drive to map to a drive letter in dosemu2; for example, choose a folder named Transfer on your Windows drive (or you can choose a folder that contains a DOS-based application).

To do this, in dosemu2, first make a further change in your .dosemurc file. Insert a line that begins:

$_l_redir_paths = ""

and edit it to include the Linux path of your Windows disk, something like this:

$_l_redir_paths = "/media/YOURUSERNAME/WinDrive"

Save the file. Now open dosemu2, and enter a command like this, which maps drive W: in dosemu2 to the the Transfer folder in your WinDrive partition:

lredir W: /media/YOURUSERNAME/WinDrive/Transfer

When you are ready to exit dosemu2, enter this command to unmount your Windows drive:

unix gio mount -u /media/YOURUSERNAME/WinDrive

Note that this command should specify the entire drive, not the folder that you linked with lredir.

Also note that if you want to remove a mapping made via the lredir command, you can use a command like this in dosemu2:

lredir -d W:

You can automate this entire procedure in a batch file. For example, your batch file might mount a partition, lredir a folder in the partition, run a DOS application, then umount the partition.

Alternatively, if your Windows drive is already mounted in Linux, you can start dosemu2 with this command, which will mount the specified drive for the current session only, and will automatically assign to it the next available drive letter:

dosemu -d /media/YOURUSERNAME/WinDrive

A second utility program, emudrv acts like the DOS subst command but with additional features. The following command acts like subst, so you can access c:\temp with the emulated drive letter g:

emdrv g: c:\temp

The following option makes the emulated drive read-only:

emdrv -R g: c:\temp

And the following option creates an emulated CDROM from a directory:

emdrv -C g: c:\temp

Further options let you delete an emulated drive assignment, restore a previously-deleted assignment, force an assignment to a letter already assigned, and show the Linux path of the current DOS directory. Run emudrv -h for a full list of options.

Create default and application-specific desktop shortcuts

You can create a desktop shortcut for dosemu2, or application-specific desktop shortcuts. For example, if you want to create a desktop shortcut that runs dosemu2 in the same way that the icon in the sidebar runs it, enter this command in the Terminal:

cp /usr/share/applications/dosemu.desktop ~/Desktop

Right-click on the dosemu.desktop icon on your desktop and select Allow Launching.

To create an application-specific desktop shortcut, for example, to WordPerfect for DOS, enter a command like this in the Terminal:

cp /usr/share/applications/dosemu.desktop ~/Desktop/WPDOS.desktop

Right-click on the WPDOS.desktop icon on your desktop and select Allow Launching. Then right-click on the icon again and choose Open With Other Application; from the menu, choose Text Editor. When the file opens, change line 2 to read something like:

Name=WordPerfect

and change line 6 by adding -E followed by the DOS path to your application, double-escaping the backslashes (that is, use three backslashes instead of one), like this:

Exec=/usr/bin/dosemu -E c:\\\wp51\\\wp.com

If you want dosemu2 to remain open after running your application add -T after the path.

Alternatively, you can use the -K switch followed by the unix path; use $HOME instead of ~ and match the lower-case or upper-case path names in Linux, like this:

Exec=/usr/bin/dosemu -K $HOME/.dosemu/drive_c/WP51/WP.COM

Again, you can use the -T switch to make dosemu2 remain open after closing the application.

Change text screen size

At the dosemu2 command prompt, you can change the text screen size or type with these commands (using decimal numbers for video modes):

xmode -mode 80 [this sets the screen to 80x30]
xmode -mode 81 [this sets the screen to 80x43]
xmode -mode 82 [this sets the screen to 80x60]
xmode -mode 83 [this sets the screen to 132x25]
xmode -mode 84 [this sets the screen to 132x30]
xmode -mode 85 [this sets the screen to 132x43]
xmode -mode 86 [this sets the screen to 132x60]

Also, to switch back to standard VGA 80x25, enter

xmode -mode 3

and for 25-line mode mono, enter:

xmode -mode 7

For convenience, you may also want to download this mode.com file (from the old dosemu-freedos project) to your Downloads folder:

mode.com

This reports the current video mode with its hex number, and the number of lines and columns. You may use it to set some combinations of lines and columns, like this:

mode con lines=60 cols=80

For other possibilities, enter:

mode con /?

Send PCL output to PDF or printer

Many DOS applications produced PCL printer code, not the PostScript code that is mostly standard on Linux. To set up dosemu2 to send PCL printer output to either a PDF file or an actual printer, do the following in the Terminal:

sudo apt install autoconf

Download and extract the GhostPDL source code from https://ghostscript.com/download/gpdldnld.html

From the top level of the extracted files, enter these commands in the terminal:

./autogen.sh
./configure
make
sudo make install

This will install gpcl6 (and also gxps, which you don't need) in /usr/local/bin.

Again in the terminal, enter

gedit ~/.dosemu/.dosemurc

and add a line that will specify the action to perform for the output from lpt1. For example, to print from a DOS application (using a PCL driver) to your default Linux printer, add this line (all in one line, no breaks):

$_lpt1 = "/usr/local/bin/gpcl6 -dBATCH -dNOPAUSE -sDEVICE=ps2write -sOutputFile=%pipe%lpr -"

Save and close the .dosemurc file. When you print to LPT1 from your DOS application, the output will print to your default Linux printer.

If you want to create PDF files from a DOS application that uses a PCL driver, make a folder named PDF in your Home folder. Then open .dosemurc again for editing, and add this line (again, all in one line, no breaks):

$_lpt2 = "/usr/local/bin/gpcl6 -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -o $HOME/PDF/$(date +%Y-%m-%d-%H:%M:%S).pdf -"

Save and close the file. When you print to LPT2 from a DOS application that uses a PCL driver a PDF will be created in your PDF folder, with a filename based on the date and time of printing.