OS virtualization and emulation on Android

Android devices have the ability to run virtual machines or emulate other operating systems. It does this either via desktop virtualization, platform virtualization, or emulation via compatibility layer.

Desktop virtualization

Desktop virtualization apps are the least resource and space intensive compared to other virtualization types, since the Operating System that is being displayed on the Android device is actually located on another computer on the local network or elsewhere like on the internet.[1] Depending upon how the desktop virtualization app works, they use RDP or can use another protocol of their own. Most business oriented desktop virtualization apps require specific types of equipment or services in order for the app to fully function. For example, VMware Horizon Client requires specific VMware equipment for the app to work.[2]

A major downside that desktop virtualization apps have compared to other types of virtualization or emulation technologies is that they require a network connection to the server as stated previously above.

Platform virtualization

Platform virtualization allows more leverage to the developer as anything that relates to the guest operating system only affects the guest operating system, and not the host operating system. Due to this it is possible for the guest operating system to be rooted, where as the host operating system remains unrooted.[3][4] Due to the nature of platform virtualization and the fact that it can virtualize an rooted guest OS, it has a greater advantage over emulators as they an run applications or utilize packages that require access to the underlying system itself.

As with all platform virtualization software and applications, they take up a lot of resources of the host in order to do the virtualization.[4]

Emulation

Types of emulations

Emulation of other operating systems

Emulation of other operating systems on Android require the usage of some form of compatibility layer, where the compatibility layer must utilize some form of technologies or APIs to run the OS inside of the app container. This does come with limitations as some emulators utilize PRoot which is a chroot like environment.[5][6] Unlike terminal emulators that emulate the internal OS with/without any extension package support, can be able to install actual Ubuntu packages, as they do not rely too much on the Android system limitations. However not all packages and applications can run.

Terminal emulation of internal operating system

Terminal emulation of the Android device itself is done via either an actual local loopback to the device, or an emulation that seems to be a local loopback. Most of these terminal emulation of the device itself utilize the native terminal Toybox toolchain's library and functions that come with every android device.[7][8] However due to the fact that the majority of the functions that are readily available without utilizing a compatibility layer, means that Toybox functions can only be utilized.[9] In order for a user to add any other functions or libraries would require the user to root their own device and add the functions or libraries manually. Some of these terminal emulators allow users to enter Toybox commands implicitly, where those that don't require the usage of "toybox COMMAND".

With enhancements via semi-emulation

Some terminal emulators like Termux allow users to add packages. This is done via semi-emulating a different environment via the usage of PRoot and/or Toybox in the back-end.[8] With the semi-emulating, some predefined ported packages can be used and installed without the need of rooting the device, as they do not utilize Android system files, and reside and run in the apps own data containers and directories.[10] Because Toybox is used mostly in the back-end, it depends on how the app was developed, for Toybox to be accessed from the semi-emulated enhanced terminal.

Extensions

Many emulators of other OSes allow the usage of extensions. Other than the use of standard SSH, some emulators allow the use of technologies like VNC and XSDL. Via the use of these extensions, the user can have the emulated/virtualized OS running in an desktop like environment.[11][12]

Limitations

The majority of limitations are seen in emulation based apps rather than the platform virtualization based apps, as the emulation apps must utilize a compatibility layer. Thus for libraries and packages to work as expected like in a real OS, the compatibility layer must work properly and must be able to provide the accurate information. However, this requires that the compatibility layer or any predefined software it uses (ex. Docker) to have access many system related and device related information, which can either be done via utilization of Toybox, or via programing language libraries that Android apps can be made form like, Java, C#, and ect. Although starting from Android 8, many new security restrictions have been placed on apps, and due to these restrictions some API libraries/classes are no longer available or have been replaced by a more restrictive API libraries/classes.[13]

One of the known limitations that were implemented was that apps can only natively access only their own app sandbox root directory or sub directories on an SD card. Apps wanting to access files or folders outside that on the SD card, are required to use Android's own system file selector.[14] Due to this guest OSes running on, emulation, platform virtualization, or compatibility apps are no longer allowed to access files outside of their own sdcard Sandbox.

Majority of these limitations can be bypassed by rooting the Android device, however utilizing Linux via utilizing an emulator or virtualization app would be redundant at that point as one could turn the device itself into a Linux environment.[15]

OS internal security enhancements

More modern versions of Android have been seen having more internal system security enhancements, such that some system folders and files are no longer accessible or even viewable for that directories existence. Versions of Android before 9, allowed terminal apps to view Androids root "/" directory (although not allowing modifications or execution). [16][17]

SELinux

Android utilizes SELinux, and due to this all, system configuration files are not editable, as well as some are not even readable.[18] Thus apps can only utilize Android API's to learn about the device or system's configuration or settings. However, not all information are available to apps, and due to this many OS compatibility layer or emulation apps are not able to run every package or application.

Some known applications or packages that are unable to run are the following  :

  • Udisks2 requires udev which does not work well in most compatibility layer environments, as stated in the sub-sub-section below.[19][20]
  • Snort
  • Open vSwitch
  • mininet (requires open vSwitch to run)

Some commands that do not work due to SELinux  :

ADB, PRoot, $HOME and $PREFIX usage

