搭建Ubuntu24.04 Arm64编译环境
前提条件
- 一台带网络端口且操作系统为Ubuntu 22.04的x86 Linux服务器。
- Linux服务器已安装python、make、gcc、unzip、pigz、bison、flex、libncurses-dev、squashfs-tools、bc、device-tree-compiler、libssl-dev、cmake和rpm2cpio。
操作步骤
- 登录Linux服务器。
- 执行如下命令,切换至root用户。
su - root
- 上传Ubuntu24.04 Arm64镜像到服务器。
- 安装环境依赖工具。
apt-get update
apt-get install qemu-user-static
- 获取最小文件系统。
- 解压镜像,生成“squashfs-root”目录。
unsquashfs ubuntu-server-minimal.squashfs
- 配置Ubuntu的网络源。
- 执行以下命令,在当前目录创建sources.list文件。
网络源配置参考如下。
deb https://repo.huaweicloud.com/ubuntu-ports/ noble main restricted universe multiverse deb-src https://repo.huaweicloud.com/ubuntu-ports/ noble main restricted universe multiverse deb https://repo.huaweicloud.com/ubuntu-ports/ noble-security main restricted universe multiverse deb-src https://repo.huaweicloud.com/ubuntu-ports/ noble-security main restricted universe multiverse deb https://repo.huaweicloud.com/ubuntu-ports/ noble-updates main restricted universe multiverse deb-src https://repo.huaweicloud.com/ubuntu-ports/ noble-updates main restricted universe multiverse deb https://repo.huaweicloud.com/ubuntu-ports/ noble-backports main restricted universe multiverse deb-src https://repo.huaweicloud.com/ubuntu-ports/ noble-backports main restricted universe multiverse ## Not recommended # deb https://repo.huaweicloud.com/ubuntu-ports/ noble-proposed main restricted universe multiverse # deb-src https://repo.huaweicloud.com/ubuntu-ports/ noble-proposed main restricted universe multiverse
- 配置完成后,按“Esc”键,再执行:wq!保存修改,并按“Enter”键退出。
- 执行以下命令,将sources.list文件复制到“squashfs-root/etc/apt”目录下。
- 执行以下命令,在当前目录创建sources.list文件。
- 执行如下命令,切换根系统。
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 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 device-tree-compiler -y
apt-get install build-essential -y
apt-get install Python3 -y
apt-get install cmake -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组件下载。
- 执行如下命令,安装Linux组件。
- 执行如下命令,退出根系统。
exit
