在树莓派上运行 DOS 系统
树莓派 DOS

> 
> 不同的 CPU 架构意味着在树莓派上运行 DOS 并非唾手可得，但其实也没多麻烦。
> 
> 
> 


![](/data/attachment/album/201804/14/222850qvyvayt4dvnnndrz.jpg)


[FreeDOS](http://www.freedos.org/) 对大家来说也许并不陌生。它是一个完整、免费并且对 DOS 兼容良好的操作系统，它可以运行一些比较老旧的 DOS 游戏或者商用软件，也可以开发嵌入式的应用。只要在 MS-DOS 上能够运行的程序，在 FreeDOS 上都可以运行。


作为 FreeDOS 的发起者和项目协调人员，很多用户会把我作为内行人士进行发问。而我最常被问到的问题是：“FreeDOS 可以在树莓派上运行吗？”


这个问题并不令人意外。毕竟 Linux 在树莓派上能够很好地运行，而 FreeDOS 和 Linux 相比是一个更古老、占用资源更少的操作系统，那 FreeDOS 为啥不能树莓派上运行呢？


简单来说。由于 CPU 架构的原因，FreeDOS 并不能在树莓派中独立运行。和其它 DOS 类的系统一样，FreeDOS 需要英特尔 x86 架构 CPU 以及 BIOS 来提供基础的运行时服务。而树莓派运行在 ARM 架构的 CPU 上，与英特尔 CPU 二进制不兼容，也没有 BIOS。因此树莓派在硬件层面就不支持 FreeDOS。


不过通过 PC 模拟器还是能在树莓派上运行 FreeDOS 的，虽然这样也许稍有不足，但也不失为一个能在树莓派上运行 FreeDOS 的方法。


### DOSBox 怎么样?


有人可能会问：“为什么不用 DOSBox 呢？” DOSBox 是一个开源的跨平台 x86 模拟器，在 Linux 上也能使用，它能够为应用软件尤其是游戏软件提供了一个类 DOS 的运行环境，所以如果你只是想玩 DOS 游戏的话，DOSBox 是一个不错的选择。但在大众眼中，DOSBox 是专为 DOS 游戏而设的，而在运行一些别的 DOS 应用软件方面，DOSBox 只是表现平平。


对多数人来说，这只是个人偏好的问题，我喜欢用 FreeDOS 来运行 DOS 游戏和其它程序，完整的 DOS 系统和 DOSBox 相比能让我体验到更好的灵活性和操控性。我只用 DOSBox 来玩游戏，在其它方面还是选择完整的 FreeDOS。


### 在树莓派上安装 FreeDOS


[QEMU](https://www.qemu.org/)（Quick EMUlator）是一款能在 Linux 系统上运行 DOS 系统的开源的虚拟机软件。很多流行的 Linux 系统都自带 QEMU。QEMU 在我的树莓派上的 Raspbian 系统中也同样能够运行，下文就有一些我在树莓派 [Raspbian GNU/Linux 9 (Stretch)](https://www.raspberrypi.org/downloads/) 系统中使用 QEMU 的截图。


去年我在写了一篇关于[如何在 Linux 系统中运行 DOS 程序](/article-9014-1.html)的文章的时候就用到了 QEMU，在树莓派上使用 QEMU 来安装运行 FreeDOS 的步骤基本上和在别的基于 GNOME 的系统上没有什么太大的区别。


在 QEMU 中你需要通过添加各种组件来搭建虚拟机。先指定一个用来安装运行 DOS 的虚拟磁盘镜像，通过 `qemu-img` 命令来创建一个虚拟磁盘镜像，对于 FreeDOS 来说不需要太大的空间，所以我只创建了一个 200MB 的虚拟磁盘：



```
qemu-img create freedos.img 200M

```

和 VMware 或者 VirtualBox 这些 PC 模拟器不同，使用 QEMU 需要通过添加各种组件来搭建虚拟机，尽管有点麻烦，但是并不困难。我使用了以下这些参数来在树莓派上使用 QEMU 安装 FreeDOS 系统：



```
qemu-system-i386 -m 16 -k en-us -rtc base=localtime -soundhw sb16,adlib -device cirrus-vga -hda freedos.img -cdrom FD12CD.iso -boot order=d

```

你可以在我其它的[文章](/article-9014-1.html)中找到这些命令的完整介绍。简单来说，上面这条命令指定了一个英特尔 i386 兼容虚拟机，并且分配了 16MB 内存、一个英文输入键盘、一个基于系统时间的实时时钟、一个声卡、一个音乐卡以及一个 VGA 卡。文件 `freedos.img` 指定为第一个硬盘（`C:`），`FD12CD.iso` 镜像作为 CD-ROM （`D:`）驱动。QEMU 设定为从 `D:` 的 CD-ROM 启动。


你只需要按照提示就可以轻松安装好 FreeDOS 1.2 了。但是由于 microSD 卡在面对大量的 I/O 时速度比较慢，所以安装操作系统需要花费很长时间。


### 在树莓派上运行 FreeDOS


你的运行情况取决于使用哪一种 microSD 卡。我用的是 SanDisk Ultra 64GB microSDXC UHS-I U1A1 ，其中 U1 这种型号专用于支持 1080p 的视频录制（例如 GoPro），它的最低串行写速度能够达到 10MB/s。相比之下，V60 型号专用于 4K 视频录制，最低连续写入速度能达到 60MB/s。如果你的树莓派使用的是 V60 的 microSD 卡甚至是 V30（也能达到 30MB/s），你就能明显看到它的 I/O 性能会比我的好。


FreeDOS 安装好之后，你可以直接从 `C:` 进行启动。只需要按照下面的命令用 `-boot order=c` 来指定 QEMU 的启动顺序即可：



```
​qemu-system-i386 -m 16 -k en-us -rtc base=localtime -soundhw sb16,adlib -device cirrus-vga -hda freedos.img -cdrom FD12CD.iso -boot order=c​

```

只要树莓派的 QEMU 上安装了 FreeDOS，就不会出现明显的性能问题。例如游戏通常在每一关开始的时候会加载地图、怪物、声音等一系列的数据，尽管这些内容需要加载一段时间，但在正常玩的时候并没有出现性能不足的现象。


FreeDOS 1.2 自带了很多游戏以及其它应用软件，可以使用 `FDIMPLES` 包管理程序来安装它们。FreeDOS 1.2 里面我最喜欢的是一款叫 WING 的太空射击游戏，让人想起经典的街机游戏 Galaga（WING 就是 Wing Is Not Galaga 的递归缩写词）。


As-Easy-As 是我最喜欢的一个 DOS 应用程序，作为 20 世纪八九十年代流行的电子表格程序，它和当时的 Lotus 1-2-3 以及现在的 Microsoft Excel、LibreOffice Calc 一样具有强大的威力。As-Easy-As 和 Lotus 1-2-3 都将数据保存为 WKS 文件，现在新版本的 Microsoft Excel 已经无法读取这种文件了，而 LibreOffice Calc 视兼容性而定有可能支持。鉴于 As-Easy-As 的初始版本是一个共享软件，TRIUS 仍然为 As-Easy-As 5.7 免费提供[激活码](http://www.triusinc.com/forums/viewtopic.php?t=10)。


我也非常喜欢 GNU Emacs 编辑器，FreeDOS 也自带了一个叫 Freemacs 的类 Emacs 的文本编辑器。它比 FreeDOS 默认的 FreeDOS Edit 编辑器更强大，也能带来 GNU Emacs 的体验。如果你也需要，可以在 FreeDOS 1.2 中通过`FDIMPLES`包管理程序来安装。


### 是的，你或许真的可以在树莓派上运行 DOS


即使树莓派在硬件上不支持 DOS，但是在模拟器的帮助下，DOS 还是能够在树莓派上运行。得益于 QEMU PC 模拟器，一些经典的 DOS 游戏和 DOS 应用程序能够运行在树莓派上。在执行磁盘 I/O ，尤其是大量密集操作（例如写入大量数据）的时候，性能可能会受到轻微的影响。当你使用 QEMU 并且在虚拟机里安装好 FreeDOS 之后，你就可以尽情享受经典的 DOS 程序了。




---


via: <https://opensource.com/article/18/3/can-you-run-dos-raspberry-pi>


作者：[Jim Hall](https://opensource.com/users/jim-hall) 译者：[HankChow](https://github.com/HankChow) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
You may be familiar with [The FreeDOS Project](http://www.freedos.org/). FreeDOS is a complete, free, DOS-compatible operating system that you can use to play classic DOS games, run legacy business software, or develop embedded PC applications. Any program that works on MS-DOS should also run on FreeDOS.

As the founder and project coordinator of the FreeDOS Project, I'm often the go-to person when users ask questions. And one question I seem to get a lot lately is: "Can you run FreeDOS on the Raspberry Pi?"

This question isn't surprising. After all, Linux runs great on the Raspberry Pi, and FreeDOS is an older operating system that requires fewer resources than Linux, so why shouldn't FreeDOS run on the Raspberry Pi.

**[Enter our Raspberry Pi week giveaway for a chance at this arcade gaming kit.]**

The simple answer is that FreeDOS cannot run on a Raspberry Pi by itself because of the CPU architecture. Like any DOS, FreeDOS requires an Intel x86 CPU and a BIOS to provide basic runtime services. But the Raspberry Pi is a completely different architecture. The Raspberry Pi runs an ARM CPU, which is not binary compatible with the Intel CPU and does not include a BIOS. So FreeDOS cannot run on the Raspberry Pi at the "bare hardware" level.

Fortunately, it's possible to run FreeDOS on the Raspberry Pi through PC emulation. Maybe that's not as cool as running FreeDOS natively, but it's a great way to run DOS applications on the Raspberry Pi.

## What about DOSBox?

Some might ask, "Why not use DOSBox instead?" DOSBox is an open source x86 emulator that runs on a variety of systems, including Linux. It is a great system that provides a DOS-like environment, mostly aimed at running games. So if you just want to run a classic DOS game, DOSBox can do that for you. But if you run want to run DOS applications, DOSBox isn't the best platform. And if you ask the DOSBox forums, they'll tell you DOSBox is really meant for games.

For most users, it's a matter of preference. It shouldn't be a surprise that I prefer to install FreeDOS to run classic DOS games and other programs. I find the full DOS experience gives me greater flexibility and control than running DOSBox. I use DOSBox for a few games, but for most things I prefer to run a full FreeDOS instead.

## Installing FreeDOS on Raspberry Pi

[QEMU](https://www.qemu.org/) (short for Quick EMUlator) is an open source virtual machine software system that can run DOS as a "guest" operating system on Linux. Most popular Linux systems include QEMU by default. QEMU is available for Raspbian, the Linux distribution I'm using on my Raspberry Pi. I took the QEMU screenshots in this article with my Raspberry Pi running [Raspbian GNU/Linux 9 (Stretch)](https://www.raspberrypi.org/downloads/).

Last year, I wrote an article about [how to run DOS programs in Linux](https://opensource.com/article/17/10/run-dos-applications-linux) using QEMU. The steps to install and run FreeDOS using QEMU are basically the same on the Raspberry Pi as they were for my GNOME-based system.

In QEMU, you need to "build" your virtual system by instructing QEMU to add each component of the virtual machine. Let's start by defining a virtual disk image that we'll use to install and run DOS. The `qemu-img`

command lets you create virtual disk images. For FreeDOS, we won't need much room, so I created my virtual disk with 200 megabytes:

`qemu-img create freedos.img 200M`


Unlike PC emulator systems like VMware or VirtualBox, you need to "build" your virtual system by instructing QEMU to add each component of the virtual machine. Although this may seem laborious, it's not that hard. I used these parameters to run QEMU to install FreeDOS on my Raspberry Pi:

```
qemu-system-i386 -m 16 -k en-us -rtc base=localtime -soundhw sb16,adlib -device cirrus-vga -hda freedos.img -cdrom FD12CD.iso -boot order=d
```


You can find the full description of that command line in my other [article](https://opensource.com/article/17/10/run-dos-applications-linux). In brief, the command line defines an Intel i386-compatible virtual machine with 16 megabytes of memory, a US/English keyboard, and a real-time clock based on my local system time. The command line also defines a classic Sound Blaster 16 sound card, Adlib digital music card, and standard Cirrus Logic VGA card. The file `freedos.img`

is defined as the first hard drive (`C:`

) and the `FD12CD.iso`

image as the CD-ROM (`D:`

) drive. QEMU is set to boot from that `D:`

CD-ROM drive.

The FreeDOS 1.2 distribution is easy to install. Just follow the prompts.

![Install FreeDos](https://opensource.com/sites/default/files/u128651/install01.png)

opensource.com

![Install FreeDos](https://opensource.com/sites/default/files/u128651/install09.png)

opensource.com

![Install FreeDos](https://opensource.com/sites/default/files/u128651/install26.png)

opensource.com

![Install FreeDos](https://opensource.com/sites/default/files/u128651/install34.png)

opensource.com

![Install FreeDos](https://opensource.com/sites/default/files/u128651/install42.png)

opensource.com

However, it takes forever to install because of the heavy disk I/O when you install the operating system, and the microSD card isn't exactly fast.


Your results may vary depending on the microSD card you use. I used a SanDisk Ultra 64GB microSDXC UHS-I U1A1 card. The U1 is designed to support 1080p video recording (such as you might use in a GoPro camera) at minimum serial write speeds of 10MB/s. By comparison, a V60 is aimed at cameras that do 4K video and has a minimum sequential write speed of 60MB/s. If your Pi has a V60 microSD card or even a V30 (30MB/s), you'll see noticeably better disk I/O performance than I did.

## Running FreeDOS on Raspberry Pi

After installing FreeDOS, you may prefer to boot directly from the virtual `C:`

drive. Modify your QEMU command line to change the boot order, using `-boot order=c`

, like this:

```
qemu-system-i386 -m 16 -k en-us -rtc base=localtime -soundhw sb16,adlib -device cirrus-vga -hda freedos.img -cdrom FD12CD.iso -boot order=c
```


Once you have installed FreeDOS in QEMU on the Raspberry Pi, you shouldn't notice any performance issues. For example, games usually load maps, sprites, sounds, and other data when you start each level. While starting a new level in a game might take a while, I didn't notice any performance lag while playing DOS games in FreeDOS on the Raspberry Pi.

The FreeDOS 1.2 distribution includes many games and other applications that might interest you. You may need to run the `FDIMPLES`

package manager program to install these extra packages. My favorite game in FreeDOS 1.2 is WING, a space-shooter game that's very reminiscent of the classic arcade game Galaga. (The name WING is a recursive acronym for Wing Is Not Galaga.)

![Installing WING](https://opensource.com/sites/default/files/u128651/installing-wing.png)

opensource.com

![Installing WING](https://opensource.com/sites/default/files/u128651/wing-dir.png)

opensource.com

![Playing WING](https://opensource.com/sites/default/files/u128651/wing.png)

opensource.com

One of my favorite DOS programs is the shareware As-Easy-As spreadsheet program. It was a popular spreadsheet application from the 1980s and 1990s, which does the same job Microsoft Excel and LibreOffice Calc fulfill today or that the DOS-based Lotus 1-2-3 spreadsheet did back in the day. As-Easy-As and Lotus 1-2-3 both saved data as WKS files, which newer versions of Microsoft Excel can't read, but LibreOffice Calc may still support, depending on compatibility. While the original version of As-Easy-As was shareware, TRIUS Software made the [activation code for As-Easy-As 5.7](http://www.triusinc.com/forums/viewtopic.php?t=10) available for free.

![As Easy As spreadsheet](https://opensource.com/sites/default/files/u128651/aseasy-webdata.png)

opensource.com

![As Easy As chart](https://opensource.com/sites/default/files/u128651/aseasy-webdata-chart.png)

opensource.com

I'm also quite fond of the GNU Emacs editor, and FreeDOS includes a similar Emacs-like text editor called Freemacs. If you want a more powerful editor than the default FreeDOS Edit and desire an experience like GNU Emacs, then Freemacs is for you. You can install Freemacs using the `FDIMPLES`

package manager in the FreeDOS 1.2 distribution.

![Installing Freemacs](https://opensource.com/sites/default/files/u128651/installing-freemacs.png)

opensource.com

![Freemacs](https://opensource.com/sites/default/files/u128651/freemacs.png)

opensource.com

## Yes, you can run DOS on the Raspberry Pi (sort of)

While you can't run DOS on "bare hardware" on the Raspberry Pi, it's nice to know that you can still run DOS on the Raspberry Pi via an emulator. Thanks to the QEMU PC emulator and FreeDOS, it's possible to play classic DOS games and run other DOS programs on the Raspberry Pi. Expect a slight performance hit when doing any disk I/O, especially if you're doing something intensive on the disk, like writing large amounts of data, but things will run fine after that. Once you've set up QEMU as the virtual machine emulator and installed FreeDOS, you are all set to enjoy your favorite classic DOS programs on the Raspberry Pi.

## 3 Comments