https://futurewei-cloud.github.io/ARM-Datacenter/qemu/how-to-launch-aarch64-vm
The below instructions will allow for bringing up an ARM VM from scratch.
To launch an aarch64 VM we first need to install a few dependencies, including QEMU and the qemu-efi-aarch64 package, which includes the efi firmware.
apt-get install qemu-system-arm
apt-get install qemu-efi-aarch64
apt-get install qemu-utils
Create the flash images with the correct sizes.
dd if=/dev/zero of=flash1.img bs=1M count=64
dd if=/dev/zero of=flash0.img bs=1M count=64
dd if=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd of=flash0.img conv=notrunc
Create a dedicated directory (folder) on your host system to contain this virtual machine.
Download the latest Alpine Linux “Virtual” ISO file for the aarch64 architecture.
Create the disk image by running the following command:
qemu-img create -f qcow2 alpine.qcow2 40G
Start QEMU with the installer.
qemu-system-aarch64 -nographic -machine virt,gic-version=max -m 2048 -cpu max -smp 4 \
-netdev user,id=vnet,hostfwd=:127.0.0.1:2222-:22 -device virtio-net-pci,netdev=vnet \
-drive file=alpine.qcow2,if=none,id=drive0,cache=writeback -device virtio-blk,drive=drive0,bootindex=0 \
-drive file=alpine-virt-3.21.2-aarch64.iso,if=none,id=drive1,cache=writeback -device virtio-blk,drive=drive1,bootindex=1 \
-drive file=flash0.img,format=raw,if=pflash -drive file=flash1.img,format=raw,if=pflash
Setup the system with the command: setup-alpine
Once the install is finished you can exit QEMU with ctrl+a,x
Then restart QEMU without the installer image with the following command.
qemu-system-aarch64 -nographic -machine virt,gic-version=max -m 2048 -cpu max -smp 4 \
-netdev user,id=vnet,hostfwd=:127.0.0.1:2222-:22 -device virtio-net-pci,netdev=vnet \
-drive file=alpine.qcow2,if=none,id=drive0,cache=writeback -device virtio-blk,drive=drive0,bootindex=0 \
-drive file=flash0.img,format=raw,if=pflash -drive file=flash1.img,format=raw,if=pflash
Starting the virtual machine by hand with the full command line each time would be cumbersome and error-prone. Consequently, I recommend creating a script that contains the QEMU command. The following example is a Bourne shell script for Linux or macOS.
#!/bin/sh
#
# Alpine Linux on AArch64
#
qemu-system-aarch64 -nographic -machine virt,gic-version=max -m 2048 -cpu max -smp 4 \
-netdev user,id=vnet,hostfwd=:127.0.0.1:2222-:22 -device virtio-net-pci,netdev=vnet \
-drive file=alpine.qcow2,if=none,id=drive0,cache=writeback -device virtio-blk,drive=drive0,bootindex=0 \
-drive file=flash0.img,format=raw,if=pflash -drive file=flash1.img,format=raw,if=pflash
echo "QEMU has finished. Press Enter to continue."
read throwaway
I’m extremely impressed along with your writing talents as
well as with the structure for your blog. Is that this a paid subject matter or did you modify it yourself?
Either way keep up the excellent high quality writing, it’s uncommon to peer a great weblog like this one these days.
Stan Store alternatives!
Thanks for your compliments! It’s based on a free theme from wordpress and i did some minor modifications:)