I discussed the problem of running virtual machines on Android phones with Termux in Termux + QEMU Linux VM. The conclusion: it is slow as hell.
Without KVM, everything depends on software emulation. The result is that you can only run 20-year-old Windows XP systems; modern operating systems are simply too heavy.
Phones equipped with Google Tensor processors introduced pKVM after Android 15, which is the technology supported underneath the AVF framework.
At the moment, except for Android 16’s experimental Debian Linux Terminal, ordinary apps cannot access pKVM. You need root privileges to enable pKVM.
1. Install packages#
With KVM acceleration, you should run a virtual machine of the same architecture. According to Termux developers, using the qemu-system-aarch64-headless package can give you a pKVM-accelerated virtual machine.
Install the following packages. On ARM machines, it is best to enable UEFI.
pkg install qemu-system-aarch64-headless qemu-utils qemu-common ovmf sudoThere is no Virt Manager in the graphical interface, and the Libvirt service probably will not run, so we have to use AVNC to access the virtual machine display.
2. Create a Linux virtual machine in Termux#
Download the Ubuntu ARM ISO and put it in Termux’s home directory
Confirm that KVM exists
sudo ls /dev/kvm- Create a virtual disk
qemu-img create -f qcow2 ubuntu.qcow2 32G- Create files to store UEFI
truncate -s 64m varstore.img
truncate -s 64m efi.img
dd if=$PREFIX/share/qemu/edk2-aarch64-code.fd of=efi.img conv=notrunc- Add a boot script
touch startubuntu.sh
chmod +x startubuntu.sh
vim startubuntu.sh- The contents are as follows
qemu-system-aarch64 -M virt \
-enable-kvm \
-drive if=pflash,format=raw,file="efi.img",readonly \
-drive if=pflash,format=raw,file="varstore.img" \
-smp cpus=2 \
-m 1024 \
-cpu host \
-nographic \
-netdev user,id=n1,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 \
-drive file=ubuntu.qcow2 \
-boot d \
-vnc :0 \
-cdrom ubuntu-24.04.3-live-server-arm64.iso- Add
sudowhen running it.
sudo ./startubuntu.shIf everything goes smoothly, you can open localhost:59000 in AVNC and see the virtual machine display.
The strange thing is that it can boot without enabling KVM, but once KVM is enabled it hits the qemu-system-aarch64: Failed to put registers after init: Invalid argument error.
If you switch to chroot and run KVM inside it, maybe the success rate will go up?


