创建面向 arm64 的 Debian 11 根文件系统时,请确保使用 amd64+QEMU 的 qemu-user-static 版本为 6.1 或更高版本
首先
如果在Ubuntu(例如18.04)上使用QEMU来构建适用于arm64的Debian11(bullseye)根文件系统,可以按以下方式操作。
shell$ mkdir debian11-rootfs
shell$ sudo chown root debian11-rootfs
shell$ sudo debootstrap --arch=arm64 --foreign bullseye debian11-rootfs
:
:
shell$ sudo cp /usr/bin/qemu-aarch64-static debian11-rootfs/usr/bin
shell$ sudo cp /etc/resolv.conf debian11-rootfs/etc
可能发生以下这样的错误。
1. 第一個現象
在debootstrap的第二阶段出现了以下错误。
shell$ sudo chroot debian11-rootfs
I have no name!@ubuntu:/# distro=bullseye
I have no name!@ubuntu:/# export LANG=C
I have no name!@ubuntu:/# /debootstrap/debootstrap --second-stage
W: Failure trying to run: /sbin/ldconfig
W: See //debootstrap/debootstrap.log for details
第二個現象
安装python3-minimal时出现分割错误。
造成原因和相應的對策
无论是哪种情况,只要qemu-user-static版本太旧就会发生。
為了避免現象1,需要使用5.2版本或更高版本,它可以在buster-backports之後提供。
為了避免現象2,需要使用6.1版本或更高版本。
如果您想避免二者之间,請使用6.1版本或更高版本。我找到了qemu-user-static_6.1+dfsg-8_amd64.deb,通過dpkg -i命令安裝和使用它。
以下是一些可供参考的资料
-
- Bug#982422: debootstrap: segmentation fault around ldconfig during debootstrapping bullseye/arm64 on a buster/amd64 host
-
- Bug#988174: /usr/bin/qemu-aarch64-static: Segfaults sometimes on python3-minimal on arm64
-
- AMD64 マシン用 qemu-user-static_5.2+dfsg-9~bpo10+1_amd64.deb のダウンロードページ
- https://debian.pkgs.org/sid/debian-main-amd64/qemu-user-static_6.1+dfsg-8_amd64.deb.html