大概在 2008 年 5 月份开始阅读赵博的《Linux内核彻底注释》,并在当时 兰大开源社区 的博客系统上连载阅读笔记。html
每阅读完一部分就会写一份笔记,当时社区的反响仍是蛮大了,所以结识了不少技术方面的好友。linux
可是大概在 2009 年初,本身出去实习了。由于实习工做任务繁重,因此这部分阅读工做未能继续。另外,那个博客网站由于升级故障,致使数据被破坏,到现在都没法访问。ios
还好当时有作数据备份,2013 年左右在本身机器上从新把网站恢复出来,博客系统的数据总算找回来。而且已经陆续把部分重要文章整理到了现在的 泰晓科技 平台上,但愿更多的同窗受益。git
计划逐步把当时的阅读笔记整理出来并抽空阅读剩下的部分。github
这里先分享如何快速搭建一个 Linux 0.11 的实验环境,这是阅读这本书很是重要的准备工做,由于做为实践性很强的操做系统课程,实验环境是必要条件,不然没法深刻理解。docker
好了,若是想快速上手,能够直接跳到 下一节。vim
赵老师书里头介绍的是在 Redhat 环境下用 Bochs 仿真系统来跑 Linux 0.11,经过实验发现诸多问题,不断摸索,阅读计划不断推迟,由于蛮多时间浪费在实验和调试环境的打造上了,分享一下这段历史吧:目前已经成功地把linux-0.11移植到gcc 4.3.2,当时仍是作了一些工做的:微信
最终达成的效果是,能够很是方便地在当时最新的 Ubuntu 系统上学习和调试 Linux 0.11,为后续进一步研究 Linux 0.11 提供了最基础的准备。网络
废话很少说了,从 2008 年到如今,本身在 Linux 方面的学习有了必定的进步,回头再看看曾经奋斗的历程,稍微有点小小的感动。app
由于当时的博客以及档案的下载地址都已经失效,因此不少网友还时长会发邮件过来咨询。通常是直接把机器上备份的一些档案邮寄给你们。
最近也稍有在 Google 上检索 Linux 0.11,很是有幸看到有蛮多的 github 仓库备份并改进了我当时上传的代码。很是精彩的例子有:
很是感谢你们的工做,上面均可以直接在当前的 Ubuntu 环境下工做,第一份甚至都已经支持 Mac OS X ;-)
不过也还有可稍微改进的地方:
把实验须要的 rootfs 镜像直接经过压缩的方式上传到仓库
这样就能够造成一个完整的实验环境,压缩的好处是能够加快网络下载的速度;另外,为了不额外的解压工做,在 Makefile 里头,我这个脚本控固然是代劳了。
合并更多不曾发布的内容
整个实验环境目前只有 30 M,压缩成 xz 只有 18 M,很是小。
先准备个电脑,XP 已死,建议用 Ubuntu 或者 OS X,这里主要介绍 Ubuntu,OS X 看 README.md吧。
apt-get install vim cscope exuberant-ctags gcc gdb binutils qemu
git clone https://github.com/tinyclub/linux-0.11-lab.git
cd linux-0.11-lab && make
这个版本在Ubuntu 16.04.2 LTS gcc 版本 7.1.0 内核4.10.0-28下能够编译经过.亦能够到这里下载
http://cloud.189.cn/t/zeeYbqr6f6Rn(访问码:3635)
make start-hd
也可用bochs启动:
cp rootfs/hdc-0.11.img hdc-0.11.img
bochrc
############################################################### # Configuration file for Bochs ############################################################### # how much memory the emulated machine will have megs: 32 # filename of ROM images romimage: file=/opt/local/share/bochs/BIOS-bochs-latest #/opt/share/bochs/BIOS-bochs-latest vgaromimage: file=/opt/local/share/bochs/VGABIOS-lgpl-latest #/usr/share/vgabios/vgabios.bin floppya: 1_44="Image", status=inserted ata0-master: type=disk, path="hdc-0.11.img", mode=flat, cylinders=410, heads=16, spt=38 boot: c log: bochsout.txt # disable the mouse mouse: enabled=0 # enable key mapping, using US layout as default. # keyboard_mapping: enabled=1, map=/opt/local/share/bochs/keymaps/x11-pc-us.map keyboard: keymap=/opt/local/share/bochs/keymaps/x11-pc-us.map
打开一个控制台,从硬盘启动并进入 debug 模式:
make debug-hd
经过 gdb 调试:
gdb images/kernel.sym
(gdb) target remote :1234
(gdb) b main
(gdb) c
make help > Usage: make --generate a kernel floppy Image with a fs on hda1 make start -- boot the kernel in qemu make start-fd -- boot the kernel with fs in floppy make start-hd -- boot the kernel with fs in hard disk make debug -- debug the kernel in qemu & gdb at port 1234 make debug-fd -- debug the kernel with fs in floppy make debug-hd -- debug the kernel with fs in hard disk make disk -- generate a kernel Image & copy it to floppy make cscope -- genereate the cscope index databases make tags -- generate the tag file make cg -- generate callgraph of the system architecture make clean -- clean the object files make distclean -- only keep the source code files
3.8 生成函数调用关系图
make cg ls calltree/linux-0.11.jpg
生成的图片见最后。
是否是够简单便捷?
遇到任何问题欢迎参与回复互动,或者关注咱们的新浪微博/微信公众号互动:@泰晓科技。
也能够直接到赵老师的站点上参与交流和讨论:http://www.oldlinux.org/oldlinux/