Bianbu 2.1 ROOTFS制作
环境要求
宿主机推荐 Ubuntu 20.04/22.14,且安装了 docker ce 和 qemu-user-static(8.0.4,定制版,默认开启了 Vector 1.0 支持)。
docker
docker ce 安装可参考 https://docs.docker.com/engine/install/ 。
qemu
-
卸载 binfmt-support
定制版的 qemu-user-static 与 binfmt-support 有冲突,因为 binfmt-support 提供的
/etc/init.d/binfmt-support
属于传统的 SysVinit 启动脚本,而定制版的 qemu-user-static 提供的/lib/systemd/system/systemd-binfmt.service
是 systemd 服务单元文件。/etc/init.d/binfmt-support
会晚于/lib/systemd/system/systemd-binfmt.service
执行,导致覆盖 systemd 的设置。sudo apt-get purge binfmt-support
-
下载定制版的 qemu
wget https://archive.spacemit.com/qemu/qemu-user-static_8.0.4%2Bdfsg-1ubuntu3.23.10.1_amd64.deb
-
安装定制版的 qemu
sudo dpkg -i qemu-user-static_8.0.4+dfsg-1ubuntu3.23.10.1_amd64.deb
-
注册 qemu-user-static 到内核,这样整个系统范围(含容器)均可以直接执行 riscv 的二进制文件
sudo systemctl restart systemd-binfmt.service
-
验证 qemu-user-static 是否注册成功
wget https://archive.spacemit.com/qemu/rvv
chmod a+x rvv
./rvv出现以下信息表示注册成功。
helloworld
spacemit
准备基础 rootfs
-
创建工作目录
mkdir ~/bianbu-workspace
-
创建并启动容器
docker run --privileged -itd -v ~/bianbu-workspace:/mnt --name build-bianbu-rootfs harbor.spacemit.com/bianbu/bianbu:latest
-
进入容器
docker exec -it -w /mnt build-bianbu-rootfs bash
-
安装基本工具
apt-get update
apt-get -y install wget uuid-runtime -
配置环境变量,方便后续命令使用
export BASE_ROOTFS_URL=https://archive.spacemit.com/bianbu-base/bianbu-base-24.04-base-riscv64.tar.gz
export BASE_ROOTFS=$(basename "$BASE_ROOTFS_URL")
export TARGET_ROOTFS=rootfs -
下载
wget $BASE_ROOTFS_URL
-
解压到指定目录
mkdir -p $TARGET_ROOTFS && tar -zxpf $BASE_ROOTFS -C $TARGET_ROOTFS
-
挂载一些系统资源到 rootfs 中
mount -t proc /proc $TARGET_ROOTFS/proc
mount -t sysfs /sys $TARGET_ROOTFS/sys
mount -o bind /dev $TARGET_ROOTFS/dev
mount -o bind /dev/pts $TARGET_ROOTFS/dev/pts
必要配置
配置源
-
首先配置环境变量,方便后续命令使用
export REPO="archive.spacemit.com/bianbu"
-
配置 bianbu.sources
cat <<EOF | tee $TARGET_ROOTFS/etc/apt/sources.list.d/bianbu.sources
Types: deb
URIs: https://$REPO/
Suites: noble/snapshots/v2.1 noble-security/snapshots/v2.1 noble-updates/snapshots/v2.1 noble-porting/snapshots/v2.1 noble-customization/snapshots/v2.1 bianbu-v2.1-updates
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/bianbu-archive-keyring.gpg
EOF使用此源即可安装到后续的2.1.x(如2.1.1)发布的包,其存放在bianbu-v2.1-updates。
配置 DNS
echo "nameserver 8.8.8.8" >$TARGET_ROOTFS/etc/resolv.conf