最新对底层比较感兴趣,在网上搜索,网友推荐了MIT的两门课程MIT6.S081 Operating System Engineering和MIT6.S808。准备利用闲暇的时间,系统学习一下。本篇文章主要记录MIT 6.S081实验环境的搭建。
环境搭建
官方搭建步骤
本地环境为ubuntu,安装步骤为:
sudo apt-get install qemu-system-misc=1:4.2-3ubuntu6
sudo apt-get install git build-essential gdb-multiarch gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu
出错如下:
Fetched 62.6 MB in 4min 36s (227 kB/s)
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gdk-pixbuf/libgdk-pixbuf2.0-common_2.40.0+dfsg-3ubuntu0.1_all.deb 404 Not Found [IP: 91.189.88.142 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gdk-pixbuf/libgdk-pixbuf2.0-0_2.40.0+dfsg-3ubuntu0.1_amd64.deb 404 Not Found [IP: 91.189.88.142 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gdk-pixbuf/libgdk-pixbuf2.0-bin_2.40.0+dfsg-3ubuntu0.1_amd64.deb 404 Not Found [IP: 91.189.88.142 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/q/qemu/qemu-block-extra_4.2-3ubuntu6.12_amd64.deb 404 Not Found [IP: 91.189.88.142 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/q/qemu/qemu-system-common_4.2-3ubuntu6.12_amd64.deb 404 Not Found [IP: 91.189.88.142 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/q/qemu/qemu-system-data_4.2-3ubuntu6.12_all.deb 404 Not Found [IP: 91.189.88.142 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/q/qemu/qemu-utils_4.2-3ubuntu6.12_amd64.deb 404 Not Found [IP: 91.189.88.142 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
该问题是镜像源的问题,更新镜像源:
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
vim /etc/apt/sources.list
将镜像替换为aliyun镜像
:%s/archive.ubuntu.com/mirrors.aliyun.com/g
更新源之后再次安装即可。
sudo apt update
sudo apt upgrade
测试是否安装成功
测试riscv64-unknown-elf-gcc
是否安装成功。
$ riscv64-unknown-elf-gcc --version
$ sudo apt install gcc-riscv64-unknown-elf
riscv64-unknown-elf-gcc () 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
测试qemu-system-risv64
是否安装成功。
$ qemu-system-risv64 --version
QEMU emulator version 4.2.0 (Debian 1:4.2-3ubuntu6)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
编译qemu
git clone git://g.csail.mit.edu/xv6-labs-2020
cd xv6-labs-2020
git checkout util
出现如下界面说明编译成功:
至此,环境编译成功,可以跟着课程做实验了。
退出系统 Ctrl-a x.