构建 Debian 根镜象
构建新的 debian 镜象,最好在已经安装好的 EVB 开发板的 Linux 环境下进行。
准备环境
apt update
apt install -y mmdebstrap
生成 rootfs目录
通过 mmdebstrap 命令制作 Debian 根文件系统:
# 生成 deiban rootfs
mkdir debian_rootfs
mmdebstrap --architectures=riscv64 sid debian_rootfs \
--keyring=/etc/apt/trusted.gpg.d \
--include="debian-ports-archive-keyring,net-tools,wget,openssh-server,haveged" \
--dpkgopt='path-exclude=/usr/share/man/*' \
--dpkgopt='path-include=/usr/share/man/man[1-9]/*' \
--dpkgopt='path-exclude=/usr/share/locale/*' \
--dpkgopt='path-include=/usr/share/locale/locale.alias' \
--dpkgopt='path-exclude=/usr/share/doc/*' \
--dpkgopt='path-include=/usr/share/doc/*/copyright' \
--dpkgopt='path-include=/usr/share/doc/*/changelog.Debian.*' \
--dpkgopt='path-exclude=/usr/share/{doc,info,man,omf,help,gnome/help}/*' \
"deb http://mirrors.aliyun.com/debian-ports sid main" \
"deb http://mirrors.aliyun.com/debian-ports unreleased main" \
"deb http://mirrors.aliyun.com/thead/debian-riscv64 sid main"
# 添加 thead riscv 仓库
wget "http://mirrors.aliyun.com/thead/thead-keys/thead-repo.gpg" \
-O debian_rootfs/etc/apt/trusted.gpg.d/thead-repo.gpg
echo "" >> debian_rootfs/etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/thead/debian-riscv64 sid main" \
>> debian_rootfs/etc/apt/sources.list
# 使能 root ssh 登录
echo "PermitRootLogin yes" >> debian_rootfs/etc/ssh/sshd_config
# 删除 root 登录密码
sed -i 's/^root:x:/root::/g' debian_rootfs/etc/passwd
# 配置基础环境
echo "export LANG='en_US.UTF-8'" > debian_rootfs/etc/profile.d/base-set-env.sh
echo "export TERM=linux" >> debian_rootfs/etc/profile.d/base-set-env.sh
echo "alias ls='ls --color=auto'" >> debian_rootfs/etc/profile.d/base-set-env.sh
echo "alias ll='ls -l'" >> debian_rootfs/etc/profile.d/base-set-env.sh
# 查看文件夹大小
du -sm debian_rootfs
# 创建镜像文件
truncate -s 160M debian-rootfs.ext4
mkfs.ext4 debian-rootfs.ext4
mkdir tmp_rootfs
mount debian-rootfs.ext4 tmp_rootfs
mv debian_rootfs/* tmp_rootfs/
# umount
umount tmp_rootfs
烧写
方法一:使用 CCT 烧写,方法参见: Linux环境下烧写镜像
方法二:将 debian-rootfs.ext4 传输到 evb 开发板上,dd if=debian-rootfs.ext4 of=/dev/mmcblk0p3