Ubuntu 针对不同的 CPU 架构提供相应的 ubuntu base 根文件系统,目前提供的架构有amd64、arm64、armhf、i386、s390x、ppc64el、riscv64
到官网下载自己需要的版本:
http://cdimage.ubuntu.com/ubuntu-base/releases/
如下图:
此次为arm设备,计划采用ubuntu 22.04,故下载ubuntu-base-22.04.3-base-arm64.tar.gz
dd if=/dev/zero of=ubuntu-22.04.3-base.ext4 bs=1M count=1024
mkfs.ext4 -O 64bit ubuntu-22.04.3-base.ext4
mkdir -p ubuntu-22.04.3-base
mount -o loop ubuntu-22.04.3-base.ext4 ubuntu-22.04.3-base
tar -xvf ubuntu-base-22.04.3-base-arm64.tar.gz -C ubuntu-22.04.3-base
cd ubuntu-22.04.3-base
echo "nameserver 223.5.5.5" > ./etc/resolv.conf
vim ./etc/apt/sources.list
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.aliyun.com/ubuntu-ports/ jammy main restricted
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-updates main restricted
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu-ports/ jammy universe
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy universe
deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-updates universe
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.aliyun.com/ubuntu-ports/ jammy multiverse
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-updates multiverse
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-security main restricted
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-security main restricted
deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-security universe
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-security universe
deb http://mirrors.aliyun.com/ubuntu-ports/ jammy-security multiverse
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ jammy-security multiverse
chroot安装包需要先执行:
cd ..
mount --bind /dev ubuntu-22.04.3-base/dev
cd -
防止没有权限
安装基础软件包:
chroot ./
apt update
apt install vim sudo kmod net-tools ethtool ifupdown language-pack-en-base rsyslog htop iputils-ping gcc make libfdt-dev wget -y
设置root的密码
passwd root
cp -r kvmtool ubuntu-22.04.3-base/opt/
cp cirros-0.6.0-aarch64-disk.img ubuntu-22.04.3-base/opt/
cd bin
ln -sf bash sh
cd -
配置完成后
exit
cd ..
umount ubuntu-22.04.3-base/dev
umount ubuntu-22.04.3-base
需要提前准备好Image和kvmtools工具,然后通过lkvm启动根文件如下
lkvm run linux-6.6.2/arch/arm64/boot/Image --disk ubuntu-22.04.3-base.ext4 --console serial --name vm1
Get:1 http://mirrors.aliyun.com/ubuntu-ports jammy InRelease [270 kB]
0% [Working]/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
E: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Err:1 http://mirrors.aliyun.com/ubuntu-ports jammy InRelease
gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Get:2 http://mirrors.aliyun.com/ubuntu-ports jammy-updates InRelease [119 kB]
0% [Working]/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
E: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Err:2 http://mirrors.aliyun.com/ubuntu-ports jammy-updates InRelease
gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Get:3 http://mirrors.aliyun.com/ubuntu-ports jammy-backports InRelease [109 kB]
0% [Working]/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
E: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Err:3 http://mirrors.aliyun.com/ubuntu-ports jammy-backports InRelease
gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Get:4 http://mirrors.aliyun.com/ubuntu-ports jammy-security InRelease [110 kB]
0% [Working]/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
/usr/bin/apt-key: 95: cannot create /dev/null: Permission denied
E: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Err:4 http://mirrors.aliyun.com/ubuntu-ports jammy-security InRelease
gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
Reading package lists... Done
W: GPG error: http://mirrors.aliyun.com/ubuntu-ports jammy InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://mirrors.aliyun.com/ubuntu-ports jammy InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.aliyun.com/ubuntu-ports jammy-updates InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://mirrors.aliyun.com/ubuntu-ports jammy-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.aliyun.com/ubuntu-ports jammy-backports InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://mirrors.aliyun.com/ubuntu-ports jammy-backports InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://mirrors.aliyun.com/ubuntu-ports jammy-security InRelease: gpgv, gpgv2 or gpgv1 required for verification, but neither seems installed
E: The repository 'http://mirrors.aliyun.com/ubuntu-ports jammy-security InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
解决方法:
mount --bind /dev ubuntu-22.04.3-base/dev
https://doc.embedfire.com/lubancat/build_and_deploy/zh/latest/building_image/ubuntu_rootfs/ubuntu_rootfs.html
https://cloud.tencent.com/developer/ask/sof/116426316