[WIP] How to emulate an ARM device using QEMU

Prepare a disk image

Create and format partitions

  1. Create disk image, create EFI and root partitions.
  2. Mount as loopback devices (using losetup) and format partitions.
  3. Mount partition images to local filesystem.

Add the base Arch ARM installation

  1. Untar aarch64 Arch base image to root partition.
  2. Add /etc/fstab based on image partitions (genfstab -U /mnt works pretty well).
  3. Unmount etc.

Prepare QEMU

  1. Install qemu-arch-extra (repo) and edk2-avmf (AUR). To use virt-manager as your GUI front-end:
    • sudo pacman -S virt-manager qemu-arch-extra-headless
    • yay -S edk2-avmf

Create the virtual machine

  1. Set up QEMU machine aarch64/virt with prepared disk image and direct kernel/initramfs booting from the Arch base image files. Boot.

Configure the installation

  1. Link /boot/Image.gz to /boot/vmlinuz-linux.
  2. Install GRUB. Update.

Final setup

  1. Remove direct kernel booting from QEMU settings. Add in display and input hardware.

Done

  1. Boot and do any remaining setup in the same way as you normally would.
7 Likes