Bianbu Desktop 2.0 ROOTFS制作
环 境要求
宿主机推荐 Ubuntu 20.04/22.04,且安装了 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"
export VERSION="v2.0.2" -
配置 bianbu.sources
cat <<EOF | tee $TARGET_ROOTFS/etc/apt/sources.list.d/bianbu.sources
Types: deb
URIs: https://$REPO/
Suites: noble/snapshots/$VERSION noble-security/snapshots/$VERSION noble-porting/snapshots/$VERSION noble-customization/snapshots/$VERSION
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/bianbu-archive-keyring.gpg
EOF
配置 DNS
echo "nameserver 8.8.8.8" >$TARGET_ROOTFS/etc/resolv.conf
安装硬件相关的包
chroot $TARGET_ROOTFS /bin/bash -c "apt-get update"
chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades upgrade"
chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades install initramfs-tools"
chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades install bianbu-esos img-gpu-powervr k1x-vpu-firmware k1x-cam spacemit-uart-bt spacemit-modules-usrload opensbi-spacemit u-boot-spacemit linux-image-6.6.36"
安装元包
不同变体有不同的元包,
- Minimal:bianbu-minimal
- Dekstop:bianbu-desktop bianbu-desktop-zh bianbu-desktop-en bianbu-desktop-minimal-en bianbu-standard bianbu-development
- NAS:bianbu-nas
minimal:
chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades install bianbu-minimal"
Desktop:需要先安装 minimal 元包
chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades install bianbu-minimal"
chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades install bianbu-desktop bianbu-desktop-zh bianbu-desktop-en bianbu-desktop-minimal-en bianbu-standard bianbu-development"
NAS:
chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades install bianbu-nas"
通用配置
配置地区
chroot $TARGET_ROOTFS /bin/bash -c "apt-get -y install locales"
chroot $TARGET_ROOTFS /bin/bash -c "echo \"locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, zh_CN.UTF-8 UTF-8\" | debconf-set-selections"
chroot $TARGET_ROOTFS /bin/bash -c "echo \"locales locales/default_environment_locale select zh_CN.UTF-8\" | debconf-set-selections"
chroot $TARGET_ROOTFS /bin/bash -c "sed -i 's/^# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen"
chroot $TARGET_ROOTFS /bin/bash -c "dpkg-reconfigure --frontend=noninteractive locales"
配置时区
chroot $TARGET_ROOTFS /bin/bash -c "echo 'tzdata tzdata/Areas select Asia' | debconf-set-selections"
chroot $TARGET_ROOTFS /bin/bash -c "echo 'tzdata tzdata/Zones/Asia select Shanghai' | debconf-set-selections"
chroot $TARGET_ROOTFS /bin/bash -c "rm /etc/timezone"
chroot $TARGET_ROOTFS /bin/bash -c "rm /etc/localtime"
chroot $TARGET_ROOTFS /bin/bash -c "dpkg-reconfigure --frontend=noninteractive tzdata"
配置时间服务器
sed -i 's/^#NTP=.*/NTP=ntp.aliyun.com/' $TARGET_ROOTFS/etc/systemd/timesyncd.conf
配置密码
chroot $TARGET_ROOTFS /bin/bash -c "echo root:bianbu | chpasswd"
配置网络
如果仅安装了 minimal(bianbu-minimal)元包,则需要使用 netplan 配置网络,
cat <<EOF | tee $TARGET_ROOTFS/etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
end0:
dhcp4: true
EOF
chroot $TARGET_ROOTFS /bin/bash -c "chmod 600 /etc/netplan/01-netcfg.yaml"