定制Ubuntu 22.04文件系统
由于当前Ubuntu 22.04的公共镜像源没有自带常用工具包,无法通过挂载本地源方式进行文件系统配置,所以需要通过配置网络源手动下载常用Linux组件,定制Sample-root-filesystem-soc_ubuntu-22.04-aarch64.img。
前提条件
- 制作环境为Arm架构的Ubuntu操作系统的服务器。
- 已获取Ubuntu 22.04镜像“ubuntu-22.04-live-server-arm64.iso”,并上传到部署环境的任意目录。

- 镜像获取方式:https://old-releases.ubuntu.com/releases/22.04.1/ubuntu-22.04-live-server-arm64.iso
- 若用户无Arm架构的Ubuntu操作系统的服务器,可访问Atlas 200I A2 加速模块软件包,下载并解压Ascend-hdk-310b-npu-sample-root-filesystem-soc_23.0.rc1_linux-aarch64.zip,直接获取Sample-root-filesystem-soc_ubuntu-22.04-aarch64.img。
- 社区版软件不需要申请下载权限可以直接下载,但软件不能用于商业用途, 详细请参见社区华为软件许可协议;如果您需要用于商业用途,参见本章节的操作步骤进行制作。因此如果您下载软件仅用于调试验证,推荐下载社区版软件。
操作步骤
- 登录制作Sample-root-filesystem-soc_ubuntu-22.04-aarch64.img的服务器,详细操作请参见使用PuTTY登录设备(网口方式)。
- 获取最小文件系统。
- 执行以下命令,解压镜像,生成“squashfs-root”目录。
unsquashfs ubuntu-server-minimal.squashfs
- 配置Ubuntu的网络源。
执行以下命令,在当前目录创建sources.list文件。
vim sources.list
网络源配置参考如下。
deb https://repo.huaweicloud.com/ubuntu-ports/ bionic main restricted universe multiverse deb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic main restricted universe multiverse deb https://repo.huaweicloud.com/ubuntu-ports/ bionic-security main restricted universe multiverse deb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic-security main restricted universe multiverse deb https://repo.huaweicloud.com/ubuntu-ports/ bionic-updates main restricted universe multiverse deb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic-updates main restricted universe multiverse deb https://repo.huaweicloud.com/ubuntu-ports/ bionic-backports main restricted universe multiverse deb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic-backports main restricted universe multiverse ## Not recommended # deb https://repo.huaweicloud.com/ubuntu-ports/ bionic-proposed main restricted universe multiverse # deb-src https://repo.huaweicloud.com/ubuntu-ports/ bionic-proposed main restricted universe multiverse
保存配置文件并退出。
执行以下命令,将sources.list文件复制到“squashfs-root/etc/apt”目录下。
cp sources.list squashfs-root/etc/apt/
- 切换根系统。
执行如下命令,切换根系统。
chroot squashfs-root
- 执行以下命令,更新源。
apt-get update
若执行命令后报错“The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3B4FE6ACC0B21F32”,请参见更新网络源时签名不可用。
- 执行以下命令,安装Linux组件。
apt-get install unzip -y
apt-get install vim -y
apt-get install sysstat -y
apt-get install libnuma1 -y
apt-get install dmidecode -y
apt-get install rsync -y
apt-get install net-tools -y
apt-get install psmisc -y
apt-get install parted -y
apt-get install arping -y
apt-get install ntpdate -y
apt-get install iproute2 -y
apt-get install iputils-ping -y
apt-get install mawk -y
apt-get install cracklib-runtime -y
apt-get install ethtool -y
apt-get install ntp -y
apt-get install fdisk -y
apt-get install libssl-dev -y
apt-get install libpam-cracklib -y
apt-get install logrotate -y
- 执行apt-get install命令后,回显中出现的需要获取的包与取得的包大小一致,则下载成功,如图1所示。
- 执行apt-get install命令后,若出现“perl:warning:xxx”相关报错、“debconf:xxx”相关报错、“Failed to retrieve available kernel versions.”以及“Failed to check for processor microcode upgrades.”报错,不影响Linux组件下载。
- 执行以下命令退出根系统。
exit
- 执行以下命令进入“squashfs-root”目录。
cd squashfs-root
- 执行以下命令,重新生成Sample-root-filesystem-soc_ubuntu-22.04-aarch64.img。
find . | cpio -o -H newc | gzip > ../Sample-root-filesystem-soc_ubuntu-22.04-aarch64.img
Sample-root-filesystem-soc_ubuntu-22.04-aarch64.img在Ubuntu 22.04镜像所在目录下。