Linux system starting protection method and device and storage medium

By dynamically managing restart protection file groups in Linux system, the startup problem caused by insufficient system disk space is solved, ensuring that the system can start normally and avoiding the impact on system use.

CN119739436AActive Publication Date: 2025-04-01KYLIN CORP
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510258426.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-06
Publication Date
2025-04-01
Estimated Expiration
2045-03-06

AI Technical Summary

Technical Problem

The Linux system cannot start normally due to the logs and various files generated by third-party system applications being filled with the system disk.

Method used

By setting the size of the restart protection file group on the system disk and dynamically generating and deleting the restart protection file group according to the available storage space status of the system disk to ensure that the system can start normally.

Benefits of technology

It effectively avoids system startup failure caused by insufficient system disk space, and protects file groups by generating restarts in stages to avoid the impact on the normal use of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119739436A_ABST
    Figure CN119739436A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a Linux system starting protection method and device and a storage medium. The method comprises the steps that the size of a restarting protection file group is set according to the storage space of a system disk; when the available storage space of the system disk is greater than a preset first space threshold value, determining a rapid recording state, and when the available storage space of the system disk is greater than the preset first space threshold value, determining the number of restart protection files in the generated restart protection file group according to the recorded system starting times, and generating a corresponding number of restart protection files in the system disk; when the available storage space of the system disk is smaller than a preset second space threshold value, determining a disk space barrier hitting state; in the state of hitting the disk space barrier, when the system is started each time, a preset number of restart protection files are generated in the system disk, and the preset number is larger than the maximum number of the restart protection files generated in the rapid recording state. And the influence on the normal use of the Linux system due to the generation of a large number of restart protection file groups at one time is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Linux systems, and in particular to a Linux system startup protection method, device and storage medium. Background Art

[0002] During the system startup process, if the system disk space is exhausted due to logs, data, configuration files, and cache files generated by daily user use or third-party system applications, the system will fail to start.

[0003] In the prior art, log files are usually managed effectively using tools that automatically manage a large number of log files, such as Logrotate, which supports functions such as regular rotation, compression, deletion, and email notification. This tool is designed to simplify the management of systems that generate a large number of log files, and helps system administrators effectively manage log files in an automated manner, thereby avoiding the problem of log files being too large and occupying too much disk space. However, this method only supports space restrictions on log files, and cannot solve the problem that the file system cannot be started after the disk is full due to data, configuration files, cache files, and other files generated by third-party system applications. Summary of the invention

[0004] The embodiment of the present invention provides a Linux system startup protection method, device and storage medium to solve the technical problem in the prior art that the Linux system cannot be normally started because the system disk is filled with various files generated by logs and third-party system applications.

[0005] In a first aspect, an embodiment of the present invention provides a Linux system startup protection method, comprising: Set the size of the restart protection file group according to the storage space of the system disk; When the available storage space of the system disk is greater than a preset first space threshold, it is determined to be in a fast recording state. In the fast recording state, the number of restart protection file groups to be generated is determined according to the recorded number of system startups, and a corresponding number of restart protection file groups are generated on the system disk; When the available storage space of the system disk is less than a preset second space threshold, it is determined that the disk space barrier state is hit; When the disk space barrier is hit, a preset number of restart protection file groups are generated on the system disk each time the system starts, and the preset number is greater than the maximum number of restart protection files generated in the fast recording state.

[0006] In a second aspect, an embodiment of the present invention further provides a Linux system startup protection device, comprising: A setting module, used to set the size of the restart protection file group according to the storage space of the system disk; A first generating module is used to determine that the system disk is in a fast recording state when the available storage space is greater than a preset first space threshold, and when in the fast recording state, determine the number of restart protection files in the restart protection file group to be generated according to the recorded number of system startups, and generate a corresponding number of restart protection files in the system disk; A determination module, configured to determine that a disk space barrier state is hit when the available storage space of the system disk is less than a preset second space threshold; The second generation module is used to generate a preset number of restart protection files on the system disk each time the system starts when the disk space barrier state is hit, and the preset number is greater than the maximum number of restart protection files generated in the fast recording state.

[0007] In a third aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions, when executed by a computer processor, are used to execute the Linux system startup protection method provided in the above embodiment.

