Container-based operating system control method

By decompressing the target startup image in the container and using the root file system of the host system, the operating system is automatically started, solving the problem of cumbersome manual operations by users and improving the startup efficiency.

CN118963846AActive Publication Date: 2024-11-15SIENGINE TECH CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202411452988.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2024-11-15
Estimated Expiration
2044-10-17

AI Technical Summary

Technical Problem

In the prior art, users need to manually operate container management tools to start the operating system, which is cumbersome and time-consuming, and lacks an automated solution.

Method used

The boot loader decompresses the target boot image to the memory block device, starts the kernel, and uses the root file system of the host system to achieve automatic startup of the target operating system in the container, including setting up a shared partition for shutdown and restart instructions, and daemon monitoring Synchronize with file system and other steps.

Benefits of technology

It realizes the startup of the user-insensitive operating system in the container, simplifies user operations, reduces startup time, and improves efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118963846A_ABST
    Figure CN118963846A_ABST
Patent Text Reader

Abstract

The invention provides a container-based operating system control method, which comprises the following steps that: a boot loader decompresses a target startup mirror image to a memory block device and starts a kernel, a native startup mirror image comprises the kernel and a root file system of a native operating system, and the target startup mirror image comprises the kernel and a root file system of a host system; the kernel starts a root file system of the host system from the memory block device so as to start the host system; the host system starts the root file system of the container to achieve starting of the target operating system in the container, the root file system of the container comprises the configuration file of the container and the root file system of the target operating system, and the root file system of the target operating system is obtained by modifying the root file system of the native operating system. By means of the method and device, starting of the operating system in the container can be achieved under the condition that a user does not feel feeling, so that user operation is simplified, and consumed time is shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of operating systems, and in particular to a container-based operating system control method. Background Art

[0002] In today's era of rapid development of digitalization and cloud computing, container technology has become an important means of application deployment and management. Containers provide a lightweight, efficient and flexible environment for the operation of operating systems.

[0003] Although traditional virtual machine technology can realize the isolated operation of the operating system, it has disadvantages such as high resource consumption and slow startup speed. In contrast, container technology utilizes the kernel characteristics of the operating system and realizes the efficient coexistence of multiple containers on the same host by sharing the host kernel.

[0004] However, current solutions require users to manually operate container management tools to start the operating system in the container, which is cumbersome and time-consuming for users. Summary of the invention

[0005] The present application provides a container-based operating system control method, which can realize the startup of the operating system in the container without the user noticing.

[0006] In a first aspect, an embodiment of the present application provides a container-based operating system control method, the container-based operating system control method comprising: The boot loader decompresses the target boot image to a memory block device and starts the kernel, wherein the native boot image includes the kernel and the root file system of the native operating system, and the target boot image includes the kernel and the root file system of the host system; The kernel starts the root file system of the host system from the memory block device to start the host system; The host system starts the root file system of the container to start the target operating system in the container, wherein the root file system of the container includes the configuration file of the container and the root file system of the target operating system, and the root file system of the target operating system is modified based on the root file system of the native operating system.

[0007] Further, in one embodiment, the native operating system and the target operating system are Android systems; After the host system starts the root file system of the container to start the target operating system in the container, the method further includes: After receiving the shutdown request, the target operating system writes a shutdown instruction to the shared partition; After the host system reads the shutdown command from the shared partition, it sends the shutdown command to the kernel.

[0008] Further, in one embodiment, the native operating system and the target operating system are Android systems; After the host system starts the root file system of the container to start the target operating system in the container, the method further includes: After receiving the restart request, the target operating system writes a restart instruction to the shared partition; After the host system reads the restart instruction from the shared partition, it sends the restart instruction to the kernel.

[0009] Furthermore, in one embodiment, the host system continuously monitors the instructions in the shared partition through a daemon process.

[0010] Furthermore, in one embodiment, after the host system starts the root file system of the container to start the target operating system in the container, the method further includes: Before the host system issues a shutdown command or a restart command to the kernel, it performs a file system synchronization operation.

[0011] Furthermore, in one embodiment, before the step of the host system starting the root file system of the container to start the target operating system in the container, the step further includes: The host system sets the partition where the root file system of the container is located to a readable and writable state, detects the state of the hardware resources in the configuration file of the container, and when there are hardware resources in an abnormal state, modifies the configuration file of the container to allocate the hardware resources in a normal state to the container.

[0012] Furthermore, in one embodiment, after the host system starts the root file system of the container to start the target operating system in the container, the method further includes: The host system sets the partition where the container's root file system is located to read-only status.

[0013] Furthermore, in one embodiment, before the step of the kernel starting the root file system of the host system from the memory block device to realize the starting of the host system, the step further includes: The kernel sets the startup path of the initialization program to the memory block device through the kernel command line parameters.

[0014] Furthermore, in one embodiment, compared with the root file system of the native operating system, the root file system of the target operating system deletes commands that the container has no permission to execute and commands that the host system depends on to start.

[0015] Further, in one embodiment, the commands that the container is not authorized to execute include WIFI configuration commands; The commands that the host system depends on for startup include temporary file system mounting commands.

[0016] In this application, the boot loader decompresses the target boot image to the memory block device and starts the kernel, wherein the native boot image contains the kernel and the root file system of the native operating system, and the target boot image contains the kernel and the root file system of the host system; the kernel starts the root file system of the host system from the memory block device to start the host system; the host system starts the root file system of the container to start the target operating system in the container, wherein the root file system of the container contains the configuration file of the container and the root file system of the target operating system, and the root file system of the target operating system is modified based on the root file system of the native operating system. Through this application, the startup of the operating system in the container can be realized without the user's feeling, thereby simplifying the user operation and reducing time consumption. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 The figure is a flowchart of a container-based operating system control method in one embodiment of the present application. DETAILED DESCRIPTION

[0018] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0019] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0020] In a first aspect, an embodiment of the present application provides a container-based operating system control method.

[0021] Figure 1 A schematic flow chart of a container-based operating system control method in an embodiment of the present application is shown.

[0022] Reference Figure 1 In one embodiment, the container-based operating system control method includes the following steps: S11, the boot loader decompresses the target boot image to a memory block device and starts the kernel, wherein the native boot image includes the kernel and the root file system of the native operating system, and the target boot image includes the kernel and the root file system of the host system; S12, the kernel starts the root file system of the host system from the memory block device to realize the startup of the host system; S13. The host system starts the root file system of the container to start the target operating system in the container, wherein the root file system of the container includes a configuration file of the container and a root file system of the target operating system, and the root file system of the target operating system is modified based on the root file system of the native operating system.

[0023] Containers need to run on the host system and rely on the resources and basic environment provided by the host system. Containers share the host's kernel with the host system. Containers can use the host system's CPU, memory, network, storage and other hardware resources, but these resources are managed and allocated by the host system. Containers have their own independent file system view, process space, and network configuration, which ensures that applications in the container will not interfere with each other or have a direct impact on the host system.

[0024] The host system's root file system needs to be placed in a disk partition for execution. Since the disk partition takes a long time to create during the system startup process, it cannot meet the host system's requirement to start as quickly as possible. A memory block device is a concept similar to a block storage device such as a disk that is simulated in memory. A memory block device can be used as an ordinary disk partition to achieve fast mounting and startup of the host system's root file system.

[0025] Extract the kernel and the root file system of the native operating system from the native boot image, build the root file system of the host system, package it with the kernel to form a target boot image, replace the native boot image with the target boot image, set the decompression path of the boot image to the memory block device in the boot loader, and set the startup path of the initialization program to the memory block device in the kernel. In this way, after the device is powered on, the boot loader decompresses the target boot image, starts the kernel, and the kernel starts the root file system of the host system, thereby automatically and quickly starting the host system and providing resources and basic environment for container operation.

[0026] In order to ensure the normal startup of the operating system in the container, the root file system of the native operating system and the configuration file of the container cannot be directly packaged to form the root file system of the container. It is necessary to first make corresponding modifications to the root file system of the native operating system to obtain the root file system of the target operating system, and then package the root file system of the native operating system and the configuration file of the container to form the root file system of the container. After packaging and compression, the root file system of the container can obtain the container image, and the startup command of the root file system of the container is placed in the self-starting script of the host system, so as to automatically start the root file system of the container during the startup process of the host system to realize the startup of the target operating system in the container.

[0027] The original startup process is: the device is powered on, the boot loader starts the kernel, the kernel starts the root file system of the native operating system, and the native operating system is started. The improved startup process is: the device is powered on, the boot loader starts the kernel, the kernel starts the root file system of the host system, and the host system starts the root file system of the container to start the target operating system in the container. For the user, they only need to perform the power-on operation and wait for the operating system to start, and the waiting time does not increase significantly. Therefore, through this embodiment, the operating system can be started in the container without the user noticing, thereby simplifying the user operation and reducing time consumption.

[0028] Optionally, a simplified Linux system is built as the host system using the buildroot framework. Buildroot is a powerful framework for building embedded Linux systems. It allows users to select the required software packages, kernel configurations, file system types, etc. according to specific needs. It integrates and automates the complex steps of building embedded Linux systems, greatly reducing the difficulty of building, and can generate suitable systems for various common processor architectures.

[0029] Optionally, the host system's root file system is formatted as ext4. Ext4 is a widely used and mature file system format that is compatible with most Linux distributions and kernel versions, reducing possible compatibility issues. After long-term use and optimization, ext4 has performed well in data integrity and error recovery, reducing the risk of data loss and system failure, and providing a guarantee for the stable operation of the container. For general read and write operations, ext4 can provide good performance, ensuring that applications in the container can quickly access and store data, support larger files and file systems, and adapt to the large amount of data that may be generated in the container.

[0030] Optionally, the native operating system and the target operating system are Android systems. Android systems are open source mobile operating systems based on the Linux kernel, with a large number of applications covering various types and functions, which users can easily download and install according to their needs, and can run on many different brands and models of devices. Manufacturers and developers can deeply customize them to meet the needs of different user groups and markets.

[0031] In the Android system, after receiving a shutdown request or a restart request, the native logic is to directly send a shutdown command or a restart command to the kernel to implement the shutdown or restart operation of the device. However, when the Android system is running in a container, the Android system cannot directly send a shutdown command or a restart command to the kernel and will be interrupted.

[0032] Further, in one embodiment, the native operating system and the target operating system are Android systems; After the host system starts the root file system of the container to start the target operating system in the container, the method further includes: After receiving the shutdown request, the target operating system writes a shutdown instruction to the shared partition; After the host system reads the shutdown command from the shared partition, it sends the shutdown command to the kernel.

[0033] In this embodiment, the shared partition is a disk partition visible to both the host system and the container, and serves as a communication bridge between the two, so that the shutdown command can be passed from the target operating system to the host system, and then from the host system to the kernel, thereby implementing the shutdown operation of the device.

[0034] Further, in one embodiment, the native operating system and the target operating system are Android systems; After the host system starts the root file system of the container to start the target operating system in the container, the method further includes: After receiving the restart request, the target operating system writes a restart instruction to the shared partition; After the host system reads the restart instruction from the shared partition, it sends the restart instruction to the kernel.

[0035] In this embodiment, the shared partition is a disk partition visible to both the host system and the container, and serves as a communication bridge between the two, so that the restart instruction can be passed from the target operating system to the host system, and then from the host system to the kernel to implement the restart operation of the device.

[0036] Furthermore, in one embodiment, the host system continuously monitors the instructions in the shared partition through a daemon process.

[0037] In this embodiment, the host system can detect new instructions in real time through the daemon process and respond quickly, reducing the delay in instruction acquisition and not being affected by other temporary factors, ensuring the stability of instruction acquisition. The daemon process runs in a continuous but low resource consumption manner and does not consume a large amount of system resources every time an instruction needs to be acquired. Compared with the periodic polling method, unnecessary waste of resources is avoided.

[0038] In Linux systems, you can use the systemctl command or related initialization scripts to manage and control the daemon process, including starting, stopping, restarting, and viewing its status.

[0039] Furthermore, in one embodiment, after the host system starts the root file system of the container to start the target operating system in the container, the method further includes: Before the host system issues a shutdown command or a restart command to the kernel, it performs a file system synchronization operation.

[0040] In this embodiment, the host system performs file system synchronization operations to force cached data in the memory to be written to the disk before shutting down or restarting, thereby ensuring data integrity and consistency, thereby avoiding data loss and file system damage.

[0041] Furthermore, in one embodiment, before the step of the host system starting the root file system of the container to start the target operating system in the container, the step further includes: The host system sets the partition where the root file system of the container is located to a readable and writable state, detects the state of the hardware resources in the configuration file of the container, and when there are hardware resources in an abnormal state, modifies the configuration file of the container to allocate the hardware resources in a normal state to the container.

[0042] In the related art, containers usually use static configuration files. When there are hardware resources in an abnormal state in the configuration file of the container, if the host system starts the root file system of the container, the hardware resources in the abnormal state will be allocated to the container, causing the container to fail to start.

[0043] In this embodiment, before starting the root file system of the container, the host system first sets the partition where the root file system of the container is located to a readable and writable state, reads the configuration file of the container, detects whether the status of the hardware resources is normal, replaces the hardware resources in the abnormal state with the hardware resources in the normal state, and realizes dynamic update of the configuration file, thereby avoiding the problem of container startup failure caused by abnormal hardware resource status.

[0044] Furthermore, in one embodiment, after the host system starts the root file system of the container to start the target operating system in the container, the method further includes: The host system sets the partition where the container's root file system is located to read-only status.

[0045] In this embodiment, after starting the root file system of the container, the host system sets the partition where the root file system of the container is located to a read-only state, thereby ensuring the consistency and stability of the root file system of the container and avoiding system crashes or unpredictable behaviors caused by erroneous modifications.

[0046] Furthermore, in one embodiment, before the step of the kernel starting the root file system of the host system from the memory block device to realize the starting of the host system, the step further includes: The kernel sets the startup path of the initialization program to the memory block device through the kernel command line parameters.

[0047] Through this embodiment, after each startup of the kernel, the startup path of the initialization program is set to the memory block device through the kernel command line parameters, which is more flexible than directly modifying the startup code, that is, hard-coding the startup path in the code.

[0048] Furthermore, in one embodiment, compared with the root file system of the native operating system, the root file system of the target operating system deletes commands that the container has no permission to execute and commands that the host system depends on to start.

[0049] Specifically, in a container environment, due to its isolation and security design principles, there are some commands that the container has no permission to execute. If these commands are retained in the root file system of the target operating system, the target operating system will fail to start in the container. The host system startup depends on a series of key commands, which have been pre-executed during the host system startup process. If these commands are retained in the root file system of the target operating system, resource conflicts will occur, causing the target operating system to fail to start in the container. Therefore, compared with the root file system of the native operating system, the root file system of the target operating system needs to delete the commands that the container has no permission to execute and the commands that the host system startup depends on to ensure that the target operating system starts normally in the container.

[0050] Optionally, the command to delete the root file system of the target operating system compared to the root file system of the native operating system can be implemented through a configuration file of the container, a root file system of the host system, a self-starting script of the host system, etc.

[0051] Further, in one embodiment, the commands that the container is not authorized to execute include WIFI configuration commands; The commands that the host system depends on for startup include the temporary file system (TMPFS) mount command.

[0052] It should be noted that the serial numbers of the above-mentioned embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.

[0053] The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices. The terms "first", "second" and "third" are used to distinguish different objects, etc., and do not represent a sequence, nor do they limit "first", "second" and "third" to different types.

[0054] In the description of the embodiments of the present application, "exemplary", "for example" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary", "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary", "for example" or "for example" is intended to present related concepts in a specific way.

[0055] In the description of the embodiments of the present application, unless otherwise specified, “ / ” means or, for example, A / B can mean A or B; the “and / or” in the text is merely a description of the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, “multiple” refers to two or more than two.

[0056] In some processes described in the embodiments of the present application, multiple operations or steps that appear in a specific order are included, but it should be understood that these operations or steps may not be executed in the order in which they appear in the embodiments of the present application or in parallel, and the sequence number of the operation is only used to distinguish the different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed in sequence or in parallel, and these operations or steps may be combined.

[0057] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD) as described above, and includes a number of instructions for a terminal device to execute the methods described in each embodiment of the present application.

[0058] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A container-based operating system control method, characterized in that: The container-based operating system control method includes: The boot loader decompresses the target boot image to a memory block device and starts the kernel, wherein the native boot image includes the kernel and the root file system of the native operating system, and the target boot image includes the kernel and the root file system of the host system; The kernel starts the root file system of the host system from the memory block device to start the host system; The host system starts the root file system of the container to start the target operating system in the container, wherein the root file system of the container includes the configuration file of the container and the root file system of the target operating system, and the root file system of the target operating system is modified based on the root file system of the native operating system.

2. The container-based operating system control method according to claim 1, characterized in that: The native and target operating systems are Android; After the host system starts the root file system of the container to start the target operating system in the container, the method further includes: After receiving the shutdown request, the target operating system writes a shutdown instruction to the shared partition; After the host system reads the shutdown command from the shared partition, it sends the shutdown command to the kernel.

3. The container-based operating system control method according to claim 1, characterized in that: The native and target operating systems are Android; After the host system starts the root file system of the container to start the target operating system in the container, the method further includes: After receiving the restart request, the target operating system writes a restart instruction to the shared partition; After the host system reads the restart instruction from the shared partition, it sends the restart instruction to the kernel.

4. The container-based operating system control method according to claim 2 or 3, characterized in that: The host system continuously listens to the instructions in the shared partition through a daemon process.

5. The container-based operating system control method according to claim 2 or 3, characterized in that: After the host system starts the root file system of the container to start the target operating system in the container, the method further includes: Before the host system issues a shutdown command or a restart command to the kernel, it performs a file system synchronization operation.

6. The container-based operating system control method according to claim 1, characterized in that: Before the host system starts the root file system of the container to start the target operating system in the container, the method further includes: The host system sets the partition where the root file system of the container is located to a readable and writable state, detects the state of the hardware resources in the configuration file of the container, and when there are hardware resources in an abnormal state, modifies the configuration file of the container to allocate the hardware resources in a normal state to the container.

7. The container-based operating system control method according to claim 6, characterized in that: After the host system starts the root file system of the container to start the target operating system in the container, the method further includes: The host system sets the partition where the container's root file system is located to read-only status.

8. The container-based operating system control method according to claim 1, characterized in that: Before the step of the kernel starting the root file system of the host system from the memory block device to start the host system, the step further includes: The kernel sets the startup path of the initialization program to the memory block device through the kernel command line parameters.

9. The container-based operating system control method according to claim 1, characterized in that: Compared with the root file system of the native operating system, the root file system of the target operating system deletes commands that the container has no permission to execute and commands that the host system depends on to start.

10. The container-based operating system control method according to claim 9, characterized in that: The commands that the container has no permission to execute include WIFI configuration commands; The commands that the host system depends on for startup include temporary file system mounting commands.

Citation Information

Patent Citations

  • Docker based method for realizing operation system of redundant exchanger

    CN105718302A

  • Multi-system starting method and device, storage medium and program product

    CN113467848A

  • Quick identification interaction method based on shared data memory

    CN115016895A

  • Virtualized computing power providing method and system

    CN115167985A

  • Container with application running effect consistent with host machine

    CN115543549A