OS virtualization and emulation on Android

Last updated

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.

Contents

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 a rooted guest OS, it has a greater advantage over emulators as it can 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, it can install actual (for example) Ubuntu packages, as it does 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 emulations 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 use of extensions. Aside from 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 a 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 accurate information. However, this requires that the compatibility layer or any predefined software it uses (ex. Docker) to have access to many types of system- and device-related information. This can either be done via Toybox or programing language libraries that Android apps can be made from (e.g., Java, C#). However, starting with Android 8, many new security restrictions have been placed on apps; due to these restrictions, some API libraries/classes are no longer available or have been replaced by more restrictive API libraries/classes. [13]

One of the known limitations that was implemented is that apps can only natively access only their own 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 limitation, guest OSes running on, emulation, platform virtualization, or compatibility apps are no longer allowed to access files outside of their own SD card Sandbox.

The 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 directory's existence. Versions of Android before 9 allowed terminal apps to view Android's root "/" directory (although not allowing modifications or execution). [16] [17]

SELinux

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

Here are some known applications and packages that are unable to run:

  • 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)

Here are some commands that do not work, due to SELinux:

ADB, PRoot, $HOME and $PREFIX usage

Because all Android apps run in a non-privileged container space, 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. Each of these is used for a different purpose. ADB is used for the emulation of a 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 are well known, prominent packages, applications, or commands, including 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 including a modified Linux kernel

Because Android utilizes 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 the application's 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 well known configuration and system files that are not in Android include:

See also

Related Research Articles

<span class="mw-page-title-main">Linux distribution</span> Operating system based on the Linux kernel

A Linux distribution is an operating system made from a software collection that includes the Linux kernel and often a package management system. Linux users usually obtain their operating system by downloading one of the Linux distributions, which are available for a wide variety of systems ranging from embedded devices and personal computers to powerful supercomputers.

In computing, cross-platform software is computer software that is designed to work in several computing platforms. Some cross-platform software requires a separate build for each platform, but some can be directly run on any platform without special preparation, being written in an interpreted language or compiled to portable bytecode for which the interpreters or run-time packages are common or standard components of all supported platforms.

In software engineering, a compatibility layer is an interface that allows binaries for a legacy or foreign system to run on a host system. This translates system calls for the foreign system into native system calls for the host system. With some libraries for the foreign system, this will often be sufficient to run foreign binaries on the host system. A hardware compatibility layer consists of tools that allow hardware emulation.

chroot is an operation on Unix and Unix-like operating systems that changes the apparent root directory for the current running process and its children. A program that is run in such a modified environment cannot name files outside the designated directory tree. The term "chroot" may refer to the chroot(2) system call or the chroot(8) wrapper program. The modified environment is called a chroot jail.

Virtual DOS machines (VDM) refer to a technology that allows running 16-bit/32-bit DOS and 16-bit Windows programs when there is already another operating system running and controlling the hardware.

OS-level virtualization is an operating system (OS) virtualization paradigm in which the kernel allows the existence of multiple isolated user space instances, called containers, zones, virtual private servers (OpenVZ), partitions, virtual environments (VEs), virtual kernels, or jails. Such instances may look like real computers from the point of view of programs running in them. A computer program running on an ordinary operating system can see all resources of that computer. However, programs running inside of a container can only see the container's contents and devices assigned to the container.

Application virtualization is a software technology that encapsulates computer programs from the underlying operating system on which they are executed. A fully virtualized application is not installed in the traditional sense, although it is still executed as if it were. The application behaves at runtime like it is directly interfacing with the original operating system and all the resources managed by it, but can be isolated or sandboxed to varying degrees.

The following is a timeline of virtualization development. In computing, virtualization is the use of a computer to simulate another computer. Through virtualization, a host simulates a guest by exposing virtual hardware devices, which may be done through software or by allowing access to a physical device connected to the machine.

Binary-code compatibility is a property of a computer system, meaning that it can run the same executable code, typically machine code for a general-purpose computer central processing unit (CPU), that another computer system can run. Source-code compatibility, on the other hand, means that recompilation or interpretation is necessary before the program can be run on the compatible system.

In computing, virtualization or virtualisation in British English is the act of creating a virtual version of something at the same abstraction level, including virtual computer hardware platforms, storage devices, and computer network resources.

<span class="mw-page-title-main">Emulator</span> System allowing a device to imitate another

In computing, an emulator is hardware or software that enables one computer system to behave like another computer system. An emulator typically enables the host system to run software or use peripheral devices designed for the guest system. Emulation refers to the ability of a computer program in an electronic device to emulate another program or device.

