T
Termux6mo ago
bakkar

Running qemu-aarch64 emulator inside Termux

Hello I tried to run qemu-system-x86_64 to run an alpine image it worked fine using this command:
pkg install qemu-utils qemu-common qemu-system-x86_64-headless wget -y
wget http://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso
qemu-img create -f qcow2 alpine.img 5G
qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -cdrom alpine-virt-3.19.1-x86_64.iso -nographic alpine.img
pkg install qemu-utils qemu-common qemu-system-x86_64-headless wget -y
wget http://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-virt-3.19.1-x86_64.iso
qemu-img create -f qcow2 alpine.img 5G
qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -cdrom alpine-virt-3.19.1-x86_64.iso -nographic alpine.img
It booted and I installed the system in the disk normally. Then I noticed I can get better performance by using aarch64 instead of x86_64 since my phone is using arm64 CPU This is what i tried:
pkg install qemu-system-arm
qemu-img create -f raw alpine-arch64.img 2G
wget https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/aarch64/alpine-virt-3.20.0-aarch64.iso
qemu-system-arm \
-machine virt \
-m 1024 \
-smp cpus=2 \
-drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-aarch64-code.fd \
-netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 \
-device virtio-net,netdev=n1 \
-drive file=alpine-arch64.img,format=raw,if=virtio \
-cdrom alpine-virt-3.20.0-aarch64.iso \
-nographic
pkg install qemu-system-arm
qemu-img create -f raw alpine-arch64.img 2G
wget https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/aarch64/alpine-virt-3.20.0-aarch64.iso
qemu-system-arm \
-machine virt \
-m 1024 \
-smp cpus=2 \
-drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-aarch64-code.fd \
-netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 \
-device virtio-net,netdev=n1 \
-drive file=alpine-arch64.img,format=raw,if=virtio \
-cdrom alpine-virt-3.20.0-aarch64.iso \
-nographic
But it just does nothing I waited for it 30mins no output on the terminal it just hangs there.
6 Replies
iamwho
iamwho6mo ago
you are using qemu-system-arm instead of qemu-system-aarch64 maybe?
Catinette
Catinette6mo ago
use aarch64 instead of arm and, i thirnk something is missing in the second one, the "alpine.img" at the end is not there
bakkar
bakkarOP6mo ago
I did use aarch64 now but i see massive I/O perfoance reduction the same when i used x86_64 In termux disk read speed is around 100Mb/s but inside termux 4Mb/s
replikvlt
replikvlt6mo ago
Well yes, qemu emulates a disk, so there's overhead
TheFoxPie
TheFoxPie6mo ago
Also, without KVM, doing aarch64 emulation instead of x86_64 will not give any significant performance improvement even if the host OS is having the same CPU architecture as the guest OS.
replikvlt
replikvlt6mo ago
Actually that isn't the whole truth, as aarch64 has mostly simpler instructions than x86_64, and that it's more 1:1 makes TCL work a bit faster, or have less slow down
Want results from more Discord servers?
Add your server