Revision 1
© 2024 by Zack Smith. All rights reserved.
Running ARM64 (aarch64) code in QEMU
If you don't own an ARM64 computer like a
Raspberry Pi, an Apple Silicon based Mac, or a Snapdragon-based device,
you can still run aarch64 code using QEMU and booting Debian Linux.
The following steps elucidate how to create an aarch64 Debian Linux
based disk image and run it with QEMU. This approach
does not support X-Windows however -- it's just text-based.
0. Install QEMU
sudo apt install qemu-system-arm qemu-efi-aarch64 qemu-utils
1. Create two 64MB PFlash drives
The first one will be initialized with the QEMU EFI data.
dd if=/dev/zero of=pflash0.img bs=1M count=64 dd if=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd \ of=pflash0.img conv=notrunc dd if=/dev/zero of=pflash1.img bs=1M count=64
2. Create a large drive to hold Debian Linux.
To ensure it'll hold all of Debian without the GUI stuff let's
make it 8 gigabytes. The minimum size is about 5 GB.
dd if=/dev/zero of=debian-aarch64.img bs=1G count=8
3. Fetch the latest Debian aarch64 image.
Download the DVD image from here:
4. Run QEMU to install Debian
#!/bin/bash ISO=debian-12.7.0-arm64-DVD-1.iso IMG=debian-aarch64.img qemu-system-aarch64 -nographic \ -machine virt,gic-version=max \ -m 512M \ -cpu max \ -netdev user,id=vnet,hostfwd=:127.0.0.1:0-:22 \ -device virtio-net-pci,netdev=vnet \ -drive file=pflash0.img,format=raw,if=pflash \ -drive file=pflash1.img,format=raw,if=pflash \ -drive file=$IMG,if=none,id=drive0,cache=writeback \ -device virtio-blk,drive=drive0,bootindex=0 \ -drive file=$ISO,if=none,id=drive1,cache=writeback \ -device virtio-blk,drive=drive1,bootindex=1
5. Launch Debian aarch64
#!/bin/bash IMG=debian-aarch64.img qemu-system-aarch64 \ -machine virt,gic-version=max \ -nographic \ -m 1536M \ -M virt \ -boot c \ -cpu max \ -smp 2 \ -netdev user,id=vnet,hostfwd=:127.0.0.1:0-:22 \ -device virtio-net-pci,netdev=vnet \ -drive file=,if=none,id=drive0,cache=writeback \ -device virtio-blk,drive=drive0,bootindex=0 \ -drive file=pflash0.img,format=raw,if=pflash \ -drive file=pflash1.img,format=raw,if=pflash