How to test ARM Ubuntu under Qemu the easiest way?

4

I would like to play with ARM version of Ubuntu (with graphical support) under Qemu, but I have problems finding any tutorial on how to get it done most easily (I would prefer to just download some image and run one command to execute it). How to achieve that with least hassle?

d33tah

Posted 2015-07-19T21:59:16.553

Reputation: 1 014

You could install qemu and then use it to boot the live medium of Ubuntu ARM, using something similar to: qemu-system-arm --enable-kvm -m 512M -cdrom ~/Downloads/ubuntu-arm.iso. – thiagowfx – 2015-07-19T23:13:48.500

@thiagowfx: Is there such a thing? I remember asking about it once: http://superuser.com/q/569655/171552

– d33tah – 2015-07-20T16:19:59.917

What do you mean? I'm not sure if the above command would work, that's why I posted a comment instead of an answer. However, in theory, it should work. – thiagowfx – 2015-07-21T05:00:38.807

You should also consider buying an inexpensive dev-board, like a Tritium (32-bit) or LePotato (64-bit). Tinkerboard is also a nice choice. You will have a much better experience then a [slow] emulator.

– jww – 2019-11-15T15:16:43.630

Answers

3

In this answer: https://askubuntu.com/questions/281763/is-there-any-prebuilt-qemu-ubuntu-image32bit-online/1081171#1081171 I have described the following working setups for Ubuntu 18.04 guest / host:

  • cloud image arm64: quickest setup to get started
  • debootstrap arm64: reasonably quick, but allows for more image customization

Those setups provide prebuilt disk images, and don't go through the installer. They are the best choices that I've seen so far.

Next, I've also managed to run the arm64 server image on QEMU. However, this goes through the installer, which is borderline impractically slow to do, unless you are not on an ARM host with KVM. This is specially painful because dozens of interactions are required to finish installation.

Here is the server script, tested on an Ubuntu 18.10 host:

#!/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.
# This filename may need updating, check http://cdimage.ubuntu.com/releases/18.04/release/
id=ubuntu-18.04.3-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 \
;

GitHub upstream.

See also this for Raspberry Pi emulation: https://stackoverflow.com/questions/28880833/how-to-emulate-the-raspberry-pi-2-on-qemu/45814913#45814913

amd64 desktop shown at: https://askubuntu.com/questions/884534/how-to-run-ubuntu-16-04-desktop-on-qemu/1046792#1046792

Ciro Santilli 新疆改造中心法轮功六四事件

Posted 2015-07-19T21:59:16.553

Reputation: 5 621