{"id":5632,"date":"2024-06-13T03:00:00","date_gmt":"2024-06-13T07:00:00","guid":{"rendered":"https:\/\/www.both.org\/?p=5632"},"modified":"2024-06-10T15:45:00","modified_gmt":"2024-06-10T19:45:00","slug":"how-to-run-dos-apps-on-linux","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=5632","title":{"rendered":"How to run DOS apps on Linux"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"5632\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><\/div>\n<p>The classic DOS operating system sported an expansive variety of great applications and games. If you are of a certain age like me, you probably remember some of the classics like WordPerfect, PC-Write, WordStar, Lotus 1-2-3, As-Easy-As, Quattro Pro, and games like DOOM, Commander Keen, and Jill of the Jungle.<\/p>\n\n\n\n<p>There are many reasons to run an old DOS application in 2024. I have a few favorites that I like to use; for example, I find that the As-Easy-As spreadsheet on DOS does pretty much everything that a \u201cmodern\u201d spreadsheet can do, even if it does things a little differently (like conditional formatting). I also like to go back and play some of my favorite DOS games &#8211; just because they are old doesn\u2019t mean they aren\u2019t fun to play.<\/p>\n\n\n\n<p>You don\u2019t need to dual-boot your computer to run these classic DOS programs. Instead, you can run them from inside Linux using a <em>PC emulator<\/em> and <a href=\"https:\/\/www.freedos.org\/\">FreeDOS<\/a>.<\/p>\n\n\n\n<p>FreeDOS is a complete, free, open source, DOS-compatible operating system that you can use to run DOS applications and games. Any DOS program that ran on MS-DOS should also run on FreeDOS. Here are a few steps to set up FreeDOS with QEMU on Linux:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"create-a-virtual-disk\">1. Create a virtual disk<\/h2>\n\n\n\n<p>You\u2019ll need somewhere to install FreeDOS inside QEMU, and that means you\u2019ll need to create a <em>virtual<\/em> hard drive. In DOS, drives are named as letters: \u201cA\u201d and \u201cB\u201d are always reserved as floppy drives, \u201cC\u201d is the first partition on the first hard drive connected to the first drive controller, and so on.<\/p>\n\n\n\n<p>Under QEMU, virtual drives are just \u201cimage\u201d files. To create an image file for a virtual hard drive, run this <code>qemu-img<\/code> command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ qemu-img create -f vmdk dos.vmdk 200M\nFormatting 'dos.vmdk', fmt=vmdk size=209715200 compat6=off hwversion=undefined<\/code><\/pre>\n\n\n\n<p>This uses the VMDK disk image format, which is supported by a variety of virtual machine systems like QEMU, VMWare, and VirtualBox.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"install-freedos-on-the-virtual-disk\">2. Install FreeDOS on the virtual disk<\/h2>\n\n\n\n<p>Unlike other graphical virtual machines like VirtualBox, QEMU requires that you \u201cbuild\u201d or configure the virtual machine using the command line. These are the options I tend to use to run FreeDOS in QEMU. See the <em>qemu(1)<\/em> man page for full details on the command line.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Option<\/th><th>What it means<\/th><\/tr><\/thead><tbody><tr><td><code>qemu-system-i386<\/code><\/td><td>QEMU can emulate several different machine systems, but to boot DOS, we\u2019ll need an i386 Intel system<\/td><\/tr><tr><td><code>-enable-kvm<\/code><\/td><td>Use the Linux kernel KVM support to make QEMU run at almost native speeds<\/td><\/tr><tr><td><code>-m 32<\/code><\/td><td>Defines the virtual machine with 32 MB of memory<\/td><\/tr><tr><td><code>-hda<\/code> <em>image<\/em><\/td><td>Sets the disk image for the first hard drive<\/td><\/tr><tr><td><code>-cdrom<\/code> <em>image<\/em><\/td><td>Sets the CD ISO image for the CD-ROM drive<\/td><\/tr><tr><td><code>-boot order=<\/code><\/td><td>Tells QEMU to boot from different media (<code>c<\/code> for the hard drive, <code>d<\/code> for the CD-ROM drive)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Download the FreeDOS 1.3 install LiveCD from the <a href=\"https:\/\/www.freedos.org\/download\/\">FreeDOS website<\/a> and extract the zip file to get the CD ISO image, then boot QEMU with this command line to start the install process:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ qemu-system-i386 -enable-kvm -m 32 -hda dos.vmdk -cdrom FD13LIVE.iso -boot order=d<\/code><\/pre>\n\n\n\n<p>For full instructions for how to install FreeDOS 1.3 under QEMU, see my other article about <a href=\"https:\/\/www.both.org\/?p=5612\">Running FreeDOS on Linux<\/a>.<\/p>\n\n\n\n<p>Once you have installed FreeDOS on the virtual disk, use the FreeDOS <code>shutdown<\/code> command to halt the FreeDOS instance and exit QEMU.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"copy-over-your-dos-applications\">3. Copy over your DOS applications<\/h2>\n\n\n\n<p>Next, you\u2019ll need to copy and DOS applications or files that you want to use into the virtual disk, so you can use them under FreeDOS. The <code>guestmount<\/code> command makes this really easy. If you don\u2019t have the <code>guestmount<\/code> command on your system, you\u2019ll need to first install the <strong>libguestfs<\/strong> package using your package manager. On Fedora Linux or other systems that use DNF, you can type:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo dnf install libguestfs<\/code><\/pre>\n\n\n\n<p>The <code>guestmount<\/code> command can access a variety of virtual disk images, including QCOW2, IMG, VMDK, and others. The command line requires the disk image you want to access using the <code>-a<\/code> option, the partition you want to mount using the <code>-m<\/code> option, and the directory where you want to access the data. Like other DOS systems of the era, FreeDOS usually makes <em>one<\/em> partition on the disk, which <code>guestmount<\/code> will address as <code>\/dev\/sda1<\/code>.<\/p>\n\n\n\n<p>Let\u2019s say you wanted to access the <code>dos.vmdk<\/code> virtual disk image from a directory called <code>dos<\/code>. You can type these commands to first create the new directory then \u201cmount\u201d the partition:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ mkdir dos\n$ guestmount -a dos.vmdk -m \/dev\/sda1 dos\n$ ls dos\nCOMMAND.COM  FDAUTO.BAT  FDCONFIG.SYS  FREEDOS  KERNEL.SYS<\/code><\/pre>\n\n\n\n<p>You can find many DOS applications and games as zip files. The <em>shareware<\/em> model was quite popular on DOS; shareware meant you could download a DOS program or game, and use it for a limited time before deciding to buy it. You could also share the program with others (which is why they called it \u201cshareware\u201d).<\/p>\n\n\n\n<p>I\u2019ve downloaded a copy of Commander Keen, a popular shareware game. Once I\u2019ve used <code>guestmount<\/code> to make my virtual disk accessible as a directory, I can just copy the Commander Keen installer using <code>cp<\/code> or my graphical file manager. Or in this case, I\u2019ll save a step and just unzip the Commander Keen installer into a new <code>TEMP<\/code> directory on my FreeDOS virtual disk:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ unzip 1keen.zip -d dos\/TEMP\nArchive:  1keen.zip\n  inflating: dos\/TEMP\/INSTALL.EXE    \n  inflating: dos\/TEMP\/CK1SW131.SHR   \n  inflating: dos\/TEMP\/FILE_ID.DIZ<\/code><\/pre>\n\n\n\n<p>Then use the <code>guestunmount<\/code> command to unmount the virtual disk from the <code>dos<\/code> directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ guestunmount dos<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"boot-freedos-from-the-virtual-disk\">4. Boot FreeDOS from the virtual disk<\/h2>\n\n\n\n<p>Now you\u2019re ready to use your favorite DOS applications and games, right from Linux, without having to dual-boot your system into DOS. From Linux, run QEMU with this command line. It\u2019s basically the same command line as before, but uses <code>order=c<\/code> to tell QEMU to boot from the virtual disk instead of the LiveCD:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ qemu-system-i386 -enable-kvm -m 32 -hda dos.vmdk -cdrom FD13LIVE.iso -boot order=c<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"427\" src=\"http:\/\/www.both.org\/wp-content\/uploads\/2024\/06\/freedos-13.png\" alt=\"screenshot of FreeDOS 1.3 booting on QEMU\" class=\"wp-image-5613\"\/><figcaption class=\"wp-element-caption\">FreeDOS 1.3 booting on QEMU<\/figcaption><\/figure>\n\n\n\n<p>You can run any DOS application on FreeDOS the same way you would run DOS programs on MS-DOS. By its nature, FreeDOS (like any DOS) is a command line operating system, so you\u2019ll type commands like <code>CD<\/code> to change to a new directory and <code>DIR<\/code> to list the contents of a directory. For example, use <code>CD<\/code> and <code>DIR<\/code> to navigate to the <code>TEMP<\/code> directory, and find the Commander Keen installer:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"461\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/06\/dir-keen.png\" alt=\"\" class=\"wp-image-5633\"\/><\/figure>\n\n\n\n<p>Run any DOS program by typing its name. DOS programs always have an <code>EXE<\/code> or <code>COM<\/code> extension; \u201cbatch\u201d files have a <code>BAT<\/code> extension. For example, to run the installer for Commander Keen, just type <code>INSTALL<\/code>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"461\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/06\/install-keen.png\" alt=\"\" class=\"wp-image-5634\"\/><\/figure>\n\n\n\n<p>And once you\u2019ve installed the game, you can use <code>CD<\/code> to change the working directory to wherever you installed the game, and run it there:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"650\" height=\"461\" src=\"https:\/\/www.both.org\/wp-content\/uploads\/2024\/06\/playing-keen.png\" alt=\"\" class=\"wp-image-5635\"\/><\/figure>\n\n\n\n<p>Again, to exit FreeDOS and shut down QEMU, use the <code>shutdown<\/code> command at the FreeDOS command line prompt.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"supporting-sound\">Supporting sound<\/h2>\n\n\n\n<p>Most DOS applications will work just fine using the command line shown above. However, DOS games will usually expect to use a sound card like the SoundBlaster 16 for digital sounds, AdLib for digital music, or the PC speaker for monotonal beeps. You will need to modify the QEMU command line to add these devices.<\/p>\n\n\n\n<p>The QEMU team has changed how users must configure sound from the command line. It used to be as simple as <code>-device sb16<\/code> to add SoundBlaster 16 support, and <code>-device adlib<\/code> for AdLib digital music. In more recent versions, QEMU has dropped default support for the PC speaker. Instead, you now need to redirect sound devices to use your Linux system\u2019s sound system.<\/p>\n\n\n\n<p>My Fedora Linux system uses PulseAudio, so I need to add the <code>-audiodev pa,id=snd<\/code> option to configure an audio device using the PulseAudio back-end, and naming that connection <code>snd<\/code>. You can use another ID name if you like. With that sound connection, I can add PC speaker, SoundBlaster 16, and AdLib devices using these options to QEMU:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>-machine pcspk-audiodev=snd -device sb16,audiodev=snd -device adlib,audiodev=snd<\/code><\/pre>\n\n\n\n<p>The updated QEMU command line is quite long, but works great to support sound in classic DOS games:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ qemu-system-i386 -enable-kvm -m 32 -audiodev pa,id=snd -machine pcspk-audiodev=snd -device sb16,audiodev=snd -device adlib,audiodev=snd -hda dos.vmdk -cdrom FD13LIVE.iso -boot order=c<\/code><\/pre>\n\n\n\n<p>But I don\u2019t type that all the time. I saved that long command line in a script called <code>freedos<\/code> so whenever I want to run DOS programs, I just type <code>freedos<\/code> and it runs QEMU with all the options I need.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"classic-dos-games-and-applications\">Classic DOS games and applications<\/h2>\n\n\n\n<p>QEMU and FreeDOS make it easy to run old DOS programs under Linux. Once you\u2019ve set up QEMU as the virtual machine emulator and installed FreeDOS, you should be all set to run your favorite classic DOS programs from Linux.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With QEMU and FreeDOS, you can run your favorite DOS applications and games.<\/p>\n","protected":false},"author":33,"featured_media":2803,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[340,5],"tags":[267,91],"class_list":["post-5632","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-freedos","category-linux","tag-freedos","tag-linux"],"modified_by":"David Both","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/5632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5632"}],"version-history":[{"count":2,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/5632\/revisions"}],"predecessor-version":[{"id":5637,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/5632\/revisions\/5637"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/2803"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}