Skip to content

Instantly share code, notes, and snippets.

@cyring
Created July 28, 2023 09:09
Show Gist options
  • Save cyring/7abc7035089a49ccb3d84644b7b63076 to your computer and use it in GitHub Desktop.
Save cyring/7abc7035089a49ccb3d84644b7b63076 to your computer and use it in GitHub Desktop.
qemu-system-aarch64 debian arm64
debian-11.6.0-arm64-netinst.iso
@cyring
Copy link
Author

cyring commented Jul 28, 2023

Prerequisites

  • AArch64 QEMU for x86_64 host
  • QEMU UEFI image EDK2 BIOS
  • Debian ISO for AArch64
  • At least 2.5GB of storage for the VM

Create the VM

  • Download Debian for AArch64 in ~/Downloads/debian-11.6.0-arm64-netinst.iso
  • Create the guest disk
qemu-img create ~/VM/arm.img 2560M
  • UEFI boot the Debian guest
qemu-system-aarch64 -machine virt -m 4096M -serial stdio -smp 4 -cpu max \
-bios "/usr/share/edk2/aarch64/QEMU_EFI.fd" \
-drive file=~/Downloads/debian-11.6.0-arm64-netinst.iso,\
id=cdrom,if=none,media=cdrom \
-device virtio-scsi-device \
-device scsi-cd,drive=cdrom \
-drive file=~/VM/arm.img,id=hd,if=none,media=disk \
-device virtio-scsi-device \
-device scsi-hd,drive=hd \
-netdev user,id=net0,hostfwd=tcp::5555-:22 \
-device virtio-net-device,netdev=net0
  • Install Debian
  • Retrieve the Kernel and Initrd images into the host
## Mount the guest disk
sudo modprobe nbd max_part=8
sudo qemu-nbd --connect=/dev/nbd0 ~/VM/arm.img
sudo fdisk -l /dev/nbd0
sudo mount -o ro /dev/nbd0p2 /mnt/
## Copy the images (not the symlinks)
mkdir ~/VM/arm/
cp -v /mnt/boot/vmlinuz ~/VM/arm/
cp -v /mnt/boot/initrd.img ~/VM/arm/
sync
## Unmount the guest disk
sudo qemu-nbd --disconnect /dev/nbd0
sudo modprobe -r nbd

Run the VM

qemu-system-aarch64 -machine virt -m 4096M -vga std -display none -serial mon:stdio -smp 8 -cpu cortex-a76 \
-initrd ~/VM/arm/initrd.img \
-kernel ~/VM/arm/vmlinuz \
-append "root=/dev/sda2 break=n audit=0 add_efi_memmap nmi_watchdog=0 selinux=0 loglevel=3 rd.systemd.show_status=auto rd.udev.log-priority=3 consoleblank=0 vt.color=0x03 nowatchdog mitigations=off nokaslr sysrq_always_enabled" \
-bios "/usr/share/edk2/aarch64/QEMU_EFI.fd" \
-drive file=~/VM/arm.img,id=hd,if=none,media=disk \
-device virtio-scsi-device \
-device scsi-hd,drive=hd \
-netdev user,id=net0,hostfwd=tcp::5555-:22 \
-device virtio-net-device,netdev=net0

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