使用 Bochs 进行平台仿真(1)(3)
使用 Bochs
Bochs 及其实用程序很简单,用于仿真各种不同的来宾操作系统。本示例演示了来自贝尔实验室操作系统的 Plan 9 的仿真。
安装 Bochs
首先,如果您的系统上没有 Bochs,则必须先安装 Bochs。对于我的 Ubuntu 系统来说,我使用了 apt 程序包管理器来安装必要的程序包:
$ sudo apt-get install bochs $ sudo apt-get install bochs-x
此命令安装 Bochs IA-32/64 PC 仿真器和 Bochs X-11 仿真器。
为 Plan 9 安装做准备
要在 Bochs 上仿真 Plan 9,对于您的虚拟环境来说您需要另外两个东西:包含 Plan 9 安装映像的 CD-ROM 和作为安装目标的虚拟硬盘(Virtual Hard Disk,VHD)。
首先,从贝尔实验室站点获得 Plan 9 映像,正如下面的命令行所示:
$ wget http://plan9.bell-labs.com/plan9/download/plan9.iso.bz2 $ bunzip2 plan9.iso.bz2
Plan9 映像是可以使用 ISO 9660 格式解译的 ISO 格式文件(如同 CD-ROM 驱动器仿真,很快会讲到)。
下一步是创建您的 VHD。请记住这将是主机操作系统中的一个文件。Bochs 提供特殊的实用程序来创建这个称为 bximage 的文件。Bximage 实用程序是交互式的,允许您为如何创建并管理文件而指定一些选项。清单 1 提供会话来创建 VHD。在调用 bximage 之后,您可以指定您想创建硬盘映像(而不是软盘映像)。虽然 Bochs 可以支持许多映像类型,但是对于性能来说,则要求平面映像,这是因为运行时动态增长是没有必要的。对于 Plan 9 安装来说,其操作系统需要大量的空间,因此根据硬盘文件的名称(c.img)指定 700MB 的磁盘。
清单 1. 使用 bximage 为 Bochs 创建 VHD 映像
$ bximage ======================================================================== bximage Disk Image Creation Tool for Bochs $Id: bximage.c,v 1.34 2009/04/14 09:45:22 sshwarts Exp $ ======================================================================== Do you want to create a floppy disk image or a hard disk image? Please type hd or fd. [hd] What kind of image should I create? Please type flat, sparse or growing. [flat] Enter the hard disk size in megabytes, between 1 and 129023 [10] 400 I will create a 'flat' hard disk image with cyl=1422 heads=16 sectors per track=63 total sectors=1433376 total size=699.89 megabytes What should I name the image? [c.img] Writing: [] Done. I wrote 314302464 bytes to c.img. The following line should appear in your bochsrc: ata0-master: type=disk, path="c.img", mode=flat, cylinders=1422, heads=16, spt=63 $ ls -la c.img -rw-r--r-- 1 mtj mtj 733888512 2010-12-19 14:30 c.img $
评论暂时关闭