[0008] The Linux system startup protection method, device and storage medium provided by the embodiment of the present invention set the size of the restart protection file group according to the storage space of the system disk; when the available storage space of the system disk is greater than the preset first space threshold, it is determined to be in a fast recording state. When it is in the fast recording state, the number of restart protection file groups generated is determined according to the recorded number of system startups, and a corresponding number of restart protection file groups are generated in the system disk; when the available storage space of the system disk is less than the preset second space threshold, it is determined to be in a disk space barrier state; when it is in a disk space barrier state, each time the system is started, a preset number of restart protection file groups are generated in the system disk, and the preset number is greater than the maximum number of restart protection files generated in the fast recording state. The restart protection file group can be used to achieve the purpose of normal startup by deleting part of the restart protection file group when the system disk storage space is tight. And the restart protection file group can be generated in stages according to the use status of the system disk to avoid generating a large number of restart protection file groups at one time, which affects the normal use of the Linux system. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings: Figure 1 This is a flowchart of a Linux system startup protection method provided by Embodiment 1 of the present invention; Figure 2 This is a schematic diagram of the number of protection files created in the Linux system startup protection method provided in the first embodiment of the present invention; Figure 3It is a flowchart of a Linux system startup protection method provided by Embodiment 2 of the present invention; Figure 4 This is a schematic diagram of creating and restoring a restart protection file in a restart protection file group in a Linux system startup protection method provided in Embodiment 2 of the present invention; Figure 5 It is a structural diagram of a Linux system startup protection device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION

[0010] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0011] Embodiment 1 Figure 1 : is a flowchart of a Linux system startup protection method provided by Embodiment 1 of the present invention. This embodiment is applicable to situations where logs, data, and configuration files are generated during the use of the Linux system, and too many cache files lead to insufficient system storage capacity, thereby affecting the normal startup of the Linux system. The method can be executed by a Linux system startup protection device, and specifically includes the following steps: Step 110, setting the size of the restart protection file group according to the storage space of the system disk.

[0012] The booting of the Linux operating system begins with the self-test phase of the BIOS (Basic Input Output System) or UEFI (Unified Extensible Firmware Interface), which ensures the integrity and functionality of all key hardware components through a series of diagnostic tests, laying the foundation for subsequent system loading.

[0013] Subsequently, control is transferred to GRUB (GRand Unified Bootloader), which is the system's boot loader. GRUB is responsible for loading the Linux kernel and its matching initial memory file system (initramfs) from the storage medium according to the user's choice or the preset boot sequence configuration. initramfs is a temporary root file system that provides the necessary drivers and tools at the beginning of system startup so that the system can perform necessary initialization operations before the official root file system is mounted.

[0014] As the kernel starts, initramfs is decompressed and mounted as a temporary root file system, providing a necessary operating environment for the further initialization process of the system. At this stage, systemd, as the system initialization daemon and service manager, is started by the kernel as the first user-mode process (PID 1).

[0015] systemd reads system and service configuration files, builds a startup dependency graph, and uses advanced parallel startup strategies to speed up the service startup process. With all necessary services and daemons started and configured, systemd guides the system to the preset target state. These target states define the operating mode of the system, such as multi-user.target represents a multi-user command line interface mode, and graphical.target represents a mode that includes a graphical user interface. Once the system reaches the predetermined target state, users can access the system through the login interface and perform various tasks and applications.

[0016] During the system startup process, if the system disk space is exhausted due to logs, data, configuration files, and cache files generated by daily user use or third-party system applications, the system will fail to start. Specifically, it may be caused by the following reasons: The startup activities of system services and key applications are monitored by the system, and the relevant information is written to the log file. The log entry contains the service startup time, status (success or failure), and possible error information and debugging data, providing system administrators with in-depth system behavior analysis and potential problem diagnosis. It is particularly important to note that the continuous logging depends on sufficient space on the storage medium (especially the hard disk). Insufficient hard disk space will directly lead to log writing failure, which may lead to two serious consequences: first, the system service cannot start normally or maintain stable operation due to the lack of log records; second, the user may not be able to access the file system because the dependent system service (such as the log service) failed to start successfully.

[0017] In the daily operation and management of the system, in addition to the key program log records, it is also necessary to consider the impact of a series of key data components created when the program is running on the system disk resources. Specifically, the program will generate various types of files, including but not limited to database files, configuration files, and cache files. These files play a vital role in the normal operation of the system, but also occupy a certain amount of disk space. The logs or other behaviors of third-party applications will inevitably lead to the problem of exhaustion of system disk space.