<span class="mw-page-title-main">Darling (software)</span> Open-source macOS compatibility layer

Darling is a free and open-source macOS compatibility layer for Linux. It duplicates functions of macOS by providing alternative implementations of the libraries and frameworks that macOS programs call. This method of duplication differs from other methods that might also be considered emulation, where macOS programs run in a virtual machine. Darling has been called the counterpart to WINE for running macOS apps.

Cycada is a compatibility layer that aims to allow applications designed for iOS to run unmodified on the Android operating system. The method uses compile-time adaptation to run unmodified code with minimal implementation effort.

<span class="mw-page-title-main">Google App Runtime for Chrome</span> Compatibility layer and sandboxing technology

Android Runtime for Chrome (ARC) is a compatibility layer and sandboxing technology for running Android applications on desktop and laptop computers in an isolated environment. It allows applications to be safely run from a web browser, independent of user operating system, at near-native speeds.

<span class="mw-page-title-main">Windows Subsystem for Linux</span> Compatibility layer for running Linux binary executables natively on Windows

Windows Subsystem for Linux (WSL) is a feature of Microsoft Windows that allows developers to run a Linux environment without the need for a separate virtual machine or dual booting. There are two versions of WSL: WSL 1 and WSL 2. WSL is not available to all Windows 10 users by default. It can be installed either by joining the Windows Insider program or manually via Microsoft Store or Winget.

<span class="mw-page-title-main">HarmonyOS</span> Distributed operating system by Huawei

HarmonyOS (HMOS) is a distributed operating system developed by Huawei for smartphones, tablets, smart TVs, smart watches, personal computers and other smart devices. It has a multi-kernel design with dual frameworks: the operating system selects suitable kernels from the abstraction layer in the case of devices that use diverse resources. The operating system was officially launched by Huawei in August 2019.

<span class="mw-page-title-main">UserLAnd Technologies</span> Compatibility layer mobile app

UserLAnd Technologies is a free and open-source compatibility layer mobile app that allows Linux distributions, computer programs, computer games and numerical computing programs to run on mobile devices without requiring a root account. UserLAnd also provides a program library of popular free and open-source Linux-based programs to which additional programs and different versions of programs can be added.

There are many apps in Android that can run or emulate other operating systems, via utilizing hardware support for platform virtualization technologies, or via terminal emulation. Some of these apps support having more than one emulation/virtual file system for different OS profiles, thus the ability to have or run multiple OS's. Some even have support to run the emulation via a localhost SSH connection (letting remote ssh terminal apps on device access the OS emulation/VM, VNC, and XSDL. If more than one of these apps that support these protocols or technologies are available on the android device, via androids ability to do background tasking the main emulator/VM app on android can be used to launch multiple emulation/vm OS, which the other apps can connect to, thus multiple emulated/VM OS's can run at the same time. However, there are a few emulator or VM apps that require that the android device to be rooted for the app to work, and there are others that do not require such. Some remote terminal access apps also have the ability to access Android's internally implemented Toybox, via device loopback support. Some VM/emulator apps have a fixed set of OS's or applications that can be supported.

<span class="mw-page-title-main">OpenHarmony</span> Family of open-source operating systems based on OpenHarmony

OpenAtom OpenHarmony, or abbreviated as OpenHarmony (OHOS), is a family of open-source distributed operating systems based on HarmonyOS derived from LiteOS, donated the L0-L2 branch source code by Huawei to the OpenAtom Foundation. Similar to HarmonyOS, the open-source distributed operating system is designed with a layered architecture, which consists of four layers from the bottom to the top, i.e., the kernel layer, system service layer, framework layer, and application layer.

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. "VMOS Lets You Run a Virtual Android Machine on your Phone". xda-developers. 2019-08-08. Retrieved 2019-11-20.
  4. 1 2 Doffman, Zak. "Huawei Mate 30: New Google Play Option Is Here". Forbes. Retrieved 2019-11-20.
  5. 1 2 "AnLinux : Run Linux On Android Without Root Access - Apps on Google Play". play.google.com. Retrieved 2019-11-21.
  6. 1 2 Farmer, Braden (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. 1 2 "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.{{cite web}}: CS1 maint: numeric names: authors list (link)
  11. "UserLAnd, a Turnkey Linux in Your Pocket | Linux Journal". www.linuxjournal.com. Retrieved 2019-11-20.
  12. To, Mayank Sharma How (June 2016). "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. Archived from the original on 2019-12-24. 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. 1 2 "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.