Skip to content

Instantly share code, notes, and snippets.

@wtdcode
Forked from itzurabhi/UB18-Qemu-AARCH64.md
Created March 16, 2022 15:23
Show Gist options
  • Save wtdcode/259f23415ca54448d6618ccb9c469692 to your computer and use it in GitHub Desktop.
Save wtdcode/259f23415ca54448d6618ccb9c469692 to your computer and use it in GitHub Desktop.
Run Ubuntu 18.04 on Qemu AARCH64 / ARM64

Install the dependecies

sudo apt install qemu-system-arm qemu-system-mips qemu-efi-aarch64 qemu-kvm qemu-efi cloud-image-utils

Prepare the EFI partition

dd if=/dev/zero of=flash0.img bs=1M count=64
dd if=/usr/share/qemu-efi/QEMU_EFI.fd of=flash0.img conv=notrunc
dd if=/dev/zero of=flash1.img bs=1M count=64

Set the credentials for the user

cat >user-data <<EOF
#cloud-config
password: thepassword
chpasswd: { expire: False }
ssh_pwauth: True
EOF

create a user-data image to initialize the VM with

cloud-localds user-data.img user-data

download ubuntu image

wget "http://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-arm64.img"

# create a backup, VM will modify the image.
cp ubuntu-18.04-server-cloudimg-arm64.img ubuntu-18.04-server-cloudimg-arm64.img.orig

qemu boot

sudo qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt -nographic -pflash flash0.img -pflash flash1.img -drive if=none,file=ubuntu-18.04-server-cloudimg-arm64.img,id=hd0 -drive file=user-data.img,format=raw,id=cloud -device virtio-blk-device,drive=hd0 -net user,hostfwd=tcp::30022-:22 -net nic -vnc :3

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