Android is an operating system based on the Linux kernel and developed for mobile devices. For that reason, it is focused on the ARM architecture that offers less power consumption compared to x86 and thus increase battery life.
Virtualizing official Android is not possible on x86 processors, the only possibility is to emulate it with Android Studio or applications like BlueStacks. Although there are unofficial projects that have ported Android Open Source Project for x86 architecture. For example, the most recognized projects are Android x86 and Android Generic Project.
Therefore, it is possible to install or virtualize it on desktops or servers with x86 or x86_64 architecture. This article will explain how to virtualize Android x86 to play it live or install it on a disk image with KVM on an Ubuntu 20.04 LTS server using QEMU.
Installation of QEMU
First, check that your processor has virtualization* enabled:
# egrep 'vmx|svm' /proc/cpuinfo
If yes, update the repositories and install QEMU x86 (Debian/Ubuntu):
# apt update && apt install qemu-system-x86 -y
Subsequently, check that it supports KVM virtualization:
# kvm-ok
It should show the following result:
INFO: /dev/kvm exists
KVM acceleration can be used
*It will depend on the processor brand, with Intel it should appear "vmx" and with AMD "svm".
Download Android x86 and virtualize it with QEMU
Then download the corresponding Android x86 image:
# wget -P /root "https://jztkft.dl.sourceforge.net/project/blissos-dev/Android-Generic/PC/aosp/stock/11/AG-11--x86_64-202106131243_k-kernel-5.4_m-x86.iso"
# wget -P /root "https://altushost-swe.dl.sourceforge.net/project/blissos-dev/Android-Generic/PC/aosp/stock/10/AG-AOSP-10-android_x86_64-202009231416_k-kernel-5.8-si-next-rmi_m-android-10.0.0_r41_dgc-q-x86-generic_cros-wv.iso"
# wget -P /root "https://osdn.net/frs/redir.php?m=gigenet&f=android-x86%2F71931%2Fandroid-x86_64-9.0-r2.iso"
# wget -P /root "https://osdn.net/frs/redir.php?m=nchc&f=android-x86%2F69704%2Fandroid-x86_64-8.1-r6.iso"
# wget -P /root "https://osdn.net/frs/redir.php?m=nchc&f=android-x86%2F67834%2Fandroid-x86_64-7.1-r5.iso"
# wget -P /root "https://osdn.net/frs/redir.php?m=rwthaachen&f=android-x86%2F65890%2Fandroid-x86_64-6.0-r3.iso"
You can use Android live, but if you prefer to install it, you will need to create a disk of at least 5 GB (recommended minimum 8 GB):
# qemu-img create android.img 8G
Once this is done, you can directly virtualize Android. To do so, simply run QEMU with the Android ISO and the created disk. Although to access it use the VNC option that it incorporates:
# qemu-system-x86_64 -net nic -net user -m 1024 -enable-kvm -drive file=/root/android.img,format=raw -vnc 127.0.0.1:0 -cdrom /root/*android-x86*.iso -boot d
As you may have noticed in the command, VNC will only listen locally and is recommended for security. The traffic will not be encrypted and there is no access control and it is not safe to publish it to the internet. Therefore, to access via VNC you can tunnel through OpenSSH. Open another SSH connection to the Ubuntu server and forward the VNC port:
# ssh root@ServerIP -L 5900:localhost:5900
That way, you can directly open a VNC client and connect to localhost to install or play Android live:
If you finally install Android x86 on the created disk image, it will not be necessary to run QEMU with the ISO again. Therefore, simply run the following next time:
# qemu-system-x86_64 -net nic -net user -m 1024 -enable-kvm -drive file=/root/android.img,format=raw -vnc 127.0.0.1:0
But also remember to create an SSH connection for VNC forwarding for when you want to connect with a new SSH session:
# ssh root@serverIP -L 5900:localhost:5900
We hope we have helped you with this tutorial, have you tried it? Leave us your comments! 🙂
Remember, if you have any questions about this or any other issue related to your Clouding servers, do not hesitate to write to soporte@clouding.io. We are at your side for whatever you need!