Because all Android apps run in an non-privileged container space, thus the virtualization or emulation apps must utilize their own app space to do the virtualization or emulation.[22] This can be done either by ADB, PRroot, or the usage of $HOME and $PREFIX, however majority of these three are utilized by emulation apps as platform virtualization apps usually use different methods. The usage of each is used for different purposes. ADB is used for the emulation of an terminal like environment for the entire Android system, but usually as an unprivileged user. $HOME and $PREFIX can be using $HOME as "~" and $PREFIX for . However, $HOME can not be set outside of the "/data/apps data space" directory on the android file system, nor can $PREFIX be moved to another place like the SD Card.[23]

For emulators or compatibility layers to emulate or virtualize a Linux based OS on Android PRoot must be used.[5] However when PRoot is used, the environment inside of Proot can act like a Chroot environment, and/or a separate mounted environment.[24][25] In this scenario (especially in the case of compatibility layer and emulator for Guest OSes, there are packages and applications that can not run as they were never designed to run inside a chroot like environment.[6] Some of these well known prominent packages, applications, or commands are the following  :

Alternatives

Due to the issue of SeLinux and PRoot, alternatives must be used and not all of the unusable packages or applications have alternatives. Being an alternative, they don't necessarily have all the functions of the original packages or applications. Some of these alternatives include  :

Android itself being a modified Linux kernel

Because Android is a modified Linux kernel, not all configuration or system files exist or are the same in Android.[27][28] Because of this emulation apps either need to provide either their own version of the configuration or system files in its application data space, use a pre-modified distribution of ported Linux libraries that do not require the usage of the missing configuration or system files, or not support the usage of those packages. Some of these configuration and system files that are not in Android and are well known are  :

  • /etc/resolve.conf[23]

See also

References

  1. Evans, Jonny (2019-01-28). "How to run Windows 10 on an iPad Pro or on Android". Computerworld. Retrieved 2019-11-20.
  2. "Published Apps | Horizon Apps". VMware. Retrieved 2019-11-20.
  3. site, A. Word From Our Sponsors 308 posts see posts > XDA thanks its sponsors for supporting the (2019-08-08). "VMOS Lets You Run a Virtual Android Machine on your Phone". xda-developers. Retrieved 2019-11-20.
  4. Doffman, Zak. "Huawei Mate 30: New Google Play Option Is Here". Forbes. Retrieved 2019-11-20.
  5. "AnLinux : Run Linux On Android Without Root Access - Apps on Google Play". play.google.com. Retrieved 2019-11-21.
  6. about, Braden Farmer 2 posts see posts > I'm passionate; roid; Development, Roid; Building, Have Been; devices, roid apps for the past three years I. love building unique applications that push the boundaries of what's possible on mobile (2017-01-28). "Guide: Installing and Running a GNU/Linux Environment on Any Android Device". xda-developers. Retrieved 2019-11-21.
  7. "Standalone Toolchains | Android NDK". Android Developers. Retrieved 2019-11-20.
  8. "README - platform/external/toybox - Git at Google". android.googlesource.com. Retrieved 2019-11-20.
  9. "README - platform/external/toybox - Git at Google". android.googlesource.com. Retrieved 2019-11-20.
  10. comments, 15 May 2018 Paul Bailey Feed 178up 5. "Termux turns Android into a Linux development environment". Opensource.com. Retrieved 2019-11-21.
  11. "UserLAnd, a Turnkey Linux in Your Pocket | Linux Journal". www.linuxjournal.com. Retrieved 2019-11-20.
  12. To, Mayank Sharma How. "How to install Linux on an Android phone". TechRadar. Retrieved 2019-11-20.
  13. "Android 9 Release Notes". Android Open Source Project. Retrieved 2019-11-20.
  14. "Android 10 Release Notes". Android Open Source Project. Retrieved 2019-11-20.
  15. "Installing Linux on an Android Phone". Red Hat Developer. 2017-03-16. Retrieved 2019-11-20.
  16. "Partition Layout". Android Open Source Project. Retrieved 2019-11-20.
  17. "Android 9 Release Notes". Android Open Source Project. Retrieved 2019-11-20.
  18. "Security-Enhanced Linux in Android". Android Open Source Project. Retrieved 2019-11-20.
  19. "Apt-Get Install failing - Udisks2 Permission Denied error leads to lots of DPKG error · Issue #992 · CypherpunkArmory/UserLAnd". GitHub. Retrieved 2019-11-20.
  20. "[Full Tutorial💻] Install Parrot OS On Android". AndroPalac.com. 2019-10-09. Retrieved 2019-11-20.
  21. "How can I change MAC address on Android devices without Root?". ResearchGate. Retrieved 2019-11-20.
  22. "Android 9 Release Notes". Android Open Source Project. Retrieved 2019-11-20.
  23. "Differences from Linux - Termux Wiki". wiki.termux.com. Retrieved 2019-11-20.
  24. "Ubuntu Manpage: PRoot - chroot, mount --bind, and binfmt_misc without privilege/setup". manpages.ubuntu.com. Retrieved 2019-11-20.
  25. "Debian -- Details of package proot in sid". packages.debian.org. Retrieved 2019-11-20.
  26. "udev - ArchWiki". wiki.archlinux.org. Retrieved 2019-11-20.
  27. "System and kernel security". Android Open Source Project. Retrieved 2019-11-21.
  28. "Does Android really use the same kernel as Linux?". Unix & Linux Stack Exchange. Retrieved 2019-11-21.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.