[0018] In order to avoid the problem of running out of system disk space, in this embodiment, a protection space can be set in the system disk space to avoid startup failures caused by running out of space. Furthermore, considering that the protection space needs to be separated separately, and the space usage needs to be monitored in real time to determine whether to cancel the protection space, and after cancellation, the protection space needs to be set again according to the newly added log and data components, the above operations are not only complicated, but also not flexible enough.

[0019] Preferably, the system disk space may be protected in the form of a file group, wherein the file group includes a number of files of a certain size without substantial content, such as files whose contents are all filled with zeros.

[0020] In this embodiment, the size of the file group can be set according to the disk space. For example, the size of the file group can be determined according to a preset ratio, and the product of the system disk space and the ratio.

[0021] Furthermore, the size of each increase in the log and the number and size of various files generated by frequently used data components can be counted, and the size of each protected file in the file group can be determined based on the statistical data. This facilitates the subsequent deletion of files in the protected file group. Exemplarily, the size of the minimum file can be determined in combination with the frequency of use of the data component and the total amount of the size of each increase in the statistical log. Furthermore, the size of the file can be determined based on a certain multiple of the minimum file size, taking into account the number range of the preset file groups.

[0022] Step 120, when the available storage space of the system disk is greater than a preset first space threshold, it is determined to be in a fast recording state. When it is in the fast recording state, the number of restart protection files in the restart protection file group is determined based on the recorded number of system startups, and a corresponding number of restart protection files are generated on the system disk.

[0023] In this embodiment, if all files in the complete restart protection file group are used to seize system disk resources in the early stage, and the system does not have a shortage of system storage space at this time, it will affect the normal use of the system. Therefore, in this embodiment, a gradual method is adopted to establish the protection files in the restart protection group.

[0024] For example, first determine whether the storage space of the current system disk is greater than a preset space threshold, if it is greater than, it can be considered that the system disk space is relatively sufficient, and determine to be in a fast recording state. In this state, most protected files can be created.

[0025] Exemplarily, the number of protection files in the generated restart protection file group is determined according to the recorded number of system startups. Optionally, the following method can be used to implement it: , where N is the total number of restart protection file groups, M is the number of system startups, and X is the total number of system startups required to generate all restart protection file groups.

[0026] It can be seen from the above formula that the protection file can be gradually established by taking the first-order difference of the line function. Figure 2 This is a schematic diagram of the number of protection files created in the Linux system startup protection method provided in the first embodiment of the present invention, see Figure 2 , under the condition that N is 20 and M is 5, determine the number of protected files established in each stage. Figure 2 It can be seen that during the first N startup processes, most of the protection files are gradually created before the device user has used a large amount of disk space, so as to avoid the protection file creation process affecting the normal use of the system.

[0027] Exemplarily, when the system is in a fast recording state, a corresponding number of restart protection files are generated on the system disk, which may also include: generating a fast establishment feature file; writing the [FileNum] field to the fast establishment feature file, and writing the total number of preset restart protection file groups as a parameter to the [FileNum] field; writing the [Estimated] field to the fast establishment feature file, and writing the expected total number of times to generate all restart protection file groups as a parameter to the [Estimated] field; writing the [StartsNum] field to the fast establishment feature file, and after each startup, writing the recorded number of startups as a parameter to the [StartsNum] field. In this embodiment, due to the fast recording state, it is necessary to generate protection files step by step in stages. Using the various fields of the fast establishment feature file, various parameters can be written, and some parameters can be flexibly modified according to each stage, so that at each startup later, by querying the various parameters of the fast establishment feature file, the establishment of the restart protection file corresponding to this startup is completed, and after the establishment is completed, the corresponding field modifies the parameters. Usually, a fast establishment feature file can be generated when the system is started for the first time.

[0028] Step 130: When the available storage space of the system disk is less than a preset second space threshold, it is determined that the disk space barrier state is hit.

[0029] If the available storage space of the system disk is found to be insufficient when the system is started, a system startup problem may occur in a short period of time. If the protection files in the restart protection file group are not created or not all created at this time, the current state can be determined as a medium disk space barrier state.

