操作系统真象还原 读书笔记01--环境配置

selph
selph
发布于 2021-01-08 / 1375 阅读
1
0

操作系统真象还原 读书笔记01--环境配置

环境

开发环境:

  • VMWare + Ubuntu 20.10

软件:

  • GCC,C语言编译器
  • NASM,汇编器
  • Bochs,开发操作系统用的虚拟机

为什么选择使用Linux环境进行开发学习?

  • 书上就这么教的,初学,怕遇到奇奇怪怪的环境问题,就按书上的走了
  • 我也算是半个 Linux 爱好者(以前拿Linux作为过主力机一段时间)

软件安装

GCC:

$ sudo apt install gcc

NASM:

$ sudo apt install nasm

Bochs:

$ sudo apt install bochs*

书上是通过源码安装,源码安装这一块我不熟悉,为了以防后面出些什么乱七八糟的问题,这里就直接包管理器一键安装了

配置 Boochs

安装完以后,切到/usr/share/bochs目录,将配置文件/etc/bochs-init/bochsrc复制过来

编辑bochsrc,将boot改为disk

命令行键入bochs -f boshsrc启动bochs虚拟机

如果出现PANIC报错,就去把配置文件相关的行注释掉

反复进行,直到没报错为止

当命令行出现<bochs:1>,且屏幕弹出窗口Bochs时,则表示虚拟机成功运行

Bochs 创建硬盘

键入命令bximage即可通过提示进行创建硬盘,基本上一路默认就行,然后大小可以设置稍微大一点,名字自己改一下,这里附上我自己的选择:

selph@selph-bochs:~/文档/OS_Study$ bximage
========================================================================
                                bximage
  Disk Image Creation / Conversion / Resize and Commit Tool for Bochs
         $Id: bximage.cc 13481 2018-03-30 21:04:04Z vruppert $
========================================================================

1. Create new floppy or hard disk image
2. Convert hard disk image to other format (mode)
3. Resize hard disk image
4. Commit 'undoable' redolog to base image
5. Disk image info

0. Quit

Please choose one [0] 1

Create image

Do you want to create a floppy disk image or a hard disk image?
Please type hd or fd. [hd] hd

What kind of image should I create?
Please type flat, sparse, growing, vpc or vmware4. [flat] flat

Choose the size of hard disk sectors.
Please type 512, 1024 or 4096. [512]    

Enter the hard disk size in megabytes, between 10 and 8257535
[10] 60

What should be the name of the image?
[c.img] hd60M.img

Creating hard disk image 'hd60M.img' with CHS=121/16/63 (sector size = 512)

The following line should appear in your bochsrc:
  ata0-master: type=disk, path="hd60M.img", mode=flat

将这里最后这行复制到配置文件中:

  ata0-master: type=disk, path="hd60M.img", mode=flat

到这里Bochs最基本的配置就完成了,现在启动Bochs会提示:

Boot Failed:not a bootable disk

这是读取到硬盘了,但是发现硬盘中没有引导程序,导致系统不能启动

这就是下一篇要讲的内容了

参考资料


评论