Readable and writable mounting startup method, device, storage medium and electronic device

Through the OverlayFS joint file system, the read-only and read-write file systems are merged, which solves the problem that some files in the read-only file system require writable permissions, achieves a balance between data security and startup performance, avoids file copying in memory, and reduces the cost of System startup time.

CN114756296BActive Publication Date: 2024-10-22SPREADTRUM COMMUNICATION (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210411712.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-19
Publication Date
2024-10-22
Estimated Expiration
2042-04-19

AI Technical Summary

Technical Problem

In a read-only file system, some files such as configuration files and log files require writable permissions, which causes the device to be loaded into memory after powering on. Data is lost after power failure, affecting system startup performance and occupying memory space.

Method used

Using the OverlayFS joint file system, the read-only file system and the read-write file system are merged. Write operations are automatically mapped to the user directory through OverlayFS to avoid copying files in the memory, and static information files are parsed to obtain mounts when the system starts. Information, execute the read-only directory union file system mount command.

Benefits of technology

It can meet the reading and writing requirements of the file system without affecting the system security, avoids the impact on the system startup performance, and reduces the occupation of memory space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114756296B_ABST
    Figure CN114756296B_ABST
Patent Text Reader

Abstract

The embodiment of the present application proposes a read-write mount startup method, device, storage medium and electronic device, the method comprising: parsing a preset static information file to obtain mount information, executing a read-only directory joint file system OverlayFS mount command according to the mount information and mounting the partition to be mounted at a specified mount point; running a read-only check program to complete the mount. The method utilizes the system native characteristics and OverlayFS functions to enable the presented file system to meet the read-write requirements, while ensuring data security and avoiding the impact on the system startup performance.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The embodiments of the present application relate to the field of system management technology, and in particular to a readable and writable mount startup method, device, storage medium and electronic device. [Background technology]

[0002] In embedded devices, the file system is a system that organizes and allocates the space of file storage devices, is responsible for file storage, and protects and retrieves stored files. It is mainly responsible for creating files for users, storing, reading, modifying, and dumping files, and controlling file access and deletion. According to different read and write permissions, the file system can be divided into a read-only file system and a read-write file system. The files of the read-only file system can only be read but not modified, while the files of the read-write file system can be read and modified. In order to ensure that important data is not tampered with, the read-only file system is usually mounted on the partition to limit the read and write permissions of the operating system. However, there are some files in the read-only file system, such as configuration files, log files, and some soft link files stored in the / var directory, which require write permissions during system startup to save real-time system data. The general processing method is to load the read-only files into the memory after the system starts, and modify these files in the memory. However, after the device loses power, the data in the memory will be lost and needs to be reloaded after the second startup. If the file occupies a large space, it will also affect the boot performance, increase the system startup time and cause memory space waste.

[0003] Therefore, it is an urgent problem for technical personnel in this field to provide a technical solution that can not only ensure user permissions and data security, but also save the need to move files in memory and avoid affecting startup performance. [Summary of the invention]

[0004] The embodiment of the present application provides a readable and writable mount startup method to achieve a file system that not only meets the read and write requirements, but also ensures data security, avoids the impact on the startup performance, and the robustness of the entire file system.

[0005] In the first aspect, an embodiment of the present application provides a read-write mount startup method, which is applied to an electronic device, including: after the system starts, parsing a preset static information file to obtain mount information, executing a read-only directory union file system OverlayFS mount command according to the mount information, and mounting the partition to be mounted at a specified mount point; running a read-only check program to perform a read-only check on the required read-write partition, and if it is determined that the required read-write partition is in a read-only state, completing the mount according to the system default configuration.

[0006] The beneficial effect of the first aspect is that the method utilizes the system native characteristics and OverlayFS functions to enable the presented file system to meet the reading and writing requirements while ensuring data security and avoiding the impact on the system startup performance.

[0007] In one possible implementation, executing a read-only directory joint file system OverlayFS mount command according to the mount information includes: mounting the original data directory of the read-only file system in the electronic device as a read-only partition, and defining it as a lower file system; mounting a readable and writable partition in the electronic device, and creating a user directory corresponding to the original data directory in the readable and writable partition, and defining it as an upper file system; and merging the lower file system and the upper file system through OverlayFS so that write operations on the original data directory are automatically mapped to the user directory.

[0008] In a possible implementation, before the step of running the read-only check program to perform a read-only check on the required read-write partition, it also includes: running a preset mount point check program to check whether the partition to be mounted is mounted successfully, and if not, remounting it according to the preset mount configuration information.

[0009] In a possible implementation, when the electronic device adopts busybox or sysvinit startup mode, the preset mount point check program is a preset mount point check script; when the electronic device adopts systemd startup mode, the preset mount point check program is a preset mount point check service.

[0010] In a possible implementation, the preset mount point check program provides a mount point directory interface, a source directory interface, and a target directory interface required for the remount, as well as a mount check interface, a size check interface, and a reset interface.

[0011] In a possible implementation, the generation process of the preset static information file includes: the compiler parses the preset default configuration file and the preset device difference configuration file to obtain the compilation variable values ​​of the predefined compilation variables; the compiler calls the preset first compilation rule file, fills the system partition mount point combination relationship according to the preset first compilation rule file and the compilation variable values, generates a static information file software package, and installs the static information file software package into the root file system to obtain the preset static information file, wherein the preset static information file integrates the creation mount point command of the additional file system partition and the read-only directory OverlayFS mount command.

[0012] In a possible implementation, the generation process of the preset mount point check program and the preset mount configuration information includes: the compiler parses the preset default configuration file and the preset device difference configuration file to obtain the compilation variable values ​​of the predefined compilation variables; the compiler calls the preset second compilation rule file, and according to the preset second compilation rule file and the compilation variable value, installs the preset mount point check program, the startup service declared in the compilation variable, and the preset mount configuration information required for the startup service into the root file system.

[0013] In a possible implementation, the filling of the system partition mount point combination relationship according to the preset first compilation rule file and the compilation variable value includes: dividing the granularity of the filling process according to four aspects: startup mode, hardware device parameters, storage device type, and file system type.

[0014] In a possible implementation, the predefined compilation variables include wildcards and universal variables. Before the compiler parses a preset default configuration file and a preset device difference configuration file to obtain the compilation variable values ​​of the predefined compilation variables, it also includes: the compiler redefines the wildcards and the universal variables according to the system characteristics of the electronic device.

[0015] In the second aspect, an embodiment of the present application provides a read-write mount startup device, which is applied to electronic devices, including: a partition mount module, which is used to parse a preset static information file to obtain mount information after the system is started, execute a read-only directory union file system OverlayFS mount command according to the mount information, and mount the partition to be mounted at a specified mount point; a read-only check module, which is used to run a read-only check program to perform a read-only check on the required read-write partition. If it is determined that the required read-write partition is in a read-only state, the mount is completed according to the system default configuration.

[0016] In one possible implementation, the partition mounting module includes a joint mounting submodule, which is used to execute a read-only directory joint file system OverlayFS mount command according to the mounting information, and the joint mounting submodule includes: a read-only partition unit, which is used to mount the original data directory of the read-only file system in the electronic device as a read-only partition, and define it as a lower file system; a read-write partition unit, which is used to mount a readable and writable partition in the electronic device, and create a user directory corresponding to the original data directory in the readable and writable partition, and define it as an upper file system; a fusion processing unit, which is used to merge the lower file system and the upper file system through OverlayFS, so that the write operation of the original data directory is automatically mapped to the user directory.

[0017] In a possible implementation, the device further includes: a mount check module, which is used to run a preset mount point check program to check whether the partition to be mounted is mounted successfully, and if not, remount it according to preset mount configuration information.

[0018] In a possible implementation, the device also includes: a first software compilation module, used to generate the preset static information file; the first software compilation module includes: a first acquisition module, used by the compiler to parse a preset default configuration file and a preset device difference configuration file to obtain the compilation variable values ​​of the predefined compilation variables; a second acquisition module, used by the compiler to call the preset first compilation rule file, fill the system partition mount point combination relationship according to the preset first compilation rule file and the compilation variable value, generate a static information file software package, install the static information file software package into the root file system, and obtain the preset static information file, wherein the preset static information file integrates the creation mount point command of the additional file system partition and the read-only directory OverlayFS mount command.

[0019] In a possible implementation, the device also includes: a second software compilation module, used to generate the preset mount point check program and the preset mount configuration information; the second software compilation module includes: a first acquisition module, used for the compiler to parse the preset default configuration file and the preset device difference configuration file to obtain the compilation variable value of the predefined compilation variable; a third acquisition module, used for the compiler to call the preset second compilation rule file, and according to the preset second compilation rule file and the compilation variable value, install the preset mount point check program, the startup service declared in the compilation variable value, and the preset mount configuration information required for the startup service into the root file system.

[0020] In a third aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor; and at least one memory communicatively connected to the processor, wherein: the memory stores program instructions executable by the processor, and the processor calls the program instructions to execute the method provided in the first aspect.

[0021] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions enable the computer to execute the method provided in the first aspect.

[0022] It should be understood that the second to fourth aspects of the embodiments of the present application are consistent with the technical solutions of the first aspect of the embodiments of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here.

Brief Description of the Drawings

[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0024] Figure 1 A flowchart of a readable and writable mount startup method provided in an embodiment of the present application;

[0025] Figure 2 A flowchart of a method for executing a read-only directory OverlayFS mount command provided in an embodiment of the present application;

[0026] Figure 3 A schematic diagram of an OverlayFS directory structure provided in an embodiment of the present application;

[0027] Figure 4 A flowchart of another readable and writable mount startup method provided in an embodiment of the present application;

[0028] Figure 5 A flowchart of a software compilation method provided in an embodiment of the present application;

[0029] Figure 6 A flowchart of another software compilation method provided in an embodiment of the present application;

[0030] Figure 7 A schematic diagram of the structure of a readable and writable mount startup device provided in an embodiment of the present application;

[0031] Figure 8 A schematic structural diagram of an electronic device is provided for an embodiment of the present application. [Specific implementation method]

[0032] In order to better understand the technical solution of this specification, the embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0033] It should be clear that the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.

[0034] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit this specification. The singular forms of "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0035] To facilitate those skilled in the art to understand the technical solution of the present application, the technical terms involved in the present application are explained below.

[0036] (1) Embedded devices: These are used in scenarios with high requirements for reliability and real-time performance. They are customized devices that can flexibly tailor software and hardware modules according to user needs (function, reliability, cost, size, power consumption, environment, etc.).

[0037] (2) OverlayFS: A joint file system provided by the Linux operating system that merges two different file paths, one as a read-only underlying file system and the other as a readable and writable upper file system. In the final object presented, the upper file content takes precedence, and objects mounted through OverlayFS can be marked so that the marked content appears to be deleted while the actual content remains unchanged.

[0038] (3) / etc / fstab: This is a file used to store static information about the file system. When the system starts, the system automatically reads information from this file and automatically mounts the file system specified in this file to the specified directory.

[0039] (4) Read-only file system: In order to protect the existing data content in the partition from being destroyed, Linux usually uses read-only mode when mounting the file system to achieve the data protection function.

[0040] (5) Yocto: is an open source software ecosystem that provides templates, tools, and methods to help developers create customized Linux-based systems designed for embedded products.

[0041] (6) bb / bbappend: is a compilation control file that defines where to obtain the software source code, how to configure, how to compile, how to install it to the file system, etc.

[0042] In the existing related technologies, with the rise of artificial intelligence Internet of Things AIOT, more and more embedded devices are integrated into people's daily lives. With the increase in the number of users and types of devices, more requirements are put forward for device stability and data security. In order to protect some important data of the Linux system, the Linux system usually uses a read-only file system to ensure the stability of key data and ensure that it is not tampered with. However, some files in the read-only file system, such as configuration files, log files, and some soft link files stored in the / var directory, require writable permissions when the Linux system is started. Therefore, the usual practice is to load the files that require read and write permissions into the memory after the system is turned on, and modify these files in the memory. However, after a power failure, the data in the memory will be lost and need to be reloaded after the second boot. If the file is particularly large, it will also affect the boot performance and increase the system startup time.

[0043] In order to solve the problem that some directories and files in a read-only file system require readable and writable permissions and the slow startup problem caused by general solutions, the embodiment of the present application provides a readable and writable mount startup method based on a containerization solution that is readable and writable but does not change the security policy, thereby ensuring user permissions and data security, while also eliminating the need to move files in memory and avoiding the impact on startup performance.

[0044] Figure 1 A flowchart of a readable and writable mount startup method provided in an embodiment of the present application is provided. The readable and writable mount startup method can be applied to electronic devices, such as Figure 1 As shown, the readable and writable mount startup method may include:

[0045] Step 101: After the system is started, the preset static information file is parsed to obtain the mount information, the read-only directory union file system OverlayFS mount command is executed according to the mount information, and the partition to be mounted is mounted at the specified mount point.

[0046] It should be noted that when the system starts, the system will automatically read information from the static information file and automatically mount the file system specified in the static information file to the specified directory. Based on the feature of automatically completing partition mounting according to the static information file configuration after the system starts, the preset static information file here is the static information file that is incrementally modified during the software compilation phase, and integrates the read-only directory OverlayFS mount command.

[0047] Among them, OverlayFS is a joint file system that can overlay the contents of multiple directories on another directory. OverlayFS does not directly involve the disk space structure. It looks like merging files from multiple directories into the same directory according to rules, and there is no requirement for the specific file system type used by multiple source directories. Even if the file system types of each source directory are different, it does not affect the use. Using the OverlayFS function, the read-only underlying file system and the read-write upper file system can be merged. The final file system meets both read and write requirements and ensures data security.

[0048] Step 102: Run the system's read-only check program to perform a read-only check on the required read-write partition. If it is determined that the required read-write partition is in a read-only state, the mounting is completed according to the system default configuration.

[0049] It should be noted that the system's read-only check program is a native program in the system startup process. The read-only check program is used to check whether the required read-write partition is in a read-only state. If it is in a read-only state, the mount is completed according to the system default configuration to ensure that the system can start and run normally.

[0050] The readable and writable mount startup method provided in the embodiment of the present application utilizes the system's native characteristics and OverlayFS functions to enable the presented file system to meet both the read and write requirements and ensure data security, while also eliminating the need to move files in memory and avoiding the impact on system startup performance.

[0051] Furthermore, Figure 2 A flowchart of a method for executing a read-only directory OverlayFS mount command provided in an embodiment of the present application is shown as follows: Figure 2 As shown, based on the containerization solution, executing the read-only directory union file system OverlayFS mount command according to the mount information may include:

[0052] Step 201: Mounting the original data directory of the read-only file system in the electronic device as a read-only partition and defining it as a lower-layer file system;

[0053] Step 202: Mounting a readable and writable partition in the electronic device, and creating a user directory corresponding to the original data directory in the readable and writable partition, and defining it as an upper-layer file system;

[0054] Step 203: The lower file system and the upper file system are integrated through OverlayFS, so that the write operation to the original data directory is automatically mapped to the user directory.

[0055] It should be noted that the above-used read-only directory OverlayFS mounting method, under the premise of maintaining the uniqueness and read-only attribute of the original data copy in the read-only file system partition, creates a readable and writable directory structure of the upper file system upperdir in the readable and writable partition, such as the userdata partition, and uses the joint mounting system of OverlayFS to realize the merger of the read-only file system partition directory and the readable and writable partition directory, which serve as the read-only underlying file system and the readable and writable upper file system respectively. In the final presented object, the upper file content takes precedence, and the object mounted by OverlayFS can be marked so that the marked content is deleted, while the actual content remains unchanged, thereby ensuring user permissions and data security; at the same time, it also saves the need to move files in memory, avoiding the impact on startup performance.

[0056] Exemplarily, the files that require read and write permissions in the read-only file system are processed as follows during mounting: the original data / var / lib, / var / cache, / var / spool, / home, etc. of the read-only file system in the electronic device are mapped to a read-only partition or mounted as a read-only partition, a userdata partition, i.e., a readable and writable partition for data files, is mounted in the electronic device, and user directories, i.e., / mnt / userdata / var / lib, mnt / userdata / var / cache, mnt / userdata / var / spool, mnt / userdata / home, etc., are established in the userdata partition, and the OverlayFS file system merges the original / var / lib, / var / cache, / var / spool, / home with the / mnt / userdata / var / lib, mnt / userdata / var / cache, mnt / userdata / var / spool, mnt / userdata / home to complete the mounting of the fused mount point. For the final file system or user, the directory structure after the file fusion in the operating system is not perceived, and the access to directories such as / var / lib, / var / cache, / var / spool, and / home is still maintained. At this time, all system or user write operations will be automatically mapped to / mnt / userdata / var / lib, mnt / userdata / var / cache, mnt / userdata / var / spool, and mnt / userdata / home, so that the originally read-only lower-level file system becomes a read-write file system, thereby avoiding the destruction of the system's native access path. When it is necessary to restore the userdata partition of an electronic device, it is only necessary to delete the / mnt / userdata / var / lib, mnt / userdata / var / cache, mnt / userdata / var / spool, and mnt / userdata / home directories, which can ensure the rapid recovery of the userdata partition and retain the contents of the original read-only partition.

[0057] It is understandable that other methods based on Linux characteristics using OverlayFS to achieve readable and writable mounting of readable partitions are also possible, and the embodiments of the present application are not limited to the method of using OverlayFS.

[0058] Figure 3 A schematic diagram of an OverlayFS directory structure provided in an embodiment of the present application is shown in FIG. Figure 3As shown, the root file system tmpfs provides read-only original shared data. At this time, the electronic device can read the shared data in read-only mode, and the root file system is defined as the lower file system (Lower Dir). Then, the space with full read and write permissions for the electronic device is defined as the upper file system (Upper Dir). Finally, it is mounted as an OverlayFS mount object (Merge Dir) that is only visible to the user through OverlayFS. At this time, the electronic device has full read and write permissions to the OverlayFS mount object, and the OverlayFS mount object has the characteristics of upper file system priority: (1) If the same data can be obtained in the upper file system, the upper file system is actually accessed. If there is no data in the upper file system, the lower file system is actually accessed; (2) New data is stored in the upper file system. If the lower file system updates the same data, according to the principle of (1), the lower file system will not be actually accessed; (3) When deleting data, a corresponding mark is made in the upper file system, and the marked content is reflected as deleted in the joint mount object, while the actual lower file system content remains unchanged. This allows users to read and write the only read-only data without increasing the space occupied by the original data and generating additional security issues. At the same time, there is no need to copy, compress and decompress the original read-only data in the readable and writable area, thereby avoiding the impact on system performance. At the same time, since the method is based on the native characteristics of the Linux system, no new components or processes are introduced to increase the startup time.

[0059] It is understandable that the objects applicable to this embodiment include, but are not limited to, terminal devices, Linux devices, and servers that support the read-only file system file read-write mount startup method. For devices such as terminal devices that use the liunx system to start, the read-only directory OverlayFS mounting method proposed in the embodiment of the present application is applicable, which can meet the writable requirements for read-only files and will not reduce system performance. At the same time, the storage space requirements for the multi-user environment of the device are reduced, the new user environment can be quickly copied, and the consistency of access to the original shared data is maintained. For devices such as servers that use the Linux system, the read-only directory OverlayFS mounting method proposed in the embodiment of the present application can also be derived into a unique read-only data security read-write solution for multiple users to the server. The deployment of this method on the server not only maintains the uniqueness and data security of the original shared data, minimizes space occupancy, and does not affect the write access of each user to the data. At the same time, the characteristics of the container sharing the host kernel space ensure the consistency of the deployment service in the container and the deployment outside the container.

[0060] In some embodiments, after the OverlayFS solution is adopted, in order to ensure that the partitions that need to be mounted can be mounted successfully, a mount point check step can be added.

[0061] Figure 4 A flowchart of another readable and writable mount startup method provided in an embodiment of the present application is shown as follows: Figure 4 As shown, in Figure 1 Based on the embodiment shown, step 301 may be further included between step 101 and step 102:

[0062] Step 301: Run a preset mount point check program to check whether the partition to be mounted is mounted successfully. If not, remount it according to preset mount configuration information.

[0063] It should be noted that in order to ensure that all partitions that need to be mounted are mounted successfully, a mount point check program is added to the system startup process to check whether the partitions that need to be mounted are mounted successfully. After adopting the OverlayFS mounting method, if the mounting fails due to an abnormality in the OverlayFS solution, the system can remount the partition through the preset mount point check program and the preset mount configuration information without affecting the normal startup of the system. By presetting the mount point check program in the system, after booting, it checks whether the mount point in the static information file is successfully mounted, ensuring the robustness of the entire file system.

[0064] In some embodiments, the system startup method of the electronic device may include busybox / sysvinit / systemd and other startup methods. The startup process of each startup method is introduced below.

[0065] Exemplarily, for the busybox / sysvinit startup mode of the Linux system, the system's read-write mount startup steps may include: (1) First, after the Linux system is started, it will parse the / etc / fstab static information file to obtain the mount information. According to the obtained mount information, the system will execute the mount-a command one by one to mount the partitions required to be mounted in the fstab static information file at the specified mount point; (2) The startup process will call the newly added checkmount.sh mount point check script, and check again whether the partition to be mounted is successfully mounted according to the uni-mount.conf mount configuration information generated during compilation. If not mounted, the checkmount.sh mount point check script will remount the unmounted partition according to the uni-mount.conf mount configuration information to ensure that the required partition is correctly mounted; (3) After the check is completed, the busybox / sysvinit startup service will execute the native read-only-rootfs-hook.sh read-only check script to perform a read-only check. If it is found that the required read-write partition is read-only, the mount will be completed according to the system default configuration to ensure that the system can start and run normally.

[0066] Exemplarily, for the systemd startup method of the Linux system, the system's read-write mount startup steps include: (1) First, after the Linux system is started, it will parse the / etc / fstab static information file to obtain the mount information, and the systemd-fstab-generator program will complete the generation of the mount information units required for systemd startup based on the obtained mount information. Then, systemd will complete the mounting of the partitions required to be mounted in the fstab static information file at the specified mount point based on these mount information units; (2) Since the systemd startup has the function of parallel execution of program services, after the above process is completed, systemd runs the checkmount-*.service mount point check service generated during compilation to check again whether the partitions to be mounted are successfully mounted. If it is not mounted, then checkmount-*.service will remount the unmounted partition according to the mount configuration information generated during compilation to ensure that the required partition is mounted correctly. (3) After the check is completed, the systemd startup service will execute the native var-volatile-*.service read-only check service to perform a read-only check. If it is found that the required read-write partition is read-only, then the mount will be completed according to the system default configuration to ensure that the system can start and run normally.

[0067] It should be noted that the read-write mount startup method mentioned in this application has good compatibility with different startup methods of busybox / sysvinit / systemd.

[0068] In some embodiments, the preset mount point check program in step 301 may provide the mount point directory interface, source directory interface and target directory interface required for the remount, as well as provide a mount check interface, a size check interface and a reset interface.

[0069] It should be noted that the preset mount point check program can provide the mount point directory interface part-dir, source directory interface source-dir and target directory interface dest-dir for bind-mount re-mounting, and mount source-dir to dest-dir in bind mode, where part-dir is the mount point of the partition where source-dir is located. Since the bind option requires the two directories to be consistent at the beginning; therefore, it is necessary to copy the contents of dest-dir to source-dir during the first mount, and after the copy is completed, a hidden flag file will be created under part-dir to avoid duplicate copying. The preset mount point check program can also provide a check mount interface to check whether the mount of each entry in the / etc / fstab static information file is successful; the preset mount point check program can also provide a checksize size check interface to check whether the available size of the file system in the non-storage partition matches the partition size; the preset mount point check program can also provide a reset interface for the factory reset service to call. After erasing userdata, some initialization work needs to be performed according to the item entries in the uni-mount.conf mount configuration information.

[0070] In some embodiments, the Yocto open source community requires that software functions can be shelf-based and packaged, that is, they can be released and applied separately in software packages. However, the current solution of mounting read-only file system partitions as read-write is that the modification of software is invasive modification or unexpandable code, which cannot meet the community's shelf-based and packaged requirements.

[0071] In order to solve the problem that software modifications in the read-write mount startup method of the read-only file system cannot be shelf-based and packaged, the embodiment of the present application is based on the feature that partition mounting is automatically completed according to the / etc / fstab static information file configuration after the Linux system is started, and the content of the / etc / fstab static information file is incrementally modified during the software compilation stage.

[0072] Figure 5 A flowchart of a software compilation method provided in an embodiment of the present application is used to generate a preset static information file. The method may include:

[0073] Step 401: the compiler parses a preset default configuration file and a preset device difference configuration file to obtain a compilation variable value of a predefined compilation variable;

[0074] Step 402: the compiler calls a preset first compilation rule file, fills in the system partition mount point combination relationship according to the preset first compilation rule file and the compilation variable value, generates a static information file software package, and installs the static information file software package into the root file system to obtain a preset static information file, wherein the preset static information file integrates a create mount point command for an additional file system partition and a read-only directory OverlayFS mount command.

[0075] It should be noted that after starting the compilation, the compiler parses the preset default configuration file unisoc-storage.inc and the device difference configuration file machine.conf to obtain the compilation variable values ​​of the compilation variables pre-defined in the project. Then the compiler calls the preset first compilation rule file base-files.bbapend corresponding to the static information file fstab, fills in the system partition mount point combination relationship according to the compilation variable values ​​obtained by the above compiler analysis, and generates the final fstab static information file software package defined by the project and installs it into the rootfs root file system.

[0076] Furthermore, before the step of running the read-only check program to perform a read-only check on the required read-write partition, it also includes: running a preset mount point check program to check whether the partition to be mounted is mounted successfully. If it is not mounted successfully, then remounting it according to the preset mount configuration information, it is also necessary to generate a preset mount point check program and preset mount configuration information.

[0077] Figure 6 A flowchart of another software compilation method provided in an embodiment of the present application is used to generate a preset mount point check program and preset mount configuration information. Figure 5 Based on the illustrated embodiment, the method may further include:

[0078] Step 403: The compiler calls a preset second compilation rule file, and installs a preset mount point checker, the startup service declared in the compilation variable value, and the preset mount configuration information required for the startup service into the root file system according to the preset second compilation rule file and the compilation variable value.

[0079] It should be noted that, since the step of the compiler parsing the preset default configuration file and the preset device difference configuration file to obtain the compilation variable values ​​of the pre-defined compilation variables has been executed in step 401, the compiler calls the second compilation rule file non-volatile-mounts.bb, and according to the above compilation variable values, the preset mount point check program used for checking and the startup service (busybox\sysvinit\systemd) declared in the compilation variable and the preset mount configuration information file required for the generated startup service are installed into the rootfs root file system, and the entire compilation process is completed.

[0080] It should be noted that the fields included in the fstab static information file are: file systems mount partition, dir mount point, type mount device or partition file system type, options use parameters when mounting, dump whether to back up, pass file system check order, and the above 6 fields constitute the complete content of fstab. Therefore, during the compilation process, the compilation process provided by the embodiment of the present application will eventually generate an fstab static information file software package filled with the required mount field information according to the preset parameters of the 6 fields of different electronic devices. At the same time, the fields required for OverlayFS mounting are also filled in the fstab static information file as required. Since kernel usually supports OverlayFS mounting, the linux system can realize partition mounting according to the / etc / fstab static information file without additional processes. It is understandable that other methods of filling the fstab static information file fields are also possible, and the embodiment of the present application does not limit the method of filling the static information file fields.

[0081] Further, in order to realize the shelf-based compilation process and compilation products, the embodiment of the present application defines the following compilation variables: BASE_FS_TYPE is the system type of the root file system, such as BASE_FS_TYPE? ? ="ext4"; PARTITION_LABEL is the name of the non-volatile storage partition with the file system, such as PARTITION_LABEL? ="userdata"; BASE_FS_TYPE_* is the file system type of the non-volatile storage partition with the file system, such as BASE_FS_TYPE_USERDATA? ="ext4"; PARTITION_MOUNTPOINT_* is the mount point of the non-volatile storage partition with the file system, such as PARTITION_MOUNTPOINT_userdata? =" / mnt / userdata"; PARTITION_MOUNTOPTION_* is the mount option of the non-volatile storage partition with the file system, such as PARTITION_MOUNTOPTION_userdata? =" / mnt / userdata"; = ""; NON_VOLATILE_OVERLAY is the overlay correspondence between non-volatile storage and the rootfs root file system directory. The above variables can be overwritten in the device difference configuration machine.conf, thereby realizing a combination of multiple relationships and adapting to multiple non-volatile storage devices and file system types.

[0082] It can be understood that wildcards and universal variables are added to the fstab static information file generation process defined in the embodiment of the present application for shelving. The wildcards and universal variables can be redefined according to the characteristics of the electronic device, thereby achieving the universality of the base-files.bbapend file, satisfying multiple startup methods of busybox / sysvinit / systemd, and realizing the shelving requirements of the software.

[0083] Furthermore, the embodiment of the present application constrains the process of completing the required field filling for the final fstab static information file, and can divide the granularity of the filling process into four aspects: startup mode, hardware device parameters, storage device type, and file system type, and abstract the configuration parameters of each aspect as much as possible, so that the compilation filling process can complete the fstab static information file requirements under various combinations by modifying the agreed parameters, thereby realizing the shelf-based generation of the fstab static information file. It is understandable that other granular configuration methods for implementing the fstab static information file field filling are also possible, and the embodiment of the present application does not limit the granular configuration method.

[0084] Furthermore, the embodiment of the present application can generate a fstab static information file for a specific device based on the Yocto compilation platform through the base-files.bbappend file, create mount points for additional file system partitions such as userdata / prodnv, and integrate the read-only directory OverlayFS mount command into the fstab static information file, thereby realizing packaging. Based on the definition of Yocto's MACHINE_ARCH and the definition of the package generation file bb, the bbappend compilation control file is used to incrementally modify base-files.bb to avoid intrusive modifications, thereby realizing the packaging of configuration information files.

[0085] The embodiment of the present application is based on the feature that partition mounting is automatically completed according to the / etc / fstab static information file configuration after the Linux system is started. The content of the / etc / fstab static information file is incrementally modified during the software compilation stage, and the fstab static information file of a specific device is generated using the added base-files.bbapend file, thereby achieving shelf requirements and packaging.

[0086] The embodiment of the present application also provides a readable and writable mounting startup device, Figure 7 A schematic diagram of a readable and writable mounting boot device provided in an embodiment of the present application is applied to electronic devices, such as Figure 7 As shown, the device includes: a partition mounting module 501 and a read-only check module 502; wherein, the partition mounting module 501 is used to parse the preset static information file to obtain the mounting information after the system is started, execute the read-only directory union file system OverlayFS mount command according to the mount information, and mount the partition to be mounted at the specified mount point; the read-only check module 502 is used to run the read-only check program to perform a read-only check on the required read-write partition, and if it is determined that the required read-write partition is in a read-only state, the mounting is completed according to the system default configuration.

[0087] In one possible implementation, the partition mounting module 501 includes a joint mounting submodule, which is used to execute a read-only directory joint file system OverlayFS mount command according to the mounting information, and the joint mounting submodule includes: a read-only partition unit, which is used to mount the original data directory of the read-only file system in the electronic device as a read-only partition, and define it as a lower file system; a read-write partition unit, which is used to mount a readable and writable partition in the electronic device, and create a user directory corresponding to the original data directory in the readable and writable partition, and define it as an upper file system; a fusion processing unit, which is used to merge the lower file system and the upper file system through OverlayFS, so that the write operation of the original data directory is automatically mapped to the user directory.

[0088] In a possible implementation, the device further includes: a mount check module, which is used to run a preset mount point check program to check whether the partition to be mounted is mounted successfully, and if not, remount it according to preset mount configuration information.

[0089] In a possible implementation, the device also includes: a first software compilation module, used to generate the preset static information file; the first software compilation module includes: a first acquisition module, used by the compiler to parse a preset default configuration file and a preset device difference configuration file to obtain the compilation variable values ​​of the predefined compilation variables; a second acquisition module, used by the compiler to call the preset first compilation rule file, fill the system partition mount point combination relationship according to the preset first compilation rule file and the compilation variable value, generate a static information file software package, install the static information file software package into the root file system, and obtain the preset static information file, wherein the preset static information file integrates the creation mount point command of the additional file system partition and the read-only directory OverlayFS mount command.

[0090] In a possible implementation, the device also includes: a second software compilation module, used to generate a preset mount point check program and preset mount configuration information; the second software compilation module includes: a first acquisition module, used for the compiler to parse a preset default configuration file and a preset device difference configuration file to obtain a compilation variable value of a predefined compilation variable; a third acquisition module, used for the compiler to call a preset second compilation rule file, and according to the preset second compilation rule file and the compilation variable value, install the preset mount point check program, the startup service declared in the compilation variable value, and the preset mount configuration information required for the startup service into the root file system.

[0091] Figure 7 The readable and writable mounting boot device provided in the embodiment shown can be used to execute the present invention. Figure 1 The technical solution of the method embodiment shown, its implementation principle and technical effects can be further referred to the relevant description in the method embodiment.

[0092] The present application also provides an electronic device, Figure 8 A schematic diagram of the structure of an electronic device is provided for an embodiment of the present application. The electronic device may be a device that uses the read-write mount startup method provided by the embodiment of the present application, such as Figure 8 As shown, the electronic device may include: at least one processor; and at least one memory in communication with the processor, wherein: the memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the following Figure 1-Figure 6 The illustrated embodiment provides a read-write mount startup method.

[0093] For example, Figure 8 1 shows a schematic diagram of the structure of the electronic device 100. Figure 8 As shown, the electronic device 100 may include components such as a processor 110, a memory 120, and a peripheral device 130. It is understood that the structure of the electronic device 100 illustrated in the embodiment of the present application does not constitute a limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware. These components may communicate via one or more buses 140 or signal lines, and the bus may be divided into an address bus, a data bus, a control bus, etc.

[0094] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). Among them, different processing units may be independent devices or integrated into one or more processors. Among them, the controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions. A memory may also be set in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a high-speed cache memory. The memory may store instructions or data that the processor 110 has just used or circulated. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. Repeated access is avoided, the waiting time of the processor 110 is reduced, and the efficiency of the system is improved.

[0095] The peripheral device 130 may include a display, an output component, an input component, and the like.

[0096] The memory 120 is used to store the codes and data included in the system of the electronic device 100, such as the codes corresponding to the application program and the operating system. The memory 120 may include a memory, an external memory, and a register. The memory may be used to store the codes corresponding to the operating system and the running application program. The external memory and the register may be used to store the data generated by the running application program during operation. The external memory may also be used to store the codes corresponding to other non-running applications. The processor 110 may transfer the codes or data stored in the external memory to the memory to implement the functions defined by the codes. For example, the processor 110 may transfer the codes corresponding to the operating system to the memory when the electronic device 100 is turned on, so as to implement various functions of the operating system on the electronic device 100; the processor 110 may also transfer the codes corresponding to other applications to the memory according to user needs, so as to implement various functions of the application on the electronic device 100.

[0097] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, wherein the computer instructions enable the computer to execute the present specification. Figure 1-Figure 6 The illustrated embodiment provides a read-write mount startup method.

[0098] The above-mentioned computer-readable storage medium can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM) or flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, a device or a device or used in combination with it.

[0099] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0100] The program code embodied on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wire, optical cable, radio frequency (RF), etc., or any suitable combination of the foregoing.

[0101] Computer program code for performing the operations of the present specification may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0102] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0103] In the description of the embodiments of the present invention, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of this specification. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0104] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this specification, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0105] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of this specification includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of this specification belong.

[0106] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0107] It should be noted that the terminals involved in the embodiments of the present application may include but are not limited to personal computers (PCs), personal digital assistants (PDAs), wireless handheld devices, tablet computers, mobile phones, MP3 players, MP4 players, etc.

[0108] In the several embodiments provided in this specification, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0109] In addition, each functional unit in each embodiment of this specification may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0110] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the method described in each embodiment of this specification. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes.

[0111] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.

Claims

1. A read-write mount startup method, characterized in that: Used in electronic equipment, including: After the system is started, the preset static information file is parsed to obtain the mount information, and the read-only directory union file system OverlayFS mount command is executed according to the mount information, and the partition to be mounted is mounted at the specified mount point; Run a read-only check program to perform a read-only check on the required read-write partition. If it is determined that the required read-write partition is in a read-only state, complete the mounting according to the system default configuration; The generation process of the preset static information file includes: The compiler parses a preset default configuration file and a preset device difference configuration file to obtain a compilation variable value of a predefined compilation variable; The compiler calls a preset first compilation rule file, fills in the system partition mount point combination relationship according to the preset first compilation rule file and the compilation variable value, generates a static information file software package, and installs the static information file software package into the root file system to obtain a preset static information file, wherein the preset static information file integrates a create mount point command for an additional file system partition and a read-only directory OverlayFS mount command.

2. The method according to claim 1, characterized in that Executing a read-only directory union file system OverlayFS mount command according to the mount information includes: Mounting the original data directory of the read-only file system in the electronic device as a read-only partition and defining it as a lower-level file system; Mounting a readable and writable partition in the electronic device, creating a user directory corresponding to the original data directory in the readable and writable partition, and defining it as an upper-layer file system; The lower file system and the upper file system are integrated through OverlayFS so that the write operation to the original data directory is automatically mapped to the user directory.

3. The method according to claim 1, characterized in that Before the step of running the read-only check program to perform a read-only check on the required read-write partition, the method further includes: Run the preset mount point check program to check whether the partition to be mounted is mounted successfully. If it is not mounted successfully, remount it according to the preset mount configuration information.

4. The method according to claim 3, characterized in that When the electronic device adopts busybox or sysvinit startup mode, the preset mount point check program is a preset mount point check script; when the electronic device adopts systemd startup mode, the preset mount point check program is a preset mount point check service.

5. The method according to claim 3, characterized in that: The preset mount point check program provides the mount point directory interface, source directory interface and target directory interface required for the remount, as well as a mount check interface, a size check interface and a reset interface.

6. The method according to claim 3, characterized in that The generation process of the preset mount point check program and the preset mount configuration information includes: The compiler parses a preset default configuration file and a preset device difference configuration file to obtain a compilation variable value of a predefined compilation variable; The compiler calls a preset second compilation rule file, and according to the preset second compilation rule file and the compilation variable value, installs a preset mount point check program, the startup service declared in the compilation variable, and the preset mount configuration information required for the startup service into the root file system.

7. The method according to claim 1, characterized in that The filling of the system partition mount point combination relationship according to the preset first compilation rule file and the compilation variable value includes: The filling process is divided into granularities according to four aspects: startup mode, hardware device parameters, storage device type, and file system type.

8. The method according to claim 1 or 6, characterized in that: The predefined compilation variables include wildcards and general variables. Before the compiler parses a preset default configuration file and a preset device difference configuration file to obtain compilation variable values ​​of the predefined compilation variables, the step further includes: The compiler redefines the wildcard and the general variable according to the system characteristics of the electronic device.

9. A read-write mount startup device, characterized in that: Used in electronic equipment, including: The partition mounting module is used to parse the preset static information file to obtain mounting information after the system is started, execute the OverlayFS mount command of the read-only directory union file system according to the mount information, and mount the partition to be mounted at the specified mount point; A read-only check module, used to run a read-only check program to perform a read-only check on the required read-write partition, and if it is determined that the required read-write partition is in a read-only state, the mounting is completed according to the system default configuration; The device further includes: a first software compiling module, configured to generate the preset static information file; the first software compiling module includes: A first acquisition module, used for the compiler to parse a preset default configuration file and a preset device difference configuration file to obtain a compilation variable value of a predefined compilation variable; The second acquisition module is used for the compiler to call the preset first compilation rule file, fill in the system partition mount point combination relationship according to the preset first compilation rule file and the compilation variable value, generate a static information file software package, install the static information file software package into the root file system, and obtain the preset static information file, wherein the preset static information file integrates the creation mount point command of the additional file system partition and the read-only directory OverlayFS mount command.

10. The device according to claim 9, characterized in that The partition mounting module includes a joint mounting submodule, and the joint mounting submodule is used to execute a read-only directory joint file system OverlayFS mounting command according to the mounting information. The joint mounting submodule includes: A read-only partition unit, used to mount the original data directory of the read-only file system in the electronic device as a read-only partition and define it as a lower file system; A read-write partition unit, used for mounting a read-write partition in the electronic device, creating a user directory corresponding to the original data directory in the read-write partition, and defining it as an upper file system; The fusion processing unit is used to fuse the lower file system and the upper file system through OverlayFS so that the write operation to the original data directory is automatically mapped to the user directory.

11. The device according to claim 9, characterized in that Also includes: The mount check module is used to run a preset mount point check program to check whether the partition to be mounted is mounted successfully. If it is not mounted successfully, it is remounted according to the preset mount configuration information.

12. The device according to claim 11, characterized in that Also includes: A second software compilation module, used to generate a preset mount point check program and preset mount configuration information; The second software compilation module includes: A first acquisition module, used for the compiler to parse a preset default configuration file and a preset device difference configuration file to obtain a compilation variable value of a predefined compilation variable; The third acquisition module is used for the compiler to call the preset second compilation rule file, and according to the preset second compilation rule file and the compilation variable value, install the preset mount point check program, the startup service declared in the compilation variable value, and the preset mount configuration information required for the startup service into the root file system.

13. An electronic device, characterized in that: include: at least one processor; and at least one memory in communication with the processor, wherein: The memory stores program instructions executable by the processor, and the processor can execute the method according to any one of claims 1 to 8 by calling the program instructions.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions enable the computer to execute the method according to any one of claims 1 to 8.