A mobile operating system implementation method mixing Linux and AOSP environments
By integrating the Linux root file system into the AOSP system architecture and using bind mounting and soft link technology, the problem of integrating Linux and AOSP on mobile SoC chip devices is solved, achieving rich system capabilities and low performance overhead, and supporting native compatibility with Linux and Android applications.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- KYLIN CORP
- Filing Date
- 2026-03-18
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies for implementing Linux environments on mobile SoC chip devices suffer from problems such as high isolation, large performance overhead, functional limitations, and complex debugging, especially on resource-constrained mobile devices, making it difficult to achieve deep integration and resource sharing between Linux and AOSP.
By directly integrating the Linux root file system into the AOSP system architecture, using bind mounting and soft link technology, a non-isolated hybrid environment is built, supporting native compatibility between Linux non-graphical applications and Android applications, and optimizing permissions and environment variables to achieve file system-level hybrid mounting.
It achieves seamless integration of Linux and AOSP on mobile SoC chip devices, supports rich system capabilities, including Linux AI models and Android application ecosystem, reduces performance overhead, and improves development efficiency and compatibility.
Smart Images

Figure CN122489137A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer operating system technology, and in particular to a method for implementing a mobile operating system that combines Linux and AOSP environments. Background Technology
[0002] Although Linux and AOSP share the Linux kernel, they differ significantly in system architecture and application ecosystem. Due to its mobile-centric design, AOSP has a clear weakness in non-graphical service capabilities compared to Linux. Linux, on the other hand, has a complete system-level service and toolchain, natively supports a rich variety of user-space network services, and boasts a more comprehensive command-line toolchain than AOSP. Its strict access control and security mechanisms are also more suitable for scenarios with high security requirements.
[0003] Hybrid operating system technology is an important component of modern computing, enabling resource sharing and functional expansion by integrating multiple operating system environments on a single device. Technologies for running hybrid operating systems on mobile devices typically include the following approaches: (1) chroot method: Change the root directory through the chroot command to isolate the Linux environment and run it in the Android file system, thereby achieving pseudo-root file system switching, but it still depends on the Android host environment in essence.
[0004] (2) PRoot emulation: Applications such as Termux or UserLAnd use the PRoot tool to simulate chroot behavior, which can run Linux user space without root privileges, but intercepts system calls through process-level emulation.
[0005] (3) Containerization method: such as LXC or Docker container framework to isolate the Linux environment and provide a virtualization layer to support application operation.
[0006] (4) Virtual machine method: Use KVM or similar virtualization to run a full Linux on Android, but requires additional kernel support and resource overhead.
[0007] With the increasing demand for multi-operating system support in mobile devices, the application of Linux environments on Android devices has become a hot topic. However, the existing technologies mentioned above for implementing Linux functionality on mobile SoC chips still lag significantly behind native Linux in terms of user experience, and the main problems include: (1) High isolation but not true integration: The chroot or PRoot method isolates the Linux environment and cannot be deeply integrated with the Android root file system, resulting in inconsistent file system hierarchy and inconvenient resource sharing, especially with low performance under the resource constraints of mobile SoC.
[0008] (2) Performance overhead: Containerization or virtual machine methods introduce additional layers (such as process emulation or virtualization overhead), resulting in high latency and low performance, especially when running high-load applications on mobile SoC chips, and the problem is more prominent on resource-limited mobile devices.
[0009] (3) Functional limitations and debugging complexity: Linux has complete implementation and testing support for the POSIX standard and has a rich command-line toolchain. Existing methods are difficult to directly reuse these capabilities, and permission, SELinux compatibility and environment variable issues are prone to occur during the building and debugging process. Summary of the Invention
[0010] To address the aforementioned issues, this invention provides a method for implementing a mobile operating system that integrates Linux and AOSP environments. By directly integrating the Linux root file system into the AOSP system architecture, a non-isolated hybrid environment is built, supporting compatibility with Linux non-graphical applications and Android applications on mobile SoC chip devices. It natively supports a massive Android application ecosystem while also supporting Linux AI models, Linux user-space network services, and POSIX testing tools. This solves the integration bottlenecks, performance issues, and mobile device compatibility problems existing in the prior art, enabling mobile terminals to have richer system capabilities and meet the needs of more usage scenarios.
[0011] This invention is implemented as follows: This invention provides a method for implementing a mobile operating system in a hybrid Linux and AOSP environment, comprising the following steps: Step S1: Build a basic Linux environment on an ARM PC; Step S2: Analyze and process the Linux and AOSP root directories to achieve compatibility and adaptation between the two directories; Step S3: Build a mixed Linux and AOSP environment.
[0012] Step S1 includes the following steps: Step S11: Use the debootstrap tool to pull a minimal system environment for the arm64 architecture from the Linux source and generate a directory structure that conforms to the FHS. Step S12: Obtain the busybox-static package from the Linux source, and deploy commonly used commands to the / usr / bin directory using the statically linked busybox program provided by the package; Step S13: Use chroot on the PC to enter the rootfs and verify the usability of the Linux environment built in steps S11 and S12 using the POSIX test in ltp.
[0013] Step S2 includes the following steps: Step S21: Compare the AOSP and Linux root directories to find the list of overlapping and different directories in the root directory; Step S22: Create symbolic links for Linux-specific directories and handle overlapping directories; Step S23: Determine that the complete Linux environment will be deployed in the / system / base directory of AOSP.
[0014] In step S21, the Linux-specific directories include / usr, / var, and / tmp, the AOSP-specific directories include / system and / data, and the overlapping directories include / bin and / etc.
[0015] In step S22, the overlapping directories are processed by configuring a symbolic link for AOSP in the / system / bin directory and copying the non-overlapping files in the / etc directory of the Linux environment to the / system / etc directory of AOSP.
[0016] Step S23 involves creating a Linux-specific directory in the AOSP root directory, copying the files in the Linux environment's / etc directory to the AOSP system directory's etc directory using a non-overwrite copy method, and creating corresponding symbolic links in the AOSP root directory.
[0017] Step S3 includes the following steps: Step S31: In the AOSP build system, copy the Linux environment to / system / base and create the corresponding empty directory under the root directory; Step S32: Add a sepolicy rule to the newly added directory and tag it with SELinux; Step S33: Adjust the root partition copy parameters in the system build environment and add the created Linux-specific directories to the exclude list to prevent content conflicts during recovery image copying; Step S34: Add the bind mount command to the init.rc file to mount the Linux directory under / system / base to the corresponding location in the root directory; Step S35: Add the tmpfs mount command to the init.rc file to provide runtime file system support for Linux directories; Step S36: Grant / system / base / usr / bin / Executable permissions are granted to the path and extended to the linker to resolve runtime permission issues; Step S37: Optimize runtime environment variables by adding / usr / bin and / usr / sbin to the PATH environment variable to ensure that Linux commands can be executed directly; Step S38: Grant read and write permissions to the Linux environment, and add a Linux environment configuration service program and service configuration file to the AOSP build system; Step S39: Use Android.mk to build the configuration file to install the Linux environment configuration service program and service configuration file.
[0018] Specifically, step S38 includes the following steps: Step S381: Support overlayfs mounting for the data partition and disable the system's casefold function; Step S382: Write a Linux environment configuration program that is responsible for mounting the overlay of / system / base when the system starts. Step S383: Add the directory creation command to the configuration file corresponding to the Linux environment configuration service, and fix the SELinux tag for the directory; Step S384: Add the service startup command to the configuration file corresponding to the service in the Linux environment, and run the Linux environment configuration program; Step S385: The Linux environment configuration program creates the upperdir and workdir directories required by overlayfs; Step S386: The Linux environment configuration program mounts / system / base as the lowerdir of overlayfs, / data / base / overlay / upperdir as the upperdir of overlayfs, and / data / base / overlay / workdir as the workdir of overlayfs to / system / base in the manner of overlayfs. Step S387: The Linux environment configuration program will re-bind the directories under / system / base that have already been bound to the corresponding locations in the root directory, or replace the bound mounting method with symbolic links, replace the directories related to bound mounting with symbolic links, and remove the bound mounting operations added in init.rc.
[0019] The beneficial effects of this invention are: The mobile operating system implementation method of the hybrid Linux and AOSP environment of the present invention has the following technical advantages compared with methods such as chroot and virtual machines: (1) It achieves true file system-level mixed installation, rather than isolated operation, supports direct access to Linux commands without switching environments, and can be used on mobile SoC chip devices, making the system natively compatible with a large number of Linux non-graphical applications and a huge number of Android applications; (2) By using bind mounting and permission optimization, performance overhead is reduced and zero-copy resource sharing is achieved; (3) Supports AOSP-led startup to avoid startup mechanism conflicts and integrates tools such as gcc / make to improve development efficiency; (4) Lightweight build process with low runtime memory usage, verified on Pixel 6a and RK3568 devices. Attached Figure Description
[0020] Figure 1 This is a schematic diagram of the modified catalog structure for the mixed-use environment according to the present invention; Figure 2 This is a flowchart illustrating the construction process of the Linux and AOSP hybrid environment of this invention. Figure 3 This is a diagram showing the Linux environment read / write structure of the present invention. Detailed Implementation
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Those skilled in the art can make similar extensions without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0022] This invention targets mobile terminal devices. After building a Linux environment on an ARM PC using debootstrap, it compares and analyzes the differences between the Linux and AOSP root directories, uses bind mounting technology or symbolic links, adds executable permissions and environment variables to Linux programs, and grants read and write permissions to relevant directories in the Linux environment. This creates an independent Linux environment within the AOSP environment, thus achieving a non-isolated hybrid Linux and AOSP mobile operating system method. This method meets the requirements of natively supporting a large number of Android applications while also natively supporting Linux user-space network services, as well as rich command-line toolchains and security mechanisms. It also lays the foundation for subsequent support of Linux graphical applications.
[0023] This invention provides a method for implementing a mobile operating system in a hybrid Linux and AOSP environment, comprising the following steps: Step S1: Build a basic Linux environment on an ARM PC.
[0024] Specifically, step S1 includes the following steps: Step S11: Use the debootstrap tool to pull a minimal arm64 architecture system environment from a Linux repository (e.g., the openKylin repository: http: / / archive.build.openkylin.top / openkylin), generating a directory structure that conforms to the FHS (File System Hierarchy Standard). When using debootstrap, specify the architecture as arm64 using `--arch`, add necessary packages such as gcc, make, and libc6-dev using the `--include` option, and remove unnecessary packages such as apt and passwd using the `--exclude` option.
[0025] Step S12: Obtain the busybox-static package from the Linux source. Use the statically linked busybox program provided by this package to deploy commonly used commands to the / usr / bin directory.
[0026] Step S13: Use chroot on the PC to enter the rootfs and verify the usability of the Linux environment built in steps S11 and S12 using the POSIX test in ltp.
[0027] Step S2: Analyze and process the Linux and AOSP root directories to achieve compatibility and adaptation between the two directories.
[0028] Specifically, step S2 includes the following steps: Step S21: As Figure 1 As shown, compare the root directories of AOSP and Linux to find the list of overlapping and different directories in the root directory. For example, Linux-specific directories include / usr, / var, and / tmp, while AOSP-specific directories include / system and / data. Overlapping directories include / bin and / etc.
[0029] Step S22: Create symbolic links for Linux-specific directories, such as / lib -> / usr / lib, / sbin -> / usr / sbin; and handle overlapping directories, such as configuring the AOSP symbolic link / system / bin for the / bin directory, and copying non-overlapping files from the / etc directory in the Linux environment to the AOSP / system / etc directory.
[0030] Step S23: Determine that the complete Linux environment will be deployed in the / system / base directory of AOSP. Create a Linux-only directory in the AOSP root directory. Copy the files in the / etc directory of the Linux environment to the etc directory of the AOSP system directory using a non-overwrite copy method, and create corresponding symbolic links in the AOSP root directory.
[0031] Step S3: Build a mixed Linux and AOSP environment, such as... Figure 2 As shown.
[0032] Specifically, step S3 includes the following steps: Step S31: In the AOSP build system, use the Android.mk build configuration file to copy the Linux environment to / system / base and create the corresponding empty directories under the root directory (such as / usr, / var). Step S32: Add a file_contexts file, add a sepolicy rule for the newly added directory, tag it with SELinux, and reference the file when building the system to resolve SELinux errors when building the image file; Step S33: Adjust the rsync exclude parameter for copying the root partition in the system build environment to add the created Linux-specific directories to the exclude list to prevent content conflicts during recovery image copying; Step S34: Add the bind mount command to the init.rc file. That is, add the bind mount command to the post-fs section of the system / core / rootdir / init.rc file to mount the Linux directory (such as / usr) under / system / base to the corresponding location in the root directory, so as to achieve seamless access. Step S35: Add the tmpfs mount command to the init.rc file, that is, add the tmpfs mount command to the early-init section of the system / core / rootdir / init.rc file to provide runtime file system support for Linux directories such as / dev / shm and / tmp; Step S36: Resolve runtime permission issues by modifying the file system / core / libcutils / fs_config.h and granting permissions to / system / base / usr / bin / Execute permissions for paths such as 00755, AID_ROOT, AID_SHELL, and extend them to the linker (e.g., / lib / ld-linux-aarch64.so.1). Step S37: Optimize runtime environment variables by modifying the bionic / libc / include / paths.h file to add / usr / bin and / usr / sbin to the PATH environment variable to ensure that Linux commands can be executed directly; Step S38: Grant read and write permissions to the Linux environment. Add a Linux environment configuration service program and service configuration file to the AOSP build system. Configure the Linux environment as read and write during system startup through this service. Step S39: Use Android.mk to build the configuration file to install the Linux environment configuration service program and service configuration file.
[0033] Specifically, step S38 includes the following steps, such as... Figure 3 As shown: Step S381: Support overlayFS mounting for the data partition, disable the system's casefold function (external_storage.casefold.enabled), and perform corresponding disabling processing in all places in the system that use external_storage.casefold.enabled to avoid overlay mounting failure; Step S382: Write a Linux environment configuration program, such as / system / bin / setup_linux, which is responsible for mounting the overlay of / system / base when the system starts. Step S383: Add a directory creation command to the post-fs-data section of the configuration file corresponding to the Linux environment configuration service to create the / data / base / overlay directory and fix the SELinux tag of the directory; Step S384: Add the service startup command to the early-boot section of the configuration file corresponding to the Linux environment configuration service, and run the Linux environment configuration program; Step S385: The Linux environment configuration program creates the / data / base / overlay / upperdir directory corresponding to the upperdir and the / data / base / overlay / workdir directory corresponding to the workdir required by overlayfs; Step S386: The Linux environment configuration program mounts / system / base as the lowerdir of overlayfs, / data / base / overlay / upperdir as the upperdir of overlayfs, and / data / base / overlay / workdir as the workdir of overlayfs to / system / base in the manner of overlayfs. Step S387: The Linux environment configuration program will re-bind and mount directories already bound under / system / base (such as / usr) to the corresponding locations in the root directory, enabling read and write access to these directories. Alternatively, symbolic links can be used to replace the bind mounting method, replacing the directories related to bind mounting with symbolic links and removing the bind mounting operations added in the post-fs stage of init.rc.
[0034] This invention proposes a method for directly integrating AOSP and Linux without chroot or container / virtual machine support. It supports building a hybrid operating system on mobile SoC chip devices and natively supports Linux AI models, Linux user-space network services, and POSIX testing tools. The Linux environment is stored in the ` / system / base` directory, and root directory fusion is achieved using bind mounting. Overlayfs enables read / write access to ` / system / base` and the Linux environment directory. Dynamic addition of SELinux tags and permission configuration are supported to ensure the security of the hybrid environment. A minimal Linux environment is built using debootstrap and busybox. The host system improves compatibility of the hybrid environment through dynamic mounting init.rc and environment variable optimization.
[0035] While the present invention discloses preferred embodiments to achieve the above objectives, these are not intended to limit the structural features of the invention. Anyone skilled in the art should know that any easily conceived variations or modifications are possible within the technical spirit of the invention and are covered by the claims of the present invention.
Claims
1. A method for implementing a mobile operating system using a hybrid Linux and AOSP environment, characterized in that, Includes the following steps: Step S1: Build a basic Linux environment on an ARM PC; Step S2: Analyze and process the Linux and AOSP root directories to achieve compatibility and adaptation between the two directories; Step S3: Build a mixed Linux and AOSP environment.
2. The method for implementing a mobile operating system in a hybrid Linux and AOSP environment according to claim 1, characterized in that, Step S1 includes the following steps: Step S11: Use the debootstrap tool to pull a minimal system environment for the arm64 architecture from the Linux source and generate a directory structure that conforms to the FHS. Step S12: Obtain the busybox-static package from the Linux source, and deploy commonly used commands to the / usr / bin directory using the statically linked busybox program provided by the package; Step S13: Use chroot on the PC to enter the rootfs and verify the usability of the Linux environment built in steps S11 and S12 using the POSIX test in ltp.
3. The method for implementing a mobile operating system in a hybrid Linux and AOSP environment according to claim 1, characterized in that, Step S2 includes the following steps: Step S21: Compare the AOSP and Linux root directories to find the list of overlapping and different directories in the root directory; Step S22: Create symbolic links for Linux-specific directories and handle overlapping directories; Step S23: Determine that the complete Linux environment will be deployed in the / system / base directory of AOSP.
4. The method for implementing a mobile operating system in a hybrid Linux and AOSP environment according to claim 3, characterized in that, In step S21, the Linux-specific directories include / usr, / var, and / tmp, the AOSP-specific directories include / system and / data, and the overlapping directories include / bin and / etc.
5. The method for implementing a mobile operating system in a hybrid Linux and AOSP environment according to claim 4, characterized in that, In step S22, the overlapping directories are processed by configuring a symbolic link for AOSP in the / system / bin directory and copying the non-overlapping files in the / etc directory of the Linux environment to the / system / etc directory of AOSP.
6. The method for implementing a mobile operating system in a hybrid Linux and AOSP environment according to claim 5, characterized in that, Step S23 involves creating a Linux-specific directory in the AOSP root directory, copying the files from the Linux environment's / etc directory to the AOSP system directory's etc directory using a non-overwrite copy method, and creating corresponding symbolic links in the AOSP root directory.
7. The method for implementing a mobile operating system in a hybrid Linux and AOSP environment according to claim 1, characterized in that, Step S3 includes the following steps: Step S31: In the AOSP build system, copy the Linux environment to / system / base and create the corresponding empty directory under the root directory; Step S32: Add a sepolicy rule to the newly added directory and tag it with SELinux; Step S33: Adjust the root partition copy parameters in the system build environment and add the created Linux-specific directories to the exclude list to prevent content conflicts during recovery image copying; Step S34: Add the bind mount command to the init.rc file to mount the Linux directory under / system / base to the corresponding location in the root directory; Step S35: Add the tmpfs mount command to the init.rc file to provide runtime file system support for Linux directories; Step S36: Grant / system / base / usr / bin / Executable permissions are granted to the path and extended to the linker to resolve runtime permission issues; Step S37: Optimize runtime environment variables by adding / usr / bin and / usr / sbin to the PATH environment variable to ensure that Linux commands can be executed directly; Step S38: Grant read and write permissions to the Linux environment, and add a Linux environment configuration service program and service configuration file to the AOSP build system; Step S39: Use Android.mk to build the configuration file to install the Linux environment configuration service program and service configuration file.
8. The method for implementing a mobile operating system in a hybrid Linux and AOSP environment according to claim 7, characterized in that, Step S38 specifically includes the following steps: Step S381: Support overlayfs mounting for the data partition and disable the system's casefold function; Step S382: Write a Linux environment configuration program that is responsible for mounting the overlay of / system / base when the system starts. Step S383: Add the directory creation command to the configuration file corresponding to the Linux environment configuration service, and fix the SELinux tag for the directory; Step S384: Add the service startup command to the configuration file corresponding to the service in the Linux environment, and run the Linux environment configuration program; Step S385: The Linux environment configuration program creates the upperdir and workdir directories required by overlayfs; Step S386: The Linux environment configuration program mounts / system / base as the lowerdir of overlayfs, / data / base / overlay / upperdir as the upperdir of overlayfs, and / data / base / overlay / workdir as the workdir of overlayfs to / system / base in the manner of overlayfs. Step S387: The Linux environment configuration program will re-bind the directories under / system / base that have already been bound to the corresponding locations in the root directory, or replace the bound mounting method with symbolic links, replace the directories related to bound mounting with symbolic links, and remove the bound mounting operations added in init.rc.