[0030] Correspondingly, the [DiskWaterMark] field in the quick creation feature file can be used to query the preset second space threshold, and determine whether the disk space barrier state is hit according to the second space threshold.

[0031] Step 140, when the disk space barrier is hit, a preset number of restart protection files are generated on the system disk each time the system starts, and the preset number is greater than the maximum number of restart protection files generated in the fast recording state.

[0032] When the disk space barrier state is hit, if the restart protection file is still created according to the method in the fast recording state, it may not be possible to complete the creation of all protection files. Therefore, in this embodiment, a restart protection file is generated in another way. Exemplarily, a fixed number of protection files are created. And the number is greater than the maximum number of restart protection files generated in the fast recording state. In order to quickly complete the creation of the restart protection file group in the disk space barrier state.

[0033] Furthermore, the preset number can be determined based on the remaining space in the current disk space barrier state and the size of the protection file to determine the number of times that can be normally started, and the preset number can be determined based on the number of times and the number of remaining protection files that need to be created, so as to complete the rapid establishment of the restart protection file without affecting the normal operation and startup of the system.

[0034] Accordingly, [Finished] may be written into the quick creation feature file to mark the completion status of generating a preset number of restart protection file groups on the system disk.

[0035] This embodiment sets the size of the restart protection file group according to the storage space of the system disk; when the available storage space of the system disk is greater than the preset first space threshold, it is determined to be in a fast recording state. When it is in the fast recording state, the number of restart protection file groups generated is determined according to the recorded number of system startups, and a corresponding number of restart protection file groups are generated in the system disk; when the available storage space of the system disk is less than the preset second space threshold, it is determined to be in a disk space barrier state; when it is in a disk space barrier state, each time the system is started, a preset number of restart protection files are generated in the system disk, and the preset number is greater than the maximum number of restart protection files generated in the fast recording state. The restart protection file group can be used to achieve the purpose of normal startup by deleting some restart protection files in the restart protection file group when the storage space of the system disk is tight. And the restart protection file group can be generated in stages according to the use status of the system disk to avoid generating a large number of restart protection files at one time, which affects the normal use of the Linux system.

[0036] In a preferred implementation of this embodiment, the method may further add the following steps: before each system shutdown, detect whether the system partition is in the resource exhaustion stage, and when in the resource exhaustion stage, delete the protection files in the restart protection file group. Optionally, it can be determined whether it is in the resource exhaustion stage based on whether the free space in the system partition is less than a preset space threshold, or the ratio of the free space to the system partition space is less than a preset ratio threshold. Before each system shutdown, detect whether the system partition is in the resource exhaustion stage. When in the resource exhaustion stage, some or all of the restart protection files in the restart protection file group need to be deleted. So that the system can start normally next time. Optionally, the number of restart protection files to be deleted can be determined based on the resource exhaustion stage.

[0037] Embodiment 2 Figure 3 It is a flow chart of the Linux system startup protection method provided by the second embodiment of the present invention. This embodiment is optimized based on the above embodiment, and the method can also add the following steps: when the event of deleting the restart protection file group during the previous shutdown is detected, the space occupancy rate of the current system disk is determined; when the space occupancy rate is greater than a preset occupancy rate threshold, it is determined to be a slow recovery state; when it is in the slow recovery state, the number of system restarts is recorded, and when the number of system restarts reaches a preset number threshold, an attempt is made to restore the restart protection file in the restart protection file group.

[0038] See also Figure 3 , the Linux system startup protection method comprises: Step 210: Set the size of the restart protection file group according to the storage space of the system disk.

[0039] Step 220, when the available storage space of the system disk is greater than a preset first space threshold, it is determined to be in a fast recording state. When it is in the fast recording state, the number of restart protection files in the restart protection file group is determined based on the recorded number of system startups, and a corresponding number of restart protection files are generated on the system disk.

[0040] Step 230: When the available storage space of the system disk is less than a preset second space threshold, it is determined that the disk space barrier state is hit.

[0041] Step 240: When the disk space barrier is hit, a preset number of restart protection files are generated on the system disk each time the system starts, and the preset number is greater than the maximum number of restart protection files generated in the fast recording state.

[0042] Step 250, when the event of deleting the restart protection file during the previous shutdown is detected, determine the space occupancy rate of the current system disk.

