系统版本:Ubuntu 18.04.3
0 介绍
mit6.828是一门经典的操作系统课程,通过这门课程可以学习到操作系统的设计与实现。
据说会对linux开发很有帮助,作为一个即将工作的菜鸟,又不擅长基础理论的学习,我决定从这门课入手,希望能对操作系统有深入的认识和了解。
框图(没必要看,我就是想放放提升逼格):
1 安装工具包
需要安装的工具包如下:
执行如下指令:
sudo apt-get install -y build-essential libtool* libglib2.0-dev libpixman-1-dev zlib1g-dev git libfdt-dev gcc-multilib gdb python
2 安装qemu
qemu是一个与bochs和pearpc类似的模拟器,或者说是仿真器,完全的软件模拟,他能模拟很多类型的cpu。
2.1 下载
执行如下指令:
git clone https://github.com/mit-pdos/6.828-qemu.git qemu
该指令会在当前目录创建qemu文件夹,并克隆代码到本地。
2.2 编译&安装
首先进入到qemu文件夹下:
cd qemu
执行指令:
./configure --disable-werror --target-list="i386-softmmu x86_64-softmmu"
如果没有安装Python,这一步会报错:
出现报错 ERROR: Python not found. Use --python=/path/to/python
需要安装Python 2.7才能正常配置。
如果出现:
disanbling libtool due to broken toolchain support
说明没有安装到所需要的libtool,在上一节我已经把指令改成了安装所有libtool工具,应该不会再出现这个报错。
上述执行完毕没有报错,就可以执行编译安装指令:
make -j8 && make install
可能出现的三个错误如下:
- 错误1
qga/commands-posix.c: In function ‘dev_major_minor’:
qga/commands-posix.c:633:13: error: In the GNU C Library, "major" is defined
by <sys/sysmacros.h>. For historical compatibility, it is
currently defined by <sys/types.h> as well, but we plan to
remove this soon. To use "major", include <sys/sysmacros.h>
directly. If you did not intend to use a system-defined macro
"major", you should undefine it after including <sys/types.h>. [-Werror]
*devmajor = major(st.st_rdev);
^~~~~~~~~~~~~~~~~~~~~~~~~~
错误中已经给出了解决方案,在 qga/commands-posix.c文件中的 #include <sys/types.h> 下面增加#include <sys/sysmacros.h>即可。紧接着的那个错误也是这个引起的,改了就都会解决的。
- 错误2
block/blkdebug.c: In function ‘blkdebug_refresh_filename’:
block/blkdebug.c:749:31: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4086 [-Werror=format-truncation=]
"blkdebug:%s:%s",
这个不是错误,只需要把qemu文件夹下的config-host.mak文件中的-Werror去掉就好了(直接ctrl+F搜索Werror)
- 错误3
install -d -m 0755 "/usr/local/share/qemu"
install: cannot change permissions of ‘/usr/local/share/qemu’: No such file or directory
Makefile:382: recipe for target 'install-datadir' failed
make: *** [install-datadir] Error 1
这是安装时报错,主要是我没有使用管理员账户,没有成功创建文件夹。可以再执行一次sudo make install即可。
3 下载实验源码
退出qemu文件夹,下载实验源码:
git clone https://pdos.csail.mit.edu/6.828/2018/jos.git lab
出现找不到代码库,可能是源码有更新,可以尝试更改2018那个年份
参考资料
mit6.828 实验环境配置
MIT-6.828 环境搭建
配置qemu时遇到disanbling libtool due to broken toolchain support问题的解决办法
6.828 | 编译QEMU
Lab 1: Booting a PC