操作系统真象还原-bochs安装

今天读了《操作系统真象还原》这本书,写上比较幽默通俗。书中例子需要安装一个bochs系统,记录一下安装过程。参考了书中1.4,1.5两节,书中尽让有两处问题,也记录了下来。

1.3 操作系统的宿主环境

下载地址:Bochs x86 PC emulator - Browse /bochs at SourceForge.net

书中使用2.6.2版本,虽然比较老(2024年还在更新,已经是2.8版本了),但是为了和书上完全一致,我也不太熟悉这个系统,就下载了2.6.2(2013年5月的版本,已经11年过去了)

download in /media/vdc/emu

tar zxvf bochs-2.6.2.tar.gz

cd bochs-2.6.2

./configure --prefix=/media/vdc/emu/bochs --enable-debugger  --enable-disasm --enable-iodebug --enable-x86-debugger --with-x --with-x11

敲这几个选项时,顺序错了,iodebug放前面,结果configure不过,提示是否是交叉编译,需要设置host,我搜了半天,以为少了配置项:--build=i386-linux --host=i386-linux  结果不起作用. 最终按书上顺序修改后就好了,看来提示很不靠谱啊。

然后:make

提示错误gtk/gtk.h: No such file or directory,这次搜到了正确答案

安装bochs问题记录 - 知乎

yum install gtk2 gtk2-devel gtk2-devel-docs

这时再make还不行,就有删了目录,重新tar,重新执行,终于又出了错误:提示少pthread

这个书上有,修改Makefile,增加pthread链接:

vim Makefile
line 92: -lpthread
 

1.4节 配置bochs

share/doc/bochs/bochsrc-sample.txt  这是个例子,可以基于书上内容,从这个例子上改

这里有两个坑,书上是错的:

1.keyboard_mapping已经废弃了,不知道为啥还用,网上搜了,有人遇到同样问题:

Bochs出现'keyboard_mapping' is deprecated - use 'keyboard' option instead.解决方法_bochs keyboard-CSDN博客

2.下面这句不可加,因为编译是没有加:
gdbstub: enabled=1, port=1234, text_base=0, data_base=0, bss_base=0

最终的bochsrc.disk配置文件如下:

megs: 32
romimage: file=/media/vdc/emu/bochs/share/bochs/BIOS-bochs-latest
vgaromimage: file=/media/vdc/emu/bochs/share/bochs/VGABIOS-lgpl-latest
boot: disk
log: bochsout.txt
mouse: enabled=0
keyboard: keymap=/media/vdc/emu/bochs/share/bochs/keymaps/x11-pc-us.map
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
 

1.5 运行bochs

bin/bochs
bochsrc.disk

插曲:因为是debug模式,运行进去后,boch提示一个命令行,需要输入c,继续执行,才能运行。

参考了:bochs: The Open Source IA-32 Emulation Project (New Bochs Documentation)

bochs]$ bin/bximage --help
Usage: bximage [options] [filename]

Supported options:
  -fd              create floppy image
  -hd              create hard disk image
  -mode=...        image mode (hard disks only)
  -size=...        image size in megabytes
  -q               quiet mode (don't prompt for user input)
  --help           display this help and exit


bochs]$ bin/bximage -hd -mode="flat" -size=60 -q hd60M.img

========================================================================
                                bximage
                  Disk Image Creation Tool for Bochs
          $Id: bximage.c 11315 2012-08-05 18:13:38Z vruppert $
========================================================================

I will create a 'flat' hard disk image with
  cyl=121
  heads=16
  sectors per track=63
  total sectors=121968
  total size=59.55 megabytes

Writing: [] Done.

I wrote 62447616 bytes to hd60M.img.
The following line should appear in your bochsrc:
  ata0-master: type=disk, path="hd60M.img", mode=flat, cylinders=121, heads=16, spt=63
bochs]$ ls

-rw-rw-r-- 1 xxx xxx 62447616 5月   8 15:03 hd60M.img

vim bochsrc.disk
line 35: ata0-master: type=disk, path="hd60M.img", mode=flat, cylinders=121, heads=16,spt=63

bin/bochs -f bochsrc.disk

<bochs:1> c
========================================================================
Bochs is exiting with the following message:
[BIOS ] No bootable device.
========================================================================
 

  • 16
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值