我的rCore——第零章 环境配置
本人参加了2025 春夏季开源操作系统训练营
环境:window11+WSL2+docker+qemu,避免复杂的环境配置。
wsl2安装
略。实验主要支持 Ubuntu18.04/20.04 操作系统,由于本人wsl2为Ubuntu24.04,且不想再用虚拟机,于是采用wsl2+docker。
docker desktop安装
略
克隆代码仓库
git clone https://github.com/LearningOS/2025s-rcore-joki-sr
cd ./2025s-rcore-joki-sr
git checkout ch1 #切换到此处是因为main分支没有dockerfile无法进行后续的构建
build docker 构建并生成一个 Docker 镜像(image)
make build_docker #看Makefile文件可以看到
等待的过程可能会发生问题,比如
问题
...
Dockerfile:1
--------------------
1 | >>> # syntax=docker/dockerfile:1
2 | # This Dockerfile is adapted from https://github.com/LearningOS/rCore-Tutorial-v3/blob/main/Dockerfile
3 | # with the following major updates:
--------------------
ERROR: failed to solve: failed to do request: Head "https://registry.docker-cn.com/v2/docker/dockerfile/manifests/1?ns=docker.io": EOF
make: *** [Makefile:8: build_docker] Error 1
解决方式:
直接移除当前目录下 Dockerfile 的第一行:# syntax=docker/dockerfile:1
是语法声明,这行不是必须的,可以尝试删除它
网络问题
Dockerfile:13
--------------------
12 | ARG DEBIAN_FRONTEND=noninteractive
13 | >>> RUN apt-get update && \
14 | >>> apt-get install -y \
15 | >>> curl \
16 | >>> git \
17 | >>> python3 \
18 | >>> wget
19 |
--------------------
ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y curl git python3 wget" did not complete successfully: exit code: 100
make: *** [Makefile:8: build_docker] Error 1
apt-get update 或 apt-get install 命令失败了,退出代码是 100。这通常是由于网络问题或 Ubuntu 软件源不可用导致的。
解决方案:更换 Ubuntu 软件源(推荐)
由于 apt-get update 失败,可能是默认的 Ubuntu 20.04 软件源(archive.ubuntu.com)访问较慢或不可用。我们可以换成国内镜像源(如阿里云、清华源等)。
修改你的 Dockerfile,在 apt-get update 之前添加换源命令:
FROM ubuntu:20.04
ARG QEMU_VERSION=7.0.0
ARG HOME=/root
# 添加此处 0.1. 更换为阿里云 Ubuntu 20.04 软件源
RUN sed -i 's@archive.ubuntu.com@mirrors.aliyun.com@g' /etc/apt/sources.list && \
sed -i 's@security.ubuntu.com@mirrors.aliyun.com@g' /etc/apt/sources.list
# 0.2. 安装基础工具
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y \
curl \
git \
python3 \
wget
磁盘空间不足
发现C盘爆红了qwq
Dockerfile:82
--------------------
81 | # This avoids having to wait for these steps each time using a new container.
82 | >>> RUN rustup target add riscv64gc-unknown-none-elf && \
83 | >>> cargo install cargo-binutils --vers ~0.2 && \
84 | >>> rustup component add rust-src && \
85 | >>> rustup component add llvm-tools-preview
86 |
--------------------
ERROR: failed to solve: error committing bd75tw5yc3e9qvrkfudebqpjr: write /var/lib/docker/buildkit/metadata_v2.db: read-only file system
make: *** [Makefile:8: build_docker] Error 1
启动(临时)container
make docker #进入docker环境
然后就可以在/mnt/os/目录下运行os!
退出container
exit

浙公网安备 33010602011771号