![如何在 QEMU 中运行 Ubuntu 16.04 ARM?](https://linux22.com/image/992131/%E5%A6%82%E4%BD%95%E5%9C%A8%20QEMU%20%E4%B8%AD%E8%BF%90%E8%A1%8C%20Ubuntu%2016.04%20ARM%EF%BC%9F.png)
我的目标是在 Qemu(在 Ubuntu 16.04 x64 主机上)中运行 Ubuntu 16.04(ARM)。
我尝试遵循这个-旧- 教程没有成功:
Home directory not accessible: Permission denied
pulseaudio: pa_context_connect() failed
pulseaudio: Reason: Connection refused
pulseaudio: Failed to initialize PA contextaudio: Could not init `pa' audio driver
Could not initialize SDL(No available video device) - exiting
debian_squeeze_armel_standard.qcow2
我没有使用那里的图像,而是使用了ubuntu-16.04-预安装服务器-armhf+raspi2.img。
忘记上述文章了,在 Qemu 上运行 Ubuntu 16.04-arm 的正确方法是什么?
如果无法轻松地通过 Qemu 运行它,还有其他选择吗?
答案1
在这个答案中:网上有没有预建的 QEMU Ubuntu 映像(32 位)?我已经描述了针对 Ubuntu 18.04 客户机/主机的以下工作设置:
- cloud image arm64:最快捷的设置方式
- debootstrap arm64:速度相当快,但允许更多图像定制
这些设置提供了预建的磁盘映像,无需通过安装程序。它们是迄今为止我见过的最佳选择。
接下来,我还设法在 QEMU 上运行了 arm64 服务器映像。但是,这需要通过安装程序,除非您不在带有 KVM 的 ARM 主机上,否则执行速度会非常慢。这特别痛苦,因为需要进行数十次交互才能完成安装。
以下是在 Ubuntu 18.10 主机上测试的服务器脚本:
#!/usr/bin/env bash
set -eux
# Tested on Ubuntu 18.10.
# - https://superuser.com/questions/942657/how-to-test-arm-ubuntu-under-qemu-the-easiest-way
# - https://askubuntu.com/questions/797599/how-to-run-ubuntu-16-04-arm-in-qemu
# Parameters.
id=ubuntu-18.04.1-server-arm64
#id=debian-9.6.0-arm64-xfce-CD-1
img="${id}.img.qcow2"
img_snapshot="${id}.img.snapshot.qcow2"
iso="${id}.iso"
flash0="${id}-flash0.img"
flash1="${id}-flash1.img"
# Images.
if [ ! -f "$iso" ]; then
wget "http://cdimage.ubuntu.com/releases/18.04/release/${iso}"
fi
if [ ! -f "$img" ]; then
qemu-img create -f qcow2 "$img" 1T
fi
if [ ! -f "$img_snapshot" ]; then
qemu-img \
create \
-b "$img" \
-f qcow2 \
"$img_snapshot" \
;
fi
if [ ! -f "$flash0" ]; then
dd if=/dev/zero of="$flash0" bs=1M count=64
dd if=/usr/share/qemu-efi/QEMU_EFI.fd of="$flash0" conv=notrunc
fi
if [ ! -f "$flash1" ]; then
dd if=/dev/zero of="$flash1" bs=1M count=64
fi
# Run.
#
# cdrom must be scsi or else the installation fails midway with:
#
# > Detect and mount CD-ROM
# >
# > Your installation CD-ROM couldn't be mounted. This probably means
# > that the CD-ROM was not in the drive. If so you can insert it and try
# > again.
# >
# > Retry mounting the CD-ROM?
# > Your installation CD-ROM couldn't be mounted.
#
# This is because the drivers for the default virtio are not installed in the ISO,
# because in the past it was not reliable on qemu-system-aarch64.
#
# See also:
# https://bazaar.launchpad.net/~ubuntu-testcase/ubuntu-manual-tests/trunk/view/head:/testcases/image/1688_ARM64_Headless_KVM_Guest
qemu-system-aarch64 \
-cpu cortex-a57 \
-device rtl8139,netdev=net0 \
-device virtio-scsi-device \
-device scsi-cd,drive=cdrom \
-device virtio-blk-device,drive=hd0 \
-drive "file=${iso},id=cdrom,if=none,media=cdrom" \
-drive "if=none,file=${img_snapshot},id=hd0" \
-m 2G \
-machine virt \
-netdev user,id=net0 \
-nographic \
-pflash "$flash0" \
-pflash "$flash1" \
-smp 2 \
;
另请参阅有关 Raspberry Pi 仿真的信息:https://stackoverflow.com/questions/28880833/how-to-emulate-the-raspberry-pi-2-on-qemu/45814913#45814913
amd64 桌面显示于:如何在 QEMU 上运行 Ubuntu 16.04 桌面?
答案2
这不起作用,因为你使用的镜像是为 Raspberry Pi 2 设备预编译的,并且只能在 Raspberry Pi 2 上运行。尝试本教程