[0043] In this embodiment, the last shutdown to delete the restart protection file may be a situation where the system has insufficient remaining space, and all or part of the restart protection files are deleted. When this event is detected, an alarm will be issued when the system is started this time, and the user may clean up the system space so that there is a larger remaining system space. At this time, the deleted restart protection files can be quickly restored. In addition, no processing may be performed, so it is necessary to detect the space occupancy rate of the current system disk to determine whether the user has cleaned up the system space.

[0044] Step 260: When the space occupancy rate is greater than a preset occupancy rate threshold, determine it as a slow recovery state.

[0045] The slow recovery state is applicable to the attempt to recover the restart protection file when the user does not do anything with the system disk.

[0046] Step 270, when in the slow recovery state, record the number of system restarts, and when the number of system restarts reaches a preset number threshold, try to restore the restart protection file in the restart protection file group.

[0047] Figure 4 This is a schematic diagram of creating and restoring a restart protection file in a restart protection file group in a Linux system startup protection method provided by Embodiment 2 of the present invention. Figure 4 , in the fast recording state and the disk space barrier hitting state, the restart protection file is gradually generated. When the event of deleting the restart protection file during the previous shutdown is detected, the time interval for trying to restore the restart protection file will be increased by K times, that is, after K restarts, try to restore the restart protection file again. In actual usage scenarios, when the disk space is insufficient and the actual protection file cannot be created, resulting in failure, the remaining space in the system is already less than the size of a restart protection file. At this time, each time the computer is turned on, an attempt is made to create a restart protection file. Because the disk has a write amplification problem, it will cause system freezes and other problems, and the creation cannot be successful. Because the user will eventually find that the disk space is seriously insufficient within K restarts, and perform operations such as removing unnecessary files, and because of the system freezes and the previous correct alarms, the user will find this problem, and then start K times, and then create the restart protection file. In this way, even if the customer does not clean up, it will not cause abnormal freezes every time the computer is turned on.

[0048] For example, [TouchOff] can be written to the fast establishment feature file to mark whether the restart protection mechanism is triggered; [RebootNumber] can be written to the fast establishment feature file to mark the number of restart protection files to be restored; and [RecoverSusecess] can be written to the fast establishment feature file to mark whether the restart protection file to be restored is successfully created. In the slow recovery stage, [TouchOff] can be read to determine whether the restart protection file was deleted during the previous shutdown, and the number of restart protection files to be restored can be obtained by reading the [RebootNumber] field, and the [RecoverSusecess] field can be used to mark whether the restart protection file to be restored is successfully created.

[0049] This embodiment adds the following steps: when the event of deleting the restart protection file group at the last shutdown is detected, the space occupancy rate of the current system disk is determined; when the space occupancy rate is greater than a preset occupancy rate threshold, it is determined to be in a slow recovery state; when it is in the slow recovery state, the number of system restarts is recorded, and when the number of system restarts reaches a preset number threshold, the restart protection files in the restart protection file group are tried to be restored. This avoids the problem of system freezing.

[0050] Embodiment 3 Figure 5 is a schematic diagram of the structure of the Linux system startup protection device provided by the third embodiment of the present invention, see Figure 5 , the Linux system startup protection device comprises: A setting module 310, used to set the size of the restart protection file group according to the storage space of the system disk; A first generating module 320 is used to determine that the system disk is in a fast recording state when the available storage space of the system disk is greater than a preset first space threshold value, and when in the fast recording state, determine the number of restart protection files in the restart protection file group to be generated according to the recorded number of system startups, and generate a corresponding number of restart protection files in the system disk; A determination module 330, configured to determine that a disk space barrier state has been hit when the available storage space of the system disk is less than a preset second space threshold; The second generation module 340 is used to generate a preset number of restart protection files on the system disk each time the system starts when the disk space barrier state is hit, and the preset number is greater than the maximum number of restart protection files generated in the fast recording state.

[0051] The Linux system startup protection device provided in this embodiment sets the size of the restart protection file group according to the storage space of the system disk; when the available storage space of the system disk is greater than the preset first space threshold, it is determined to be in a fast recording state. When it is in the fast recording state, the number of restart protection file groups generated is determined according to the recorded number of system startups, and a corresponding number of restart protection file groups are generated in the system disk; when the available storage space of the system disk is less than the preset second space threshold, it is determined to be in a disk space barrier state; when it is in a disk space barrier state, each time the system is started, a preset number of restart protection file groups are generated in the system disk, and the preset number is greater than the maximum number of restart protection files generated in the fast recording state. The restart protection file group can be used to achieve the purpose of normal startup by deleting part of the restart protection file group when the system disk storage space is tight. And the restart protection file group can be generated in stages according to the use status of the system disk to avoid generating a large number of restart protection file groups at one time, which affects the normal use of the Linux system.

[0052] Based on the above embodiments, the device further includes: The space occupancy rate determination module is used to determine the space occupancy rate of the current system disk when detecting the event of deleting the restart protection file during the previous shutdown; A slow recovery state determination module, configured to determine a slow recovery state when the space occupancy rate is greater than a preset occupancy rate threshold; The recovery attempt module is used to record the number of system restarts when the system is in a slow recovery state, and when the number of system restarts reaches a preset number threshold, attempt to restore the restart protection file in the restart protection file group.

[0053] Based on the above embodiments, the first generating module includes: A determination unit is used to determine the number of restart protection file groups to be generated according to the recorded number of system startups. This is accomplished by: , where N is the total number of restart protection file groups, M is the number of system startups, and X is the total number of system startups required to generate all restart protection file groups.

[0054] Based on the above embodiments, the first generating module includes: A padding file generating unit, used for generating a corresponding number of padding files with zero information volume and a preset size; An alarm signature file generating unit, used for generating an alarm signature file; The first field writing unit is used to write the [RemoveFileLastReboot] field into the alarm feature file, and adjust the state value of the [RemoveFileLastReboot] field according to the detection result of the last shutdown, deletion and restart protection file group event.

[0055] Based on the above embodiments, the first generating module includes: A quick establishment feature file generation unit, used for generating a quick establishment feature file; The second field writing unit is used to write the [FileNum] field into the quick creation feature file, and write the total number of the preset restart protection files as a parameter into the [FileNum] field; The third field writing unit is used to write the [Estimated] field into the quick creation feature file, and write the expected total number of times of generating all restart protection file groups as a parameter into the [Estimated] field; The fourth field writing unit is used to write the [StartsNum] field to the quick establishment feature file, and after each start, write the recorded start times as a parameter into the [StartsNum] field; The fourth field writing unit is used to write the [DiskWaterMark] field into the quick establishment feature file, and write the second space threshold corresponding to the disk space barrier state as a parameter into the [DiskWaterMark] field; The fifth field writing unit is used to write the [NormalEstablishNum] field to the fast establishment feature file, and write the number of file blocks established each time the disk space barrier state is hit as a parameter into the [NormalEstablishNum] field.

[0056] Based on the above embodiments, the first generating module includes: The sixth field writing unit is used to write [Finished] to the quick creation feature file, which is used to mark the completion status of generating a preset number of restart protection file groups on the system disk.

[0057] Based on the above embodiments, the second generating module includes: The seventh field write unit is used to write [TouchOff] to the quick establishment feature file to mark whether the restart protection mechanism is triggered; The eighth field writing unit is used to write [RebootNumber] to the quick creation feature file, which is used to mark the number of the restored restart protection file; The ninth field is a write unit, which is used to write [RecoverSusecess] to the quick creation feature file, and is used to mark whether the restart protection file to be restored is successfully created.

[0058] The Linux system startup protection device provided in the embodiment of the present invention can execute the Linux system startup protection method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0059] Embodiment 4 Embodiment 4 of the present invention further provides a storage medium containing computer executable instructions, and when the computer executable instructions are executed by a computer processor, they are used to execute any of the Linux system startup protection methods provided in the above embodiments.

[0060] The computer storage medium of the embodiment of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. 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 thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device.

[0061] 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.

[0062] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0063] Computer program code for performing the operation of the present invention 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 device. In the case of 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).

[0064] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A Linux system startup protection method, characterized in that: include: Set the size of the restart protection file group according to the storage space of the system disk; When the available storage space of the system disk is greater than a preset first space threshold, it is determined to be in a fast recording state. When it is in the fast recording state, the number of restart protection files in the restart protection file group is determined according to the recorded number of system startups, and a corresponding number of restart protection files are generated in the system disk; When the available storage space of the system disk is less than a preset second space threshold, it is determined that the disk space barrier state is hit; When the disk space barrier is hit, a preset number of restart protection files are generated on the system disk each time the system starts, and the preset number is greater than the maximum number of restart protection files generated in the fast recording state.

2. The method according to claim 1, characterized in that The method further comprises: When the event of deleting the restart protection file at the last shutdown is detected, the space occupancy rate of the current system disk is determined; When the space occupancy rate is greater than a preset occupancy rate threshold, determining it to be in a slow recovery state; In the slow recovery state, the number of system restarts is recorded, and when the number of system restarts reaches a preset number threshold, an attempt is made to restore the restart protection file in the restart protection file group.

3. The method according to claim 1, characterized in that The method further comprises: Before each system shutdown, check whether the system partition is in the resource exhaustion stage. If it is in the resource exhaustion stage, delete the protection files in the restart protection file group.

4. The method according to claim 1, characterized in that: The step of determining the number of restart protection file groups to be generated according to the recorded number of system startups includes: This is accomplished by: , where N is the total number of restart protection file groups, M is the number of system startups, and X is the total number of system startups required to generate all restart protection file groups.

5. The method according to claim 1, characterized in that The generating of a corresponding number of restart protection files on the system disk includes: Generate a corresponding number of padding files with zero information content and a preset size; Generate alarm signature files; The [RemoveFileLastReboot] field is written into the alarm feature file, and the state value of the [RemoveFileLastReboot] field is adjusted according to the detection result of the previous shutdown, deletion and restart protection file group event.

6. The method according to claim 1, characterized in that When the system is in the fast recording state, generating a corresponding number of restart protection files on the system disk also includes: Generate a quick build signature file; Write the [FileNum] field to the quick creation feature file, and write the total number of the preset restart protection files as a parameter into the [FileNum] field; Write the [Estimated] field to the quick creation feature file, and write the expected total number of times to generate all restart protection file groups as a parameter to the [Estimated] field; Write the [StartsNum] field to the quick build feature file, and after each start, write the recorded start times as a parameter to the [StartsNum] field; Write the [DiskWaterMark] field to the quick creation feature file, and write the second space threshold corresponding to the disk space barrier state as a parameter into the [DiskWaterMark] field; The [NormalEstablishNum] field is written to the fast establishment feature file, and the number of file blocks established each time the disk space barrier state is hit is written as a parameter into the [NormalEstablishNum] field.

7. The method according to claim 6, characterized in that When the disk space barrier state is hit, each time the system is started, a preset number of restart protection files are generated on the system disk, and the method further includes: [Finished] is written to the quick creation feature file to mark the completion status of generating a preset number of restart protection file groups on the system disk.

8. The method according to claim 2, characterized in that: When the system is in the fast recording state, generating a corresponding number of restart protection files on the system disk also includes: Write [TouchOff] to the quick creation feature file to mark whether the restart protection mechanism is triggered; Write [RebootNumber] to the quick creation feature file to mark the number of the restored restart protection files; Write [RecoverSusecess] to the quick creation feature file to mark whether the restart protection file to be restored is created successfully.

9. A Linux system startup protection device, characterized in that: include: A setting module, used to set the size of the restart protection file group according to the storage space of the system disk; A first generating module is used to determine that the system disk is in a fast recording state when the available storage space is greater than a preset first space threshold, and when in the fast recording state, determine the number of restart protection files in the restart protection file group to be generated according to the recorded number of system startups, and generate a corresponding number of restart protection files in the system disk; A determination module, configured to determine that a disk space barrier state is hit when the available storage space of the system disk is less than a preset second space threshold; The second generation module is used to generate a preset number of restart protection files on the system disk each time the system starts when the disk space barrier state is hit, and the preset number is greater than the maximum number of restart protection files generated in the fast recording state.

10. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to execute the Linux system startup protection method as described in any one of claims 1-8 when executed by a computer processor.

Citation Information

Patent Citations

  • Background real-time monitoring processing method for data

    CN102810073A

  • Method and device for restarting intelligent terminal, and intelligent terminal

    CN106598563A

  • Intelligent gateway disaster recovery method and device, electronic equipment and storage medium

    CN114866404A

  • Vehicle machine system restarting method, device and equipment and storage medium

    CN117493079A

  • Embedded system restarting method and device, electronic equipment and readable storage medium

    CN117667258A