Blog

[Samsung DeX] Linux on Galaxy
Blog Oct 18, 2017
135

State-of-the-art smart phones utilize computing power comparable to commodity PCs or laptops in respect to CPU, RAM, storage, and even GPU. As a result, there is an increasing number of smartphone-only users. Nevertheless, power users who generate content still largely rely on traditional PCs and laptops. For example, software developers still find it cumbersome to use smartphones to write code because of the physical limitation of a relatively small screen and the challenge of porting software development environments to the appified (app-based) operating systems commonly used by smartphones.

The small smartphone screen issue can be practically addressed using a Samsung DeX station. Samsung DeX is a comprehensive hardware solution enabling users to use big screens as their smartphone display while allowing the smartphone to charge and cool down simultaneously using integrated fan and charger. Therefore, users can seamlessly harness higher computing power from their devices with DeX mode.

The problem of porting the software development environment to the appified OS has yet been properly addressed. For developers, porting and compatibility are key issues since effectively developing software requires a lot of configuration overhead. Developers are usually restricted to specific compilers and off-the-shelf (COTS) software. Developers also require the freedom to roam through their development spaces to access files and modify their access permissions without the restrictions added by smartphones OSes.

The vision of Linux on Galaxy:

Linux on Galaxy is Samsung's answer to remove the last entry barrier for developers to exclusively use smartphones for all their computing needs. Linux on Galaxy allows smartphone users to run their preferred Linux distribution, such as Ubuntu or CentOS, on their smartphones utilizing the same Linux kernel that powers the Android OS to ensure the best possible performance.

From the user’s perspective, Linux on Galaxy is installed as another app on the smartphone. The Linux on Galaxy app allows users to install one or more Linux distributions on their smartphones. Whenever the user requires a function not typically present in the smartphone OS, they can switch to the Linux on Galaxy app and choose the image they need and run it to have their own Linux OS environment running on the smartphone. This new environment is particularly useful with a big screen, that allows users to create content using their smartphones like the Samsung DeX station. In summary, Linux on Galaxy converts a regular smartphone into a hybrid system that can simultaneously run multiple operating systems.

This new vision provides additional value to Samsung smartphone users. To begin with, it pushes the limit of what’s achievable with the computing resources of their smartphone. Using Linux on Galaxy, users are able to install software available to common Linux distributions. Therefore, setting up a full software development environment, or any general content creation environment per se, becomes possible on their mobile device.

The cost savings of buying a dedicated computer for development tasks will indeed be welcomed by Samsung users. Additionally, the new portable full development environment that can be stowed in user’s pocket and easily carried was enthusiastically welcomed from many of the software developers we introduced this new feature to. This portability is especially valuable to user segments such as students, developers, hackers, IT professionals or the average geek developer that cannot stay away from their development environments while on the go.

Running a full Linux distribution on a Samsung Galaxy smartphone comes with an extra benefit, as commodity PCs and laptops are rarely equipped with the environment sensing and communication capabilities of state-of-the art smartphones. Indeed, a full development environment with access to a gyroscope, magnetometer, accelerometer, full LTE connectivity would be an interesting capability for many developers that is not present on commodity PCs or laptops. In addition, Linux on Android gives a nice and rare opportunity to have native development platform based on the ARM64 architecture instead of the commonx86 architecture. Other ARM64 dev platforms are less attractive to a regular user because they usually come in the form of bare development boards.

A look under the hood:

Linux on Galaxy is designed to make this interaction efficient and seamless to both the Android OS and the guest Linux distribution. The Android OS controls the resources assigned to Linux on Galaxy the same as every other app installed on the phone. Therefore, the main dynamics and functionality of the Android OS remain unchanged.

To achieve maximum efficiency for the guest Linux distribution, the Linux on Galaxy app runs directly on top of the Linux kernel of the Android OS. Therefore, it avoids any unnecessary performance overhead that results from the common hardware virtualization practice of running two different OS kernels on the same hardware. Linux on Galaxy runs in a separate sandbox, which is different from Android. Sandboxing is achieved by utilizing kernel namespace containers. The sandboxing guarantees both runtime and file system isolation of the guest Linux distribution.

All processes that run inside the guest Linux distribution are spawned in a separate namespace, other than the namespace used by Android. These processes utilize a virtual privileged access inside this namespace container without the ability to access any resource directly managed by the Android OS. Therefore, it cannot threaten the security of Android or any of the other apps installed on the system.

Part of the storage space dedicated to the Linux on Galaxy app is used to mount the virtual file system of the guest Linux distribution, which enjoys full access privilege over that space without the ability to access other file system resources used by Android or any of the other installed apps, which ensures the file system level isolation.

One last question is how to manage the guest Linux distribution display in a dynamic and high performance manner. To achieve this objective, the guest OS uses a memory mapped frame buffer, so there is no need in extra memory copy when delivering rendered pixels to the screen. On the side of Linux on Galaxy app the guest OS display is treated like an off-screen buffer so user can maximize, minimize and move it around just like any other Android app. Keyboard and mouse events are transparently delivered from Android into the guest OS through the Linux on Galaxy app.


Revision history
REVISION HISTORY DATE
First update Oct 18, 2017