Skip to content

Instantly share code, notes, and snippets.

Forked from oznu/
Created March 16, 2022 15:23
What would you like to do?
QEMU + Ubuntu ARM aarch64

QEMU + Ubuntu ARM aarch64

These are the steps I used to get Ubuntu ARM aarch64 running with QEMU on OSX.

Get Ubuntu Image and QEMU EFI:


Create EFI volumes:

dd if=/dev/zero of=flash0.img bs=1m count=64
dd if=QEMU_EFI.fd of=flash0.img conv=notrunc
dd if=/dev/zero of=flash1.img bs=1m count=64

Create a cloud.txt file replacing the username, here shown as oznu, and the ssh-rsa value with the values appropriate for you:

  - name: oznu
      - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC...
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash

Create a cloud-config disk image:

cloud-localds --disk-format qcow2 cloud.img cloud.txt

cloud-localds is part of the cloud-utils package which is not is not available on OSX. I used an Ubuntu docker image to run the command.

docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) ubuntu
apt-get update && apt-get -y install cloud-utils
cloud-localds --disk-format qcow2 cloud.img cloud.txt

Backup your image:

cp ubuntu-16.04-server-cloudimg-arm64-uefi1.img ubuntu-16.04-server-cloudimg-arm64-uefi1.img.original

Launch QEMU Guest:

qemu-system-aarch64 -m 1024 -smp 2 -cpu cortex-a57 -M virt -nographic \
  -pflash flash0.img \
  -pflash flash1.img \
  -drive if=none,file=ubuntu-16.04-server-cloudimg-arm64-uefi1.img,id=hd0 \
  -device virtio-blk-device,drive=hd0 \
  -drive if=none,id=cloud,file=cloud.img \
  -device virtio-blk-device,drive=cloud \
  -netdev user,id=user0 -device virtio-net-device,netdev=user0 \
  -redir tcp:2222::22


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment