CN109445861B - System starting method, device, computer device and storage medium - Google Patents

System starting method, device, computer device and storage medium Download PDF

Info

Publication number
CN109445861B
CN109445861B CN201811218034.2A CN201811218034A CN109445861B CN 109445861 B CN109445861 B CN 109445861B CN 201811218034 A CN201811218034 A CN 201811218034A CN 109445861 B CN109445861 B CN 109445861B
Authority
CN
China
Prior art keywords
partition
file system
mounting
directory
computer device
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811218034.2A
Other languages
Chinese (zh)
Other versions
CN109445861A (en
Inventor
仵小勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Onething Technology Co Ltd
Original Assignee
Shenzhen Onething Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Onething Technology Co Ltd filed Critical Shenzhen Onething Technology Co Ltd
Priority to CN201811218034.2A priority Critical patent/CN109445861B/en
Publication of CN109445861A publication Critical patent/CN109445861A/en
Application granted granted Critical
Publication of CN109445861B publication Critical patent/CN109445861B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4406Loading of operating system

Abstract

The invention provides a system starting method, which comprises the following steps: judging whether the Linux system starts an init process or not; when the Linux system starts an init process, mounting a first partition to which a root file system in the computer device belongs and a second partition, which is not the first partition, in the computer device to a combined directory for starting the file system through a combined file system technology, wherein the mounting attribute of the first partition is read-only, and the mounting attribute of the second partition is writable; and switching the root directory of the Linux system into the combined directory, and acquiring the root file system from the combined directory by the Linux system to start and operate. The invention also discloses a system starting device, a computer device and a computer readable storage medium. The method can read and write the root file system, keep the root file system from being modified, and improve the safety of the root file system and the running stability of the Linux system.

Description

System starting method, device, computer device and storage medium
Technical Field
The present invention relates to the field of operating system technologies, and in particular, to a system booting method and apparatus, a computer apparatus, and a storage medium.
Background
With the development of technology, the application of the Linux system is more and more extensive, and the Linux system needs to mount a Linux root file system (i.e. a root file system) when being started, and the root file system comprises directories and files which are necessary when the Linux system is started.
In the prior art, in order to enable an upper-layer service program above an operating system to read and write a root file system after a Linux system is started, a partition where the root file system is located is mounted to a root directory in a writable manner in the process of starting the Linux system. However, in this case, if the upper-layer service program performs an erroneous write operation, malicious modification, or an erroneous operation on the root file system, the upper-layer service program may damage the root file system irreversibly, which may cause the Linux system to crash or cannot be started next time.
Disclosure of Invention
In view of the foregoing, there is a need to provide a system booting method, apparatus, computer apparatus and storage medium, which can read and write a root file system, keep the root file system unmodified, and improve the security of the root file system and the running stability of the Linux system.
The invention provides a system starting method, which comprises the following steps:
judging whether the Linux system starts an init process or not;
when the Linux system starts an init process, mounting a first partition to which a root file system in the computer device belongs and a second partition, which is not the first partition, in the computer device to a combined directory for starting the file system through a combined file system technology, wherein the mounting attribute of the first partition is read-only, and the mounting attribute of the second partition is writable;
and switching the root directory of the Linux system into the combined directory, and acquiring the root file system from the combined directory by the Linux system to start and operate.
In an optional implementation of the present invention, the mounting a first partition to which a root file system in the computer apparatus belongs and a second partition other than the first partition in the computer apparatus to a union directory of a boot file system by a union file system technology, where a mount attribute of the first partition is read-only and a mount attribute of the second partition is writable, includes:
creating a first mounting point folder and a second mounting point folder in the starting file system;
mounting a first partition to which a root file system in the computer device belongs to the first mounting point folder in a readable manner, and mounting a second partition of the computer device to the second mounting point folder in a writable manner;
and mounting the first mounting point folder and the second mounting point folder to a joint directory in the starting file system through an AUFS technology.
In an alternative embodiment of the invention, the method further comprises:
receiving a write operation instruction aiming at the root file system;
acquiring a root file system from the combined directory according to the write operation instruction to perform write operation, and storing a write file obtained through the write operation in the combined directory;
and if the write file is detected to be abnormal, deleting the write file from the combined directory.
In an alternative implementation of the invention, the method further comprises:
and if the Linux system is detected to be abnormal, formatting the second partition.
In an optional implementation of the present invention, after the mounting the second partition of the computer device to the second mount point folder in a writable manner, the method further includes:
judging whether the second partition is successfully mounted to the second mounting point folder or not;
if the second partition is not successfully mounted to the second mounting point folder, formatting the second partition, and executing the step of mounting the second partition of the computer device to the second mounting point folder in a writable manner.
In an alternative embodiment of the invention, the second partition is a partition created in advance according to the size of a storage medium of the computer apparatus, or the second partition is a partition created in advance according to the size of a historical write operation.
The present invention provides a system starting apparatus, comprising:
the judging module is used for judging whether the Linux system starts an init process or not;
the mount module is used for mounting a first partition to which a root file system in the computer device belongs and a second partition outside the first partition in the computer device to a joint directory for starting the file system through a joint file system technology when the Linux system starts an init process, wherein the mount attribute of the first partition is read-only, and the mount attribute of the second partition is writable;
and the switching module is used for switching the root directory of the Linux system into the combined directory, and the Linux system acquires the root file system from the combined directory to start and run.
In an optional embodiment of the present invention, the mount module is specifically configured to:
creating a first mounting point folder and a second mounting point folder in the starting file system;
mounting a first partition to which a root file system in the computer device belongs to the first mounting point folder in a readable manner, and mounting a second partition of the computer device to the second mounting point folder in a writable manner;
and mounting the first mounting point folder and the second mounting point folder to a joint directory in the starting file system through an AUFS technology.
In an optional embodiment of the invention, the apparatus further comprises a first repair module, the first repair module being configured to:
receiving a write operation instruction aiming at the root file system;
acquiring a root file system from the combined directory according to the write operation instruction to perform write operation, and storing a write file obtained through the write operation in the combined directory;
and if the write file is detected to be abnormal, deleting the write file from the combined directory.
In an optional embodiment of the invention, the apparatus further comprises a second repair module, the second repair module being configured to:
and if the Linux system is detected to be abnormal, formatting the second partition.
In an optional embodiment of the present invention, the apparatus further comprises a triggering module, where the triggering module is configured to:
after the second partition of the computer device is mounted to the second mounting point folder in a writable manner, judging whether the second partition is successfully mounted to the second mounting point folder;
and if the second partition is not successfully mounted to the second mounting point folder, formatting the second partition, and triggering the mounting module to mount the second partition of the computer device to the second mounting point folder in a writable manner.
In an alternative embodiment of the invention, the second partition is a partition created in advance according to the size of a storage medium of the computer apparatus, or the second partition is a partition created in advance according to the size of a historical write operation.
The invention also provides a computer device comprising a memory and a processor, wherein the memory is used for storing at least one instruction, and the processor is used for executing the at least one instruction to realize the system starting method in any embodiment.
The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores at least one instruction, and the at least one instruction, when executed by a processor, implements the system boot method described in any of the embodiments.
According to the technical scheme, the method is applied to the computer device, and the Linux system is judged whether to start the init process or not; when the Linux system starts an init process, mounting a first partition to which a root file system in the computer device belongs and a second partition, which is not the first partition, in the computer device to a combined directory for starting the file system through a combined file system technology, wherein the mounting attribute of the first partition is read-only, and the mounting attribute of the second partition is writable; and switching the root directory of the Linux system into the combined directory, and acquiring the root file system from the combined directory by the Linux system to start and operate. Because the first partition to which the root file system belongs and the second partition except the first partition are mounted to the union directory for starting the file system through the union file system technology, and the root directory of the Linux system is switched to the union directory, the Linux system can be started by acquiring the root file system in the union directory. Meanwhile, as the mounting attribute of the first partition is read only, after the Linux system is started, the root file system in the mounted first partition can be read through the joint directory; since the mount attribute of the second partition is writable, the write operation can be performed based on the read root file system and the write operation can be saved in the second partition. Therefore, the purpose of reading and writing the root file system after the Linux system is started is achieved, and the root file system in the first partition can not be directly modified all the time, so that the purpose of keeping the root file system unmodified is achieved, the safety of the root file system is improved, the problem that the Linux system is crashed or cannot be restarted is solved, and the stability of the Linux system during operation can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of a system booting method according to an embodiment of the present invention;
FIG. 2 is a functional block diagram of a system startup device provided by an embodiment of the invention;
FIG. 3 is a schematic structural diagram of a computer device according to a preferred embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
As shown in fig. 1, fig. 1 is a flowchart of a system booting method according to an embodiment of the present invention. The system starting method of the invention can be applied to computer devices, the sequence of the steps in the flow chart can be changed according to different requirements, and some steps can be omitted.
And S11, judging whether the Linux system starts the init process.
The init process is the first process started by the Linux kernel, and all processes in the Linux are created and run by the init process, so that the init process is the most basic process for running the Linux system.
Therefore, in the embodiment, determining whether the Linux system starts the init process may determine that the Linux system is in a start state.
S12: when the Linux system starts an init process, mounting a first partition to which a root file system in the computer device belongs and a second partition outside the first partition in the computer device to a combined directory for starting the file system through a combined file system technology, wherein the mounting attribute of the first partition is read-only, and the mounting attribute of the second partition is writable.
In the embodiment of the invention, after the Linux system starts the init process, the operations of S12 and S13 are performed, that is, in the init process, the operations of S12 and S13 are performed.
The computer device may be any electronic device capable of mounting a Linux operating system, such as a server, a notebook computer, and a video camera. Meanwhile, the computer device includes a storage medium, such as a Flash memory (Flash) or a hard disk.
In this embodiment, there may be at least two partitions for the computer device. Partitioning refers to dividing a storage medium into storage areas, so that each divided storage area can store data. Each of the memory regions obtained after the division may be referred to as a partition.
The file system is a mechanism for organizing data and files on a storage medium, the root file system is a file system, and various file systems can be provided in the Linux system.
The first partition to which the root file system belongs in the computer device refers to: a partition of a root file system is stored in a computer device. And the mount attribute of the first partition is read-only, that is, the first partition is mounted in a read-only manner, and after mounting, the partition can only perform read operation, that is, only read data in the partition.
The second partition of the computer apparatus other than the first partition may be any other partition of the computer apparatus other than the first partition. And the mount attribute of the second partition is writable, that is, the second partition is mounted in a writable manner, and after mounting, a write operation can be performed in the second partition, that is, data can be stored in the second partition.
Meanwhile, the file system type of the second partition may be the same as the file system type of the first partition, or may be different from the file system type of the first partition.
In one possible embodiment, the second partition may be a partition created in advance according to the size of a storage medium of the computer apparatus.
Specifically, when the size of the storage medium of the computer device is larger than a capacity threshold, a second partition is created, and the storage capacity of the second partition is the same as that of a first partition to which a root file system in the computer device belongs; when the size of the storage medium of the computer device is smaller than the capacity threshold value, a second partition is created, and the storage capacity of the second partition is one half or one fourth of the storage capacity of the first partition to which the root file system belongs in the computer device.
When the storage medium of the computer device is small, in order to ensure that other data can be stored (for example, operation data of a user and data obtained when the device runs), when the second partition is divided, the storage capacity of the second partition may be determined to be one-half or one-fourth of the storage capacity of the first partition to which the root file system belongs in the computer device, so that the situation that the storage capacity of the second partition is too large to cause the shortage of other storage spaces is avoided, and the situations that the system is jammed and crashed due to the shortage of other storage spaces are avoided.
In another possible embodiment, the second partition may be a partition created in advance according to the size of the historical write operation.
The historical write operation size may be a size of data resulting from a write operation to the root file system over a past period of time, and the historical write operation size may be used to predict a size of data resulting from a write operation to the root file system.
The second partition is created in advance according to the size of the historical write operation, so that the storage capacity of the second partition can be more reasonable when the second partition is created, and the waste of the storage space is avoided under the condition that the second partition is ensured to have enough space to store the data to be written.
In this embodiment, the mount may also be referred to as mount, and specifically, the mount is to associate a partition with a directory, so that the content in the partition can be operated. In specific implementation, mount can be realized by executing mount command.
The Union File System (Union File System) technology is a technology for merging and mounting directories in different physical positions into the same directory, namely, the contents of a plurality of folders are merged together, and files stored in the directories in different physical positions can be checked through the merged folders.
The starting file system is used for starting the Linux system, and specifically, the starting file system may be an initramfs file system. The union directory may be a directory previously designated in the boot-up file system or a newly created directory. Since the content in the boot file system is read when the Linux system is booted, in this embodiment, the first partition and the second partition are mounted to the directory in the boot file system by using a union file system technology.
In specific implementation, the operation of mounting the first partition and the second partition to the union directory of the starting file system can be realized by executing the corresponding command of the union file technology.
In another embodiment of the present invention, the S12 mounts, to a union directory of a boot file system, a first partition to which a root file system in the computer apparatus belongs and a second partition outside the first partition in the computer apparatus by a union file system technology, where a mount attribute of the first partition is read only and a mount attribute of the second partition is writable, where the mount attribute may include:
creating a first mounting point folder and a second mounting point folder in the starting file system;
mounting a first partition to which a root file system in the computer device belongs to the first mounting point folder in a readable manner, and mounting a second partition of the computer device to the second mounting point folder in a writable manner;
and mounting the first mounting point folder and the second mounting point folder to a joint directory in the starting file system through an AUFS technology.
In this embodiment, the first mount point folder is a folder for mounting the first partition, and the second mount point folder is a folder for mounting the second partition.
Specifically, the first partition is mounted to the first mounting point folder in a readable manner, and the second partition is mounted to the second mounting point folder in a writable manner. In an implementation, when the second partition is mounted, the mounted attribute of the second partition is also designated as being writable and also designated as being readable.
For example, hda1 represents the first partition, hda2 represents the second partition, file1 represents the first mount point folder, and file2 represents the second mount point folder, # mount-o ro/dev/hda1/file1 is performed to mount the first partition hda1 to the first mount point folder file1 in a read-only manner.
Meanwhile, executing # mount-o rw/dev/hda2/file2 mounts the second partition hda2 to the second mount point folder file2 in a readable and writable manner.
The AUFS (advanced multi-layered unified file system) technology is a joint file system technology, which may also be referred to as an advanced UnionFS.
For example, if the name of the federated directory is aufs _ root, then # mount-t aufs-o br ═ file1:./file2none./aufs _ root is executed, which enables the first mount point folder file1 and the second mount point folder file2 to be mounted to the federated directory aufs _ root.
Then if one mount point folder file1 includes files a and b and the second mount point folder file2 includes file c, when viewing the files in the federated directory afs _ root directory, file a, file b, and file c can be viewed under the federated directory afs _ root.
Figure BDA0001834054530000091
Through the above, after the first mounting point folder and the second mounting point folder are mounted, under the combined directory, the root file system in the first mounting point folder and the content in the second mounting point folder are merged, and the content of the first mounting point folder can be read through the combined directory, and the content of the second mounting point folder can be read and written.
In a possible embodiment, after mounting the second partition of the computer apparatus to the second mount point folder in a writable manner, the method further includes:
judging whether the second partition is successfully mounted to the second mounting point folder or not;
if the second partition is not successfully mounted to the second mounting point folder, formatting the second partition, and executing the step of mounting the second partition of the computer device to the second mounting point folder in a writable manner.
In this embodiment, after the second partition is mounted to the second mount point folder in a writable manner, it is determined whether the mounting is successful. The determining may be performed by determining whether the second partition is successfully mounted according to the received mounting feedback message, formatting the second partition when the second partition is not successfully mounted, and mounting again after formatting the second partition.
In this embodiment, by determining whether the second partition is successfully mounted or not and solving the problem of unsuccessful mounting when the second partition is not successfully mounted, it can be ensured that the second partition is successfully mounted and then performs subsequent operations. The problem that the content in the first partition and the content in the second partition cannot be merged after the first mounting point folder and the second mounting point folder are subsequently mounted to the union directory is solved.
S13: and switching the root directory of the Linux system into the combined directory, and acquiring the root file system from the combined directory by the Linux system to start and operate.
The root file directory of the Linux system is \ ", each file and directory in the Linux system start from the root directory, namely each file and directory in the Linux system exist under the root directory, and the root directory of the Linux system is a primary file structure of the Linux system. Meanwhile, the root directory also comprises a file for starting Linux startup.
And switching the root directory of the Linux system into the union directory, so that the Linux system can acquire the root file system from the union directory to further start and run.
Further, in other embodiments of the present invention, the method further includes:
receiving a write operation instruction aiming at the root file system;
acquiring a root file system from the combined directory according to the write operation instruction to perform write operation, and storing a write file obtained through the write operation in the combined directory;
and if the write file is detected to be abnormal, deleting the write file from the combined directory.
Specifically, due to the technical characteristics of the union file system, the data stored in the first partition and the data stored in the second partition can be acquired from the union directory. Therefore, the file to be modified in the root file system can be acquired from the combined directory for writing, and the write file obtained through the writing can be stored in the combined directory, wherein the write file obtained through the writing can be substantially stored in the first partition.
The write file abnormality may be that the write file is maliciously tampered, or the write file is damaged, and the like, so that the write file is abnormal, and the write file is deleted from the joint directory at this time.
By the embodiment, when the write operation is performed, not only can all files in the root file system be acquired for modification, but also the modified files obtained after modification can not cover or modify the original root file system. Meanwhile, if the modified file is abnormal, the abnormal file deletion can be deleted on the basis of not influencing the original root file system, so that the safety of the root file system and the running stability of the Linux system are improved.
Further, in other embodiments of the present invention, the method further includes:
and if the Linux system is detected to be abnormal, formatting the second partition.
In this embodiment, when detecting that the Linux system is abnormal, since the first partition stores the root file system of the unmodified Linux, and the second partition stores the modified file modified by the root file system, in order to repair an error that the Linux system is abnormal due to the modified file, the second partition is formatted, and the modification of the root file system is deleted, and since the original root file system is not covered, the Linux can be restored to the initial version.
By the embodiment, the Linux system can be quickly restored when the Linux system is abnormal, and can still be continuously used after being restored, so that the fault tolerance of the Linux system during operation is improved.
The system starting method provided by the invention is applied to a computer device, and is used for judging whether an init process is started by a Linux system; when the Linux system starts an init process, mounting a first partition to which a root file system in the computer device belongs and a second partition, which is not the first partition, in the computer device to a combined directory for starting the file system through a combined file system technology, wherein the mounting attribute of the first partition is read-only, and the mounting attribute of the second partition is writable; and switching the root directory of the Linux system into the combined directory, and acquiring the root file system from the combined directory by the Linux system to start and operate. Because the first partition to which the root file system belongs and the second partition except the first partition are mounted to the union directory for starting the file system through the union file system technology, and the root directory of the Linux system is switched to the union directory, the Linux system can be started by acquiring the root file system in the union directory. Meanwhile, as the mounting attribute of the first partition is read only, after the Linux system is started, the root file system in the mounted first partition can be read through the joint directory; since the mount attribute of the second partition is writable, the write operation can be performed based on the read root file system and the write operation can be saved in the second partition. Therefore, the purpose of reading and writing the root file system after the Linux system is started is achieved, and the root file system in the first partition can not be directly modified all the time, so that the purpose of keeping the root file system unmodified is achieved, the safety of the root file system is improved, the problem that the Linux system is crashed or cannot be restarted is solved, and the stability of the Linux system during operation can be improved.
As shown in fig. 2, fig. 2 is a functional block diagram of a system starting apparatus according to an embodiment of the present invention. The system starting device comprises a judging module 210, a mounting module 220 and a switching module 230. The module referred to in the present invention refers to a series of computer program segments capable of being executed by a processor of a computer device and performing a fixed function, which are stored in a memory of the computer device. In the present embodiment, the functions of the modules will be described in detail in the following embodiments.
The judging module 210 is configured to judge whether the Linux system starts an init process.
The init process is the first process started by the Linux kernel, and all processes in the Linux are created and run by the init process, so that the init process is the most basic process for running the Linux system.
Therefore, in the embodiment, determining whether the Linux system starts the init process may determine that the Linux system is in a start state.
A mount module 220, configured to mount, when the Linux system starts an init process, a first partition to which a root file system in the computer device belongs and a second partition outside the first partition in the computer device to a union directory of a starting file system through a union file system technology, where a mount attribute of the first partition is read-only and a mount attribute of the second partition is writable.
In the embodiment of the present invention, after the Linux system starts the init process, the mount module 220 and the switch module 230 perform operations, that is, in the init process, the mount module 220 and the switch module 230 perform operations.
The computer device may be any electronic device capable of mounting a Linux operating system, such as a server, a notebook computer, and a video camera. Meanwhile, the computer device includes a storage medium, such as a Flash memory (Flash) or a hard disk.
In this embodiment, there may be at least two partitions for the computer device. Partitioning refers to dividing a storage medium into storage areas, so that each divided storage area can store data. Each of the memory regions obtained after the division may be referred to as a partition.
The file system is a mechanism for organizing data and files on a storage medium, the root file system is a file system, and various file systems can be provided in the Linux system.
The first partition to which the root file system belongs in the computer device refers to: a partition of a root file system is stored in a computer device. And the mount attribute of the first partition is read-only, that is, the first partition is mounted in a read-only manner, and after mounting, the partition can only perform read operation, that is, only read data in the partition.
The second partition of the computer apparatus other than the first partition may be any other partition of the computer apparatus other than the first partition. And the mount attribute of the second partition is writable, that is, the second partition is mounted in a writable manner, and after mounting, a write operation can be performed in the second partition, that is, data can be stored in the second partition.
Meanwhile, the file system type of the second partition may be the same as the file system type of the first partition, or may be different from the file system type of the first partition.
In one possible embodiment, the second partition may be a partition created in advance according to the size of a storage medium of the computer apparatus.
Specifically, when the size of the storage medium of the computer device is larger than a capacity threshold, a second partition is created, and the storage capacity of the second partition is the same as that of a first partition to which a root file system in the computer device belongs; when the size of the storage medium of the computer device is smaller than the capacity threshold value, a second partition is created, and the storage capacity of the second partition is one half or one fourth of the storage capacity of the first partition to which the root file system belongs in the computer device.
When the storage medium of the computer device is small, in order to ensure that other data can be stored (for example, operation data of a user and data obtained when the device runs), when the second partition is divided, the storage capacity of the second partition may be determined to be one-half or one-fourth of the storage capacity of the first partition to which the root file system belongs in the computer device, so that the situation that the storage capacity of the second partition is too large to cause the shortage of other storage spaces is avoided, and the situations that the system is jammed and crashed due to the shortage of other storage spaces are avoided.
In another possible embodiment, the second partition may be a partition created in advance according to the size of the historical write operation.
The historical write operation size may be a size of data resulting from a write operation to the root file system over a past period of time, and the historical write operation size may be used to predict a size of data resulting from a write operation to the root file system.
The second partition is created in advance according to the size of the historical write operation, so that the storage capacity of the second partition can be more reasonable when the second partition is created, and the waste of the storage space is avoided under the condition that the second partition is ensured to have enough space to store the data to be written.
In this embodiment, the mount may also be referred to as mount, and specifically, the mount is to associate a partition with a directory, so that the content in the partition can be operated. In specific implementation, mount can be realized by executing mount command.
The Union File System (Union File System) technology is a technology for merging and mounting directories in different physical positions into the same directory, namely, the contents of a plurality of folders are merged together, and files stored in the directories in different physical positions can be checked through the merged folders.
The starting file system is used for starting the Linux system, and specifically, the starting file system may be an initramfs file system. The union directory may be a directory previously designated in the boot-up file system or a newly created directory. Since the content in the boot file system is read when the Linux system is booted, in this embodiment, the first partition and the second partition are mounted to the directory in the boot file system by using a union file system technology.
In specific implementation, the operation of mounting the first partition and the second partition to the union directory of the starting file system can be realized by executing the corresponding command of the union file technology.
In another embodiment of the present invention, the mounting module 220 may specifically be configured to:
creating a first mounting point folder and a second mounting point folder in the starting file system;
mounting a first partition to which a root file system in the computer device belongs to the first mounting point folder in a readable manner, and mounting a second partition of the computer device to the second mounting point folder in a writable manner;
and mounting the first mounting point folder and the second mounting point folder to a joint directory in the starting file system through an AUFS technology.
In this embodiment, the first mount point folder is a folder for mounting the first partition, and the second mount point folder is a folder for mounting the second partition.
Specifically, the first partition is mounted to the first mounting point folder in a readable manner, and the second partition is mounted to the second mounting point folder in a writable manner. In an implementation, when the second partition is mounted, the mounted attribute of the second partition is also designated as being writable and also designated as being readable.
For example, hda1 represents the first partition, hda2 represents the second partition, file1 represents the first mount point folder, and file2 represents the second mount point folder, # mount-o ro/dev/hda1/file1 is performed to mount the first partition hda1 to the first mount point folder file1 in a read-only manner.
Meanwhile, executing # mount-o rw/dev/hda2/file2 mounts the second partition hda2 to the second mount point folder file2 in a readable and writable manner.
The AUFS (advanced multi-layered unified file system) technology is a joint file system technology, which may also be referred to as an advanced UnionFS.
For example, if the name of the federated directory is aufs _ root, then # mount-t aufs-o br ═ file1:./file2none./aufs _ root is executed, which enables the first mount point folder file1 and the second mount point folder file2 to be mounted to the federated directory aufs _ root.
Then if one mount point folder file1 includes files a and b and the second mount point folder file2 includes file c, when viewing the files in the federated directory afs _ root directory, file a, file b, and file c can be viewed under the federated directory afs _ root.
Figure BDA0001834054530000161
Through the above, after the first mounting point folder and the second mounting point folder are mounted, under the combined directory, the root file system in the first mounting point folder and the content in the second mounting point folder are merged, and the content of the first mounting point folder can be read through the combined directory, and the content of the second mounting point folder can be read and written.
In a possible embodiment, the apparatus further comprises a triggering module for
After the second partition of the computer device is mounted to the second mounting point folder in a writable manner, judging whether the second partition is successfully mounted to the second mounting point folder;
and if the second partition is not successfully mounted to the second mounting point folder, formatting the second partition, and triggering the mounting module to mount the second partition of the computer device to the second mounting point folder in a writable manner.
In this embodiment, after the second partition is mounted to the second mount point folder in a writable manner, it is determined whether the mounting is successful. The determining may be performed by determining whether the second partition is successfully mounted according to the received mounting feedback message, formatting the second partition when the second partition is not successfully mounted, and mounting again after formatting the second partition.
In this embodiment, by determining whether the second partition is successfully mounted or not and solving the problem of unsuccessful mounting when the second partition is not successfully mounted, it can be ensured that the second partition is successfully mounted and then performs subsequent operations. The problem that the content in the first partition and the content in the second partition cannot be merged after the first mounting point folder and the second mounting point folder are subsequently mounted to the union directory is solved.
A switching module 230, configured to switch the root directory of the Linux system to the union directory, where the Linux system obtains the root file system from the union directory to start and run.
The root file directory of the Linux system is \ ", each file and directory in the Linux system start from the root directory, namely each file and directory in the Linux system exist under the root directory, and the root directory of the Linux system is a primary file structure of the Linux system. Meanwhile, the root directory also comprises a file for starting Linux startup.
And switching the root directory of the Linux system into the union directory, so that the Linux system can acquire the root file system from the union directory to further start and run.
Further, in other embodiments of the present invention, the apparatus further includes a first repair module, where the first repair module is configured to:
receiving a write operation instruction aiming at the root file system;
acquiring a root file system from the combined directory according to the write operation instruction to perform write operation, and storing a write file obtained through the write operation in the combined directory;
and if the write file is detected to be abnormal, deleting the write file from the combined directory.
Specifically, due to the technical characteristics of the union file system, the data stored in the first partition and the data stored in the second partition can be acquired from the union directory. Therefore, the file to be modified in the root file system can be acquired from the combined directory for writing, and the write file obtained through the writing can be stored in the combined directory, wherein the write file obtained through the writing can be substantially stored in the first partition.
The write file abnormality may be that the write file is maliciously tampered, or the write file is damaged, and the like, so that the write file is abnormal, and the write file is deleted from the joint directory at this time.
By the embodiment, when the write operation is performed, not only can all files in the root file system be acquired for modification, but also the modified files obtained after modification can not cover or modify the original root file system. Meanwhile, if the modified file is abnormal, the abnormal file deletion can be deleted on the basis of not influencing the original root file system, so that the safety of the root file system and the running stability of the Linux system are improved.
Further, in other embodiments of the present invention, the apparatus further includes a second repair module, where the second repair module is configured to:
and if the Linux system is detected to be abnormal, formatting the second partition.
In this embodiment, when detecting that the Linux system is abnormal, since the first partition stores the root file system of the unmodified Linux, and the second partition stores the modified file modified by the root file system, in order to repair an error that the Linux system is abnormal due to the modified file, the second partition is formatted, and the modification of the root file system is deleted, and since the original root file system is not covered, the Linux can be restored to the initial version.
By the embodiment, the Linux system can be quickly restored when the Linux system is abnormal, and can still be continuously used after being restored, so that the fault tolerance of the Linux system during operation is improved.
The system starting device provided by the invention judges whether the Linux system starts the init process or not through the judgment module; when the Linux system starts an init process, a mounting module mounts a first partition to which a root file system in the computer device belongs and a second partition outside the first partition in the computer device to a combined directory for starting the file system through a combined file system technology, wherein the mounting attribute of the first partition is read-only, and the mounting attribute of the second partition is writable; and the switching module switches the root directory of the Linux system into the combined directory, and the Linux system acquires the root file system from the combined directory to start and operate. Because the first partition to which the root file system belongs and the second partition except the first partition are mounted to the union directory for starting the file system through the union file system technology, and the root directory of the Linux system is switched to the union directory, the Linux system can be started by acquiring the root file system in the union directory. Meanwhile, as the mounting attribute of the first partition is read only, after the Linux system is started, the root file system in the mounted first partition can be read through the joint directory; since the mount attribute of the second partition is writable, the write operation can be performed based on the read root file system and the write operation can be saved in the second partition. Therefore, the purpose of reading and writing the root file system after the Linux system is started is achieved, and the root file system in the first partition can not be directly modified all the time, so that the purpose of keeping the root file system unmodified is achieved, the safety of the root file system is improved, the problem that the Linux system is crashed or cannot be restarted is solved, and the stability of the Linux system during operation can be improved.
The integrated unit implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention.
Fig. 3 is a schematic structural diagram of a computer device according to a preferred embodiment of the system booting method of the invention. The computer means comprise at least one transmitting means 31, at least one memory 32, at least one processor 33, at least one receiving means 34 and at least one communication bus. Wherein the communication bus is used for realizing connection communication among the components.
The computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like. The computer apparatus may also include a network device and/or a user device. Wherein the network device includes, but is not limited to, a single network server, a server group consisting of a plurality of network servers, or a Cloud Computing (Cloud Computing) based Cloud consisting of a large number of hosts or network servers, wherein Cloud Computing is one of distributed Computing, a super virtual computer consisting of a collection of loosely coupled computers.
The computer device may be, but is not limited to, any electronic product that can perform human-computer interaction with a user through a keyboard, a touch pad, or a voice control device, for example, a tablet computer, a smart phone, a monitoring device, and other terminals.
The Network in which the computer device is located includes, but is not limited to, the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
The receiving device 34 and the transmitting device 31 may be wired transmitting ports, or may be wireless devices, for example, including antenna devices, for performing data communication with other devices.
The memory 32 is used to store program code. The Memory 32 may be a circuit having a storage function, such as a RAM (Random-Access Memory), a FIFO (First In First Out ), or the like, which is not In a physical form In the integrated circuit. Alternatively, the memory 32 may be a memory in a physical form, such as a memory bank, a TF Card (Trans-flash Card), a smart media Card (smart media Card), a secure digital Card (secure digital Card), a flash memory Card (flash Card), and so on.
The processor 33 may comprise one or more microprocessors, digital processors. The processor 33 may call program code stored in the memory 32 to perform the associated functions. For example, the various elements described in FIG. 3 are program code stored in the memory 32 and executed by the processor 33 to implement a system boot method. The processor 33 is also called a Central Processing Unit (CPU), and is an ultra-large scale integrated circuit, which is an operation Core (Core) and a Control Core (Control Unit).
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A system starting method applied to a computer device is characterized by comprising the following steps:
judging whether the Linux system starts an init process or not;
when the Linux system starts an init process, mounting a first partition to which a root file system in the computer device belongs and a second partition except the first partition in the computer device to a combined directory for starting the file system through a combined file system technology, wherein the mounting attribute of the first partition is read only, the mounting attribute of the second partition is writable, and the second partition refers to a partition capable of being formatted;
and switching the root directory of the Linux system into the combined directory, and acquiring the root file system from the combined directory by the Linux system to start and operate.
2. The method of claim 1, wherein the mounting a first partition of the computer device to which a root file system belongs and a second partition of the computer device outside the first partition to a union directory of a boot file system through a union file system technology, wherein a mounting attribute of the first partition is read-only and a mounting attribute of the second partition is writable, comprises:
creating a first mounting point folder and a second mounting point folder in the starting file system;
mounting a first partition to which a root file system in the computer device belongs to the first mounting point folder in a readable manner, and mounting a second partition of the computer device to the second mounting point folder in a writable manner;
and mounting the first mounting point folder and the second mounting point folder to a joint directory in the starting file system through an AUFS technology.
3. The method of claim 1 or 2, wherein the method further comprises:
receiving a write operation instruction aiming at the root file system;
acquiring a root file system from the combined directory according to the write operation instruction to perform write operation, and storing a write file obtained through the write operation in the combined directory;
and if the write file is detected to be abnormal, deleting the write file from the combined directory.
4. The method of claim 1 or 2, wherein the method further comprises:
and if the Linux system is detected to be abnormal, formatting the second partition.
5. The method of claim 1 or 2, wherein after the mounting the second partition of the computer device to the second mount point folder in a writable manner, further comprising:
judging whether the second partition is successfully mounted to the second mounting point folder or not;
if the second partition is not successfully mounted to the second mounting point folder, formatting the second partition, and executing the step of mounting the second partition of the computer device to the second mounting point folder in a writable manner.
6. The method of claim 1 or 2, wherein the second partition is a partition pre-created according to a size of a storage medium of the computer apparatus, or the second partition is a partition pre-created according to a size of a historical write operation.
7. A system activation device, the device comprising:
the judging module is used for judging whether the Linux system starts an init process or not;
the mount module is used for mounting a first partition to which a root file system in the computer device belongs and a second partition except the first partition in the computer device to a joint directory for starting the file system through a joint file system technology when the Linux system starts an init process, wherein the mount attribute of the first partition is read only, the mount attribute of the second partition is writable, and the second partition refers to a partition capable of being formatted;
and the switching module is used for switching the root directory of the Linux system into the combined directory, and the Linux system acquires the root file system from the combined directory to start and run.
8. The apparatus of claim 7, wherein the mounting module is specifically configured to:
creating a first mounting point folder and a second mounting point folder in the starting file system;
mounting a first partition to which a root file system in the computer device belongs to the first mounting point folder in a readable manner, and mounting a second partition of the computer device to the second mounting point folder in a writable manner;
and mounting the first mounting point folder and the second mounting point folder to a joint directory in the starting file system through an AUFS technology.
9. A computer device, comprising a memory for storing at least one instruction and a processor for executing the at least one instruction to implement the system startup method of any one of claims 1 to 6.
10. A computer-readable storage medium having stored thereon computer instructions, characterized in that: the computer instructions, when executed by a processor, implement the system startup method of any one of claims 1 to 6.
CN201811218034.2A 2018-10-18 2018-10-18 System starting method, device, computer device and storage medium Active CN109445861B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811218034.2A CN109445861B (en) 2018-10-18 2018-10-18 System starting method, device, computer device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811218034.2A CN109445861B (en) 2018-10-18 2018-10-18 System starting method, device, computer device and storage medium

Publications (2)

Publication Number Publication Date
CN109445861A CN109445861A (en) 2019-03-08
CN109445861B true CN109445861B (en) 2022-04-01

Family

ID=65546660

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811218034.2A Active CN109445861B (en) 2018-10-18 2018-10-18 System starting method, device, computer device and storage medium

Country Status (1)

Country Link
CN (1) CN109445861B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110162429B (en) * 2019-05-27 2021-09-24 深圳市网心科技有限公司 System repair method, server and storage medium
CN110262918B (en) * 2019-06-19 2023-07-18 深圳市网心科技有限公司 Process crash analysis method and device, distributed equipment and storage medium
CN112579347A (en) * 2019-09-29 2021-03-30 北京君正集成电路股份有限公司 System capable of restoring file system
CN112579345A (en) * 2019-09-29 2021-03-30 北京君正集成电路股份有限公司 Method for realizing file system restoration based on device mapper mechanism
CN112579521A (en) * 2019-09-29 2021-03-30 北京君正集成电路股份有限公司 File system implementation method based on equipment mapping mechanism
CN110992992B (en) * 2019-10-31 2022-12-02 苏州浪潮智能科技有限公司 Hard disk test method, device and storage medium
CN112416862A (en) * 2020-11-30 2021-02-26 中国航空工业集团公司西安航空计算技术研究所 File management system and method based on partition operating system architecture
CN112579256B (en) * 2020-12-14 2022-04-19 上海英方软件股份有限公司 Linux migration method and device
CN112988464A (en) * 2021-03-23 2021-06-18 武汉深之度科技有限公司 Power-off protection method and computing device
CN113672302A (en) * 2021-08-20 2021-11-19 四川长虹网络科技有限责任公司 Router starting method and device, router and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102262568A (en) * 2010-05-25 2011-11-30 上海中标软件有限公司 Power-down prevention Linux system startup method
CN102495812A (en) * 2011-12-15 2012-06-13 江苏中科梦兰电子科技有限公司 Hard disk data protection and recovery method of Linux platform
CN103106091A (en) * 2013-01-31 2013-05-15 深圳市开立科技有限公司 Start-up system and method of operating system based on removable storage media
CN105825126A (en) * 2016-03-08 2016-08-03 北京网康科技有限公司 File protecting method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107885748B (en) * 2016-09-30 2021-10-26 华为技术有限公司 File hierarchical access method and device for virtualized instance
CN107590272B (en) * 2017-09-26 2020-04-10 天津麒麟信息技术有限公司 Operating system snapshot realization method based on Overlay file system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102262568A (en) * 2010-05-25 2011-11-30 上海中标软件有限公司 Power-down prevention Linux system startup method
CN102495812A (en) * 2011-12-15 2012-06-13 江苏中科梦兰电子科技有限公司 Hard disk data protection and recovery method of Linux platform
CN103106091A (en) * 2013-01-31 2013-05-15 深圳市开立科技有限公司 Start-up system and method of operating system based on removable storage media
CN105825126A (en) * 2016-03-08 2016-08-03 北京网康科技有限公司 File protecting method and device

Also Published As

Publication number Publication date
CN109445861A (en) 2019-03-08

Similar Documents

Publication Publication Date Title
CN109445861B (en) System starting method, device, computer device and storage medium
EP3036634B1 (en) Disconnected operation for systems utilizing cloud storage
EP2840495B1 (en) Container-based processing method and apparatus
CN108153849B (en) Database table segmentation method, device, system and medium
CN110162429B (en) System repair method, server and storage medium
US11698808B2 (en) System and method of selectively restoring a computer system to an operational state
CN111258666B (en) Method and device for reading computer file, computer system and storage medium
CN106777394B (en) Cluster file system
US20170083419A1 (en) Data management method, node, and system for database cluster
CN113568566A (en) Method, host device and storage server for seamless migration of simple storage service by using index object
WO2015085755A1 (en) Operating system recovery method, apparatus and terminal device
CN111897493B (en) Storage space management method and device, electronic equipment and storage medium
CN116340053A (en) Log processing method, device, computer equipment and medium for system crash
CN105608150A (en) Business data processing method and system
CN113687779A (en) Data migration method and device, electronic equipment and readable storage medium
CN111435323A (en) Information transmission method, device, terminal, server and storage medium
CN113986471A (en) Method, device, equipment and storage medium for safely deleting mirror image file of virtual machine
CN114675995A (en) Data backup method and device and electronic equipment
CN113791934A (en) Data recovery method, computing device and storage medium
CN113806309A (en) Metadata deleting method, system, terminal and storage medium based on distributed lock
CN109324931B (en) Method for realizing vmware mount recovery in data de-duplication system
CN108509252B (en) Virtual machine starting device and method and host
CN115774701B (en) Data sharing method and device, electronic equipment and storage medium
CN107704198B (en) Information processing method and electronic equipment
US11068194B2 (en) Method and system for storing and managing states of a computer

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant