title:Qemu ARM64 keywords:arm64,linux,kernel,initrd # Qemu ARM64 How to run QEMU with various ARM64 images. Not covering full blown support of each distribution. Goal is just to get to Linux shell and no more further at this stage. ## Run Ubuntu Image ```bash wget -c https://cdimage.ubuntu.com/releases/22.04/release/ubuntu-22.04.3-live-server-arm64.iso ``` ## Run Debian Image ```bash wget -c http://http.us.debian.org/debian/dists/bookworm/main/installer-arm64/current/images/netboot/debian-installer/arm64/initrd.gz wget -c http://http.us.debian.org/debian/dists/bookworm/main/installer-arm64/current/images/netboot/debian-installer/arm64/linux ``` Prepare qemu empty hdd image ```bash qemu-img create -f qcow2 hda.qcow2 5G ``` Boot image and follow installation steps. That will install Debian ARM64 distribution ```bash qemu-system-aarch64 -M virt -m 1024 -cpu cortex-a53 \ -kernel linux \ -initrd initrd.gz \ -drive if=none,file=hda.qcow2,format=qcow2,id=hd \ -device virtio-blk-pci,drive=hd \ -netdev user,id=mynet \ -device virtio-net-pci,netdev=mynet \ -nographic -no-reboot ``` get guestfs-tools to make below commands work [https://libguestfs.org/](https://libguestfs.org/) find vmlinuz and initrd names in /boot directory ``` virt-ls -a hda.qcow2 /boot virt-copy-out -a hda.qcow2 /boot/vmlinuz-6.1.0-12-arm64 /boot/initrd.img-6.1.0-12-arm64 . ``` Boot qemu with installed debian arm64 image ``` qemu-system-aarch64 -M virt -m 1024 -cpu cortex-a53 \ -kernel vmlinuz-6.1.0-12-arm64 \ -initrd initrd.img-6.1.0-12-arm64 \ -append 'root=/dev/vda2' \ -drive if=none,file=hda.qcow2,format=qcow2,id=hd \ -device virtio-blk-pci,drive=hd \ -netdev user,id=mynet \ -device virtio-net-pci,netdev=mynet \ -nographic ``` ## Run Archlinux ```bash wget -c http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz ``` ## Create custom images ``` ``` ### Create kernel ``` ``` ### Create initrd or rootfs find . -print0 | cpio --null -ov --format=newc > ../initramfs.cpio zstd initramfs.cpio List content of cpio lsinitcpio initramfs.cpio ### Unpack initrd ## Run virt Qemu contains configuration to run non existent machine called virt that suppose to be run with virtual machines. ```bash ``` ## Under ArchLinux Install all qemu packages with ```bash pacman -S qemu-full ``` ## Links 1. [/writeup/qemu_usage.md](/writeup/qemu_usage.md) 2. [https://www.qemu.org/docs/master/system/target-arm.html](https://www.qemu.org/docs/master/system/target-arm.html) 3. [https://futurewei-cloud.github.io/ARM-Datacenter/qemu/how-to-launch-aarch64-vm/](https://futurewei-cloud.github.io/ARM-Datacenter/qemu/how-to-launch-aarch64-vm/) 4. [https://wiki.debian.org/Arm64Qemu](https://wiki.debian.org/Arm64Qemu) 5. [https://gist.github.com/oznu/ac9efae7c24fd1f37f1d933254587aa4](https://gist.github.com/oznu/ac9efae7c24fd1f37f1d933254587aa4) 6. [https://medium.com/@kiky.tokamuro/creating-initramfs-5cca9b524b5a](https://medium.com/@kiky.tokamuro/creating-initramfs-5cca9b524b5a) 7. [https://translatedcode.wordpress.com/2017/07/24/installing-debian-on-qemus-64-bit-arm-virt-board/](https://translatedcode.wordpress.com/2017/07/24/installing-debian-on-qemus-64-bit-arm-virt-board/) 8. [https://archlinuxarm.org/platforms/armv8/generic](https://archlinuxarm.org/platforms/armv8/generic) 9. [https://github.com/niw/TinyLinux](https://github.com/niw/TinyLinux) 10. [https://cs4118.github.io/dev-guides/debian-kernel-compilation.html](https://cs4118.github.io/dev-guides/debian-kernel-compilation.html) 11. [https://developer.ibm.com/articles/l-initrd/](https://developer.ibm.com/articles/l-initrd/) 12. [https://wiki.archlinux.org/title/mkinitcpio](https://wiki.archlinux.org/title/mkinitcpio) 13. https://www.ibm.com/docs/en/zos/2.4.0?topic=codes-exit-status-usrsbininit 14. https://access.redhat.com/solutions/24029 15. [http://phwl.org/2022/qemu-aarch64-debian/](http://phwl.org/2022/qemu-aarch64-debian/)