File system repair method, device, storage medium and electronic device
By automatically performing file system maintenance during the startup process of the operating system, the problem of file loss caused by manual repair is solved, the automatic file system repair capability of the smart server is improved, and data security is ensured.
Patent Information
- Application Number
- CN202410998252.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-07-24
AI Technical Summary
In smart servers, manual file system repair can easily lead to the loss of key files, and existing technologies cannot effectively solve this problem.
By automatically performing maintenance operations on the target file system in the virtual file system during the startup process of the operating system, and using the service manager to determine file system abnormalities and repair them, the automatic repair capability of the file system is ensured.
It effectively avoids the loss of key files caused by manual repair, improves the automatic repair capability of the file system, and ensures the stability of the file system and data security in the smart server.
Smart Images

Figure CN118519834B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of intelligent servers, and in particular, to a method, device, storage medium and electronic device for repairing a file system. Background Art
[0002] In the AI (Artificial Intelligence) intelligent era, intelligent servers that run intelligent services such as analysis, calculation, and training are deployed in computer rooms. Abnormal power outages or some other reasons may cause the file system of the intelligent server operating system to be abnormal and unable to start normally. Taking the Linux operating system as an example, after the file system is damaged, it will not be able to be mounted, and the file system will enter emergency maintenance mode and cannot start normally. In related technologies, it is generally repaired manually, and manual repair methods are prone to cause the loss of key files. In intelligent business scenarios, the security of key data is very important. Once certain configurations or data are lost, it will bring huge losses.
[0003] Currently, no effective solution has been proposed for the above-mentioned problems existing in the related technologies. Summary of the invention
[0004] The embodiments of the present invention provide a method, device, storage medium and electronic device for repairing a file system, so as to at least solve the problem of easy loss of key files caused by manually repairing a file system in the related art.
[0005] According to one embodiment of the present invention, a method for repairing a file system is provided, comprising: reading a value of a target field in a predetermined file stored in an operating system for indicating whether to perform a target repair function on a target file system, wherein the target repair function is implemented by executing a first repair command by a target service of a first service manager loaded under a first file system, and the first file system is a virtual file system; when it is determined that the value of the target field is a first value and the value of a first parameter in a loader for indicating whether to repair a second file system is a second value, determining whether the target file system has an abnormality through the target repair function, wherein the second file system is a real file system included in a hard disk, and the second file system includes the target file system; when it is determined that the target file system has an abnormality, repairing the target file system through the target repair function.
[0006] In an exemplary embodiment, after determining whether the target file system has an abnormality through the target repair function, the method further includes: mounting the target file system when it is determined that the target file system is normal, or mounting the target file system after determining that the target file system has an abnormality and repairing the target file system through the target repair function; and after completing the mounting of the target file system, switching the currently running first file system to the target file system to instruct the target file system to repair a third file system, wherein the third file system is a file system other than the target file system included in the second file system.
[0007] In an exemplary embodiment, after switching the currently running first file system to the target file system, the method further includes: the second service manager loaded under the target file system reads the value of the first field stored in the operating system for indicating whether to perform a first maintenance function on the third file system, wherein the first maintenance function is implemented by executing a second maintenance command by the first service in the target file system; when the second service manager determines that the value of the first field is a third value and the value of the second parameter in the loader for indicating whether to perform maintenance on the third file system is a fourth value, determines whether there is an abnormality in the third file system through the first maintenance function; when the second service manager determines that there is an abnormality in the third file system, the second service manager repairs the third file system through the first maintenance function.
[0008] In an exemplary embodiment, after determining whether the third file system has an abnormality through the first repair function, the method further includes: the second service manager mounts the third file system when determining that the third file system is normal; or, the second service manager mounts the third file system after determining that the third file system has an abnormality and repairing the third file system through the first repair function.
[0009] In an exemplary embodiment, the method also includes: a third service manager loaded under the operating system monitors changes in the target file of the second file system, wherein the target file is stored in a target path pre-allocated by the path allocation service of the third service manager; when the third service manager detects changes in the target file, the target file is backed up in a specific partition in the disk, wherein the specific partition includes other partitions in the disk except the file system partition, and the file system partition is used to store files of the second file system.
[0010] In an exemplary embodiment, the method also includes: the third service manager determines whether the second file system has been repaired; if the third service manager determines that the second file system has been repaired, the third service manager determines whether the target file stored under the target path is missing; if the third service manager determines that the target file stored under the target path is missing, the third service manager obtains the target file backed up under the specific partition; the third service manager replaces the missing target file with the target file backed up under the specific partition.
[0011] In an exemplary embodiment, when the third service manager determines that the target file stored under the target path is missing and before obtaining the target file backed up under the specific partition, the method also includes: the third service manager suspends monitoring of changes in the target file of the second file system; after the third service manager replaces the missing target file with the target file backed up under the specific partition, the method also includes: the third service manager continues to monitor changes in the target file of the second file system.
[0012] According to another embodiment of the present invention, a file system repair device is provided, comprising: a first reading module, used to read the value of a target field in a predetermined file stored in an operating system for indicating whether to perform a target repair function on a target file system, wherein the target repair function is implemented by executing a first repair command by a target service of a first service manager loaded under a first file system, and the first file system is a virtual file system; a first determining module, used to determine whether there is an abnormality in the target file system through the target repair function when it is determined that the value of the target field is a first value and the value of a first parameter in a loader for indicating whether to perform repair on a second file system is a second value, wherein the second file system is a real file system included in a hard disk, and the second file system includes the target file system; and a first repairing module, used to repair the target file system through the target repair function when it is determined that there is an abnormality in the target file system.
[0013] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any one of the above method embodiments when run.
[0014] According to yet another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0015] Through the present invention, since the repair operation of the target file system is automatically performed in the virtual file system during the startup of the operating system, the problem of easy loss of key files caused by manual repair of the file system in the related art can be solved, thereby achieving the effect of improving the automatic repair capability of the file system. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 is a hardware structure block diagram of a method for repairing a file system according to an embodiment of the present invention;
[0017] Figure 2 The process of the method for repairing a file system according to an embodiment of the present invention is as follows Figure 1 ;
[0018] Figure 3 The process of the method for repairing a file system according to an embodiment of the present invention is as follows Figure 2 ;
[0019] Figure 4 The process of the method for repairing a file system according to an embodiment of the present invention is as follows Figure 3 ;
[0020] Figure 5 It is a structural block diagram of a file system repair device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0021] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with the embodiments.
[0022] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0023] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a file system repair method according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0024] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for repairing the file system in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0025] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0026] In this embodiment, a method for repairing a file system running on an operating system is provided. Figure 2 The process of the method for repairing a file system according to an embodiment of the present invention is as follows Figure 1 ,like Figure 2 As shown, the process includes the following steps:
[0027] Step S202, reading a value of a target field in a predetermined file stored in the operating system for indicating whether to execute a target repair function on a target file system, wherein the target repair function is implemented by executing a first repair command by a target service of a first service manager loaded under a first file system, and the first file system is a virtual file system;
[0028] Step S204, when it is determined that the value of the target field is the first value and the value of the first parameter in the loader for indicating whether to repair the second file system is the second value, determining whether the target file system is abnormal through the target repair function, wherein the second file system is a real file system included in the hard disk, and the second file system includes the target file system;
[0029] Step S206: When it is determined that the target file system is abnormal, the target file system is repaired by using the target repair function.
[0030] In the above steps, the operating system includes but is not limited to: Linux, Windows Server, VMware ESXi, FreeBSD, OpenBSD, Oracle Solaris, IBM AIX, HP-UX, etc. In this application, the Linux system is taken as an example to describe this embodiment and other optional embodiments in detail.
[0031] In step S202, the predetermined file includes but is not limited to: / etc / fstab file, the predetermined file is used to store information of the file system that needs to be mounted when the operating system is started; the first file system includes but is not limited to: a temporary file system used to load necessary drivers and file system modules when the kernel is started; the first file system includes but is not limited to: a virtual file system generated by the kernel, such as initramfs, etc.; the target file system includes but is not limited to: a root file system; the target field includes but is not limited to: a passno field; the first service manager includes but is not limited to: systemd; the target service includes but is not limited to: systemd-fsck@.service.
[0032] In step S204, the first value includes but is not limited to: a value greater than 0, a specific letter or other types of characters, for example, the first value is 1, the first value is a, the first value is *, etc.; the loader includes but is not limited to: a boot loader, for example, GRUB (GNU GRand Unified Bootloader, GNU boot loader); the value of the first parameter includes but is not limited to the second value: fsck.mode=force and fsck.repair=yes, of course, the second value can also be set to other values, for example, fsck.mode=force and fsck.repair=ok, for example, fsck.mode=a and fsck.repair=a, etc.; the settings of the above types of values can be flexibly adjusted. In addition, the second file system includes but is not limited to: a root file system, a home file system, a boot file system, etc.; the value of the first parameter is read by the operating system during the kernel loading process; whether the value of the target field is the first value and the value of the first parameter in the loader for indicating whether to repair the second file system is the second value is satisfied at the same time includes but is not limited to: judging by systemd-fsck@.service. Exemplarily, the execution order between "determining the value of the first parameter in the loader for indicating whether to repair the second file system" and step S202 is not limited. Step S202 can be executed first and then the value of the first parameter can be determined, or the value of the first parameter can be determined first and then step S202 can be executed, or the value of the first parameter can be determined while executing step S202.
[0033] Through the above steps, since the target file system maintenance operation is automatically performed in the virtual file system during the startup of the operating system, the problem of easy loss of key files caused by manual repair of the file system in the related technology can be solved, thereby achieving the effect of improving the automatic repair capability of the file system.
[0034] The execution subject of the above steps may be an operating system, a base station equipped with an operating system, a terminal, or other equipment or system with similar processing capabilities, etc., but is not limited thereto.
[0035] In an optional embodiment, after determining whether the target file system has an abnormality through the target repair function, the method further includes: mounting the target file system when it is determined that the target file system is normal, or mounting the target file system after determining that the target file system has an abnormality and repairing the target file system through the target repair function; and after completing the mounting of the target file system, switching the currently running first file system to the target file system to instruct the target file system to repair a third file system, wherein the third file system is a file system other than the target file system included in the second file system.
[0036] In the above steps, mounting the target file system includes but is not limited to: mounting the target file system by systemd loaded under the first file system; switching the currently running first file system to the target file system includes but is not limited to: switching by initrd-switch-root.service of systemd loaded under the first file system; the third file system includes but is not limited to: home file system, boot file system, etc.
[0037] In an optional embodiment, after switching the currently running first file system to the target file system, the method further includes: a second service manager loaded under the target file system reads a value of a first field stored in the operating system for indicating whether to perform a first maintenance function on the third file system, wherein the first maintenance function is implemented by executing a second maintenance command by the first service in the target file system; when the second service manager determines that the value of the first field is a third value and the value of the second parameter in the loader for indicating whether to perform maintenance on the third file system is a fourth value, determines through the first maintenance function whether there is an abnormality in the third file system; when the second service manager determines that there is an abnormality in the third file system, the second service manager repairs the third file system through the first maintenance function.
[0038] In the above steps, the second service manager includes but is not limited to: systemd; the operating system includes but is not limited to: Linux operating system; the first field includes but is not limited to: the passno field stored in the / etc / fstab file of the operating system for indicating whether to start the maintenance function of systemd-fsck@.service for the third file system; the first service includes but is not limited to: systemd-fsck@.service of systemd loaded under the root file system; the third value includes but is not limited to: a value greater than 0, a specific letter or other types of characters, for example, the third value is 1, the third value is a, the third value is *, etc., the value of the second parameter is a fourth value including but not limited to: fsck.mode=force and fsck.repair=yes, of course, the fourth value can also be set to other values, for example, fsck.mode=force and fsck.repair=ok, for example, fsck.mode=a and fsck.repair=a, etc.; the settings of the above-mentioned various values can be flexibly adjusted, the second parameter and the first parameter can be the same parameter, or can be different parameters configured independently, and accordingly, the fourth value and the second value can be the same or different.
[0039] In an optional embodiment, after determining whether the third file system has an abnormality through the first repair function, the method further includes: the second service manager mounts the third file system when determining that the third file system is normal; or, the second service manager mounts the third file system after determining that the third file system has an abnormality and repairing the third file system through the first repair function.
[0040] In the above steps, mounting the third file system includes but is not limited to: mounting the third file system by systemd loaded under the root file system.
[0041] In an optional embodiment, the method further includes: a third service manager loaded under the operating system monitors changes in a target file of the second file system, wherein the target file is stored in a target path pre-allocated by a path allocation service of the third service manager; when the third service manager detects changes in the target file, the target file is backed up in a specific partition in the disk, wherein the specific partition includes other partitions in the disk except the file system partition, and the file system partition is used to store files of the second file system.
[0042] In the above steps, the third service manager includes but is not limited to: systemd; the target files include but are not limited to: configuration files of business programs, important video, audio, picture files, etc., the target files can be pre-set, and the target path includes but is not limited to: a path allocation service of systemd that can be pre-set and can be allocated by the operating system; the method for the third service manager to monitor whether the target file has changed includes but is not limited to: the file-monitor-backup.service of systemd loaded under the operating system compares the current MD5 value of the target file with the MD5 value obtained previously to determine whether the target file has changed; the specific partitions include but are not limited to: a specific area for storing backup data, for example, a backup file storage area, etc.
[0043] In an optional embodiment, the method also includes: the third service manager determines whether the second file system has been repaired; when the third service manager determines that the second file system has been repaired, determines whether the target file stored under the target path is missing; when the third service manager determines that the target file stored under the target path is missing, obtains the target file backed up under the specific partition; and the third service manager replaces the missing target file with the target file backed up under the specific partition.
[0044] In the above steps, the third service manager determines whether the second file system has been repaired, including but not limited to: systemd loaded under the Linux operating system determines whether the second file system has been repaired by reading logs; the method for the third service manager to determine whether the target file is missing is not limited to: file-monitor-restore.service of systemd loaded under the Linux operating system compares the file name of the target file before and after, compares the current MD5 value of the target file with the MD5 value obtained previously, and determines whether the target file is missing based on the comparison result.
[0045] In an optional embodiment, when the third service manager determines that the target file stored under the target path is missing and before obtaining the target file backed up under the specific partition, the method also includes: the third service manager suspends monitoring of changes in the target file of the second file system; after the third service manager replaces the missing target file with the target file backed up under the specific partition, the method also includes: the third service manager continues to monitor changes in the target file of the second file system.
[0046] In the above embodiment, when the systemd loaded under the Linux operating system determines that the target file stored under the target path is missing, it suspends monitoring the changes of the target file of the second file system through file-monitor-backup.service, uses file-monitor-restore.service to repair the target file, and after completing the repair of the target file, continues to pull up file-monitor-backup.service to monitor the changes of the target file of the second file system.
[0047] The following is an overall description of how the present invention repairs a file system in conjunction with a specific embodiment:
[0048] Embodiment 1:
[0049] In this embodiment, a method for repairing a file system running on an operating system is provided. Figure 3 The process of the method for repairing a file system according to an embodiment of the present invention is as follows Figure 2 ,like Figure 3 As shown, the process includes the following steps:
[0050] Step S302, Uuboot\UEFI initializes the device hardware;
[0051] Step S304, the kernel is loaded, and the parameters fsck.mode=force fsck.repair=yes configured in grub for indicating to repair the file system are read;
[0052] Step S306, initializing the first-level root file system Initramfs;
[0053] Step S308, loading the first-level root file system in Readonly mode;
[0054] Step S310, systemd is started, and the passno field corresponding to the secondary real root file system recorded in / etc / fstab is read. If the passno field is greater than 0, the check service is started;
[0055] Step S312, Systemd-fsck@.service checks the secondary real root file system to determine whether the secondary real root file system is normal. If it is abnormal, jump to step S314; if it is normal, jump to step S316;
[0056] Step S314, repairing the secondary root file system;
[0057] Step S316, if normal or repair is completed, mount the secondary real root file system and switch to the secondary real root file system;
[0058] Step S318, Systemd starts the service and target, reads the values of the passno fields corresponding to other real file systems recorded in / etc / fstab, and starts the check service for other real file systems whose passno field values are greater than 0;
[0059] Step S320, Systemd-fsck@.service checks the real file systems of other partitions except the root partition, and determines whether the real file systems of other partitions are normal. If not, jump to step S322; if normal, jump to step S324;
[0060] Step S322, repairing the abnormal real file system of other partitions;
[0061] Step S324, mounting the real file system of other partitions that are normal or repaired;
[0062] Step S326, when the operating system is started, file-monitor-restore.service detects whether the real file system has been repaired. If yes, jump to step S328, if not, end;
[0063] Step S328, verifying the preset key path file;
[0064] Step S330, determine whether the file is missing, if yes, jump to step S332;
[0065] Step S332, restore the missing files from the backup files.
[0066] In step S304, grub is started and the kernel is loaded. During the kernel loading process, the parameters configured in grub are read, and fsck.mode=force fsck.repair=yes is read;
[0067] In step S306, the first-level root file system initramfs is initialized in readonly mode; when file-monitor-restore.service detects that a file is missing, file-monitor-backup.service suspends monitoring and restores the file by copying the missing file back from the original backup file. After the restoration is completed, file-monitor-backup.service is started to continue monitoring the key path file.
[0068] Through the above steps, due to the addition of file-monitor-backup.service and file-monitor-restore.service services, after the real file system is repaired, the key location files of the repaired real file system will be checked to avoid the problem of missing key files. In the initramfs stage, the secondary real root file system is repaired to ensure the normality of the secondary real root file system, so as to facilitate the subsequent inspection of the real file systems of other partitions in / etc / fstab through the secondary real root file system, so that the repair is more comprehensive.
[0069] Embodiment 2:
[0070] In this embodiment, a method for repairing a file system running on an operating system is provided. Figure 4 The process of the method for repairing a file system according to an embodiment of the present invention is as follows Figure 3 ,like Figure 4 As shown, the process includes the following steps:
[0071] Step S402, monitoring the preset key path files through file-monitor-backup.service;
[0072] Step S404, determining whether the file has changed;
[0073] Step S406: back up the changed files.
[0074] In the above steps, during the normal operation of the system, the pre-configured key position files are monitored by the file monitoring backup service file-monitor-backup.service. When changes are detected in the files, the changed files are backed up. During the system startup process, if an abnormality is detected in the file system, the abnormal file system is repaired, and after the repair is completed, the pre-set key position files are verified by file-monitor-restore.service. When the file is found to be missing, the missing part is restored from the original backed up file. After the system is running normally, the file-monitor-backup.service service is started to continue monitoring the files in the key file directory. When changes are detected in the files, the changed files are continued to be backed up.
[0075] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0076] In this embodiment, a file system repair device is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0077] Figure 5 is a structural block diagram of a file system repair device according to an embodiment of the present invention, such as Figure 5As shown, the device includes: a first reading module 52, which is used to read the value of a target field in a predetermined file stored in an operating system for indicating whether to perform a target repair function on a target file system, wherein the target repair function is implemented by executing a first repair command by a target service of a first service manager loaded under a first file system, and the first file system is a virtual file system; a first determining module 54, which is used to determine whether there is an abnormality in the target file system through the target repair function when it is determined that the value of the target field is a first value and the value of a first parameter in the loader for indicating whether to perform a repair on a second file system is a second value, wherein the second file system is a real file system included in a hard disk, and the second file system includes the target file system; a first repairing module 56, which is used to repair the target file system through the target repair function when it is determined that there is an abnormality in the target file system.
[0078] In an optional embodiment, the device also includes: a first mounting module, which is used to mount the target file system if it is determined that the target file system is normal after determining whether the target file system is abnormal through the target repair function, or to mount the target file system after determining that the target file system is abnormal and repairing the target file system through the target repair function; and a switching module, which is used to switch the currently running first file system to the target file system after completing the mounting of the target file system, so as to instruct the target file system to repair a third file system, wherein the third file system is a file system other than the target file system included in the second file system.
[0079] In an optional embodiment, the second service manager loaded under the target file system also includes: a second reading module, which is used to read the value of the first field stored in the operating system for indicating whether to perform a first maintenance function on the third file system after switching the currently running first file system to the target file system, wherein the first maintenance function is implemented by executing a second maintenance command by the first service in the target file system; a second determination module, which is used to determine whether there is an abnormality in the third file system through the first maintenance function when it is determined that the value of the first field is a third value and the value of the second parameter in the loader for indicating whether to perform maintenance on the third file system is a fourth value; and a second repair module, which is used to repair the third file system through the first repair function when it is determined that there is an abnormality in the third file system.
[0080] In an optional embodiment, the second service manager loaded under the target file system also includes: a second mounting module, which is used to mount the third file system after determining whether the third file system is abnormal through the first repair function and if it is determined that the third file system is normal; or, the second service manager mounts the third file system after determining that the third file system is abnormal and repairing the third file system through the first repair function.
[0081] In an optional embodiment, the third service manager loaded under the operating system also includes: a monitoring module, used to monitor changes in the target file of the second file system, wherein the target file is stored in a target path pre-allocated by the path allocation service of the third service manager; a backup module, used to back up the target file in a specific partition in the disk when changes to the target file are detected, wherein the specific partition includes other partitions in the disk except the file system partition, and the file system partition is used to store files of the second file system.
[0082] In an optional embodiment, the third service manager loaded under the operating system also includes: a third determination module, used to determine whether the second file system has been repaired; a fourth determination module, used to determine whether the target file stored under the target path is missing when it is determined that the second file system has been repaired; an acquisition module, used to acquire the target file backed up under the specific partition when it is determined that the target file stored under the target path is missing; and a replacement module, used to replace the missing target file with the target file backed up under the specific partition.
[0083] In an optional embodiment, the third service manager loaded under the operating system also includes: a pause module, which is used to pause monitoring the changes of the target file of the second file system when it is determined that the target file stored under the target path is missing and before obtaining the target file backed up under the specific partition; and a continue module, which is used to continue monitoring the changes of the target file of the second file system after replacing the missing target file with the target file backed up under the specific partition.
[0084] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0085] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0086] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0087] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0088] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0089] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0090] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0091] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for repairing a file system, characterized in that: include: During the process of operating system startup, automatically reading a value of a target field in a predetermined file stored in the operating system for indicating whether to execute a target repair function on a target file system, wherein the target repair function is implemented by executing a first repair command by a target service of a first service manager loaded under a first file system, and the first file system is a virtual file system; In a case where it is determined that the value of the target field is a first value and the value of a first parameter in the loader for indicating whether to repair the second file system is a second value, determining whether the target file system is abnormal through the target repair function, wherein the second file system is a real file system included in the hard disk, and the second file system includes the target file system; When it is determined that the target file system is abnormal, repairing the target file system through the target repair function; The method further comprises: a third service manager loaded under the operating system determines whether a target file of the target file system stored under a target path is missing, wherein the third service manager is used to back up the changed target file under a specific partition in the disk when detecting that the target file of the target file system has changed, the target path is a path pre-allocated by a path allocation service of the third service manager, the specific partition includes other partitions in the disk except the file system partition, and the file system partition is used to store files of the second file system; When determining that the target file of the target file system is missing, the third service manager obtains the target file of the target file system backed up in the specific partition, and replaces the missing target file with the backed-up target file.
2. The method according to claim 1, characterized in that After determining whether the target file system is abnormal through the target maintenance function, the method further includes: If it is determined that the target file system is normal, the target file system is mounted; or, if it is determined that the target file system is abnormal and the target file system is repaired by the target repair function, the target file system is mounted; When the target file system is mounted, the currently running first file system is switched to the target file system to instruct the target file system to overhaul the third file system, wherein the third file system is other file systems included in the second file system except the target file system.
3. The method according to claim 2, characterized in that After switching the currently running first file system to the target file system, the method further includes: The second service manager loaded under the target file system reads the value of the first field stored in the operating system for indicating whether to execute a first maintenance function on the third file system, wherein the first maintenance function is implemented by executing a second maintenance command by the first service in the target file system; The second service manager determines whether the third file system is abnormal by using the first repair function when it is determined that the value of the first field is a third value and the value of the second parameter in the loader for indicating whether to repair the third file system is a fourth value; When determining that the third file system is abnormal, the second service manager repairs the third file system through the first repair function.
4. The method according to claim 3, characterized in that After determining whether the third file system is abnormal through the first maintenance function, the method further includes: The second service manager mounts the third file system when determining that the third file system is normal; or The second service manager mounts the third file system after determining that the third file system is abnormal and repairing the third file system through the first repair function.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: The third service manager monitors changes in target files of a third file system, wherein the target files of the third file system are stored in the target path, and the third file system is a file system other than the target file system included in the second file system; When the third service manager detects that the target file of the third file system has changed, the third service manager backs up the target file of the third file system in a specific partition in the disk.
6. The method according to claim 5, characterized in that The method further comprises: The third service manager determines whether the third file system has been repaired; The third service manager determines, when determining that the third file system has been repaired, whether a target file of the third file system stored in the target path is missing; The third service manager obtains the target file of the third file system backed up in the specific partition when determining that the target file of the third file system stored in the target path is missing; The third service manager replaces the missing target file of the third file system with the target file of the third file system backed up in the specific partition.
7. The method according to claim 6, characterized in that When the third service manager determines that the target file of the second file system stored in the target path is missing and before obtaining the target file backed up in the specific partition, the method further includes: the third service manager suspending monitoring of changes in the target file of the second file system; After the third service manager replaces the missing target file of the second file system with the target file backed up in the specific partition, the method further includes: the third service manager continues to monitor changes in the target file of the second file system.
8. A file system repair device, characterized in that: include: A first reading module is used to automatically read, during the process of operating system startup, a value of a target field in a predetermined file stored in the operating system for indicating whether to execute a target repair function on a target file system, wherein the target repair function is implemented by executing a first repair command by a target service of a first service manager loaded under a first file system, and the first file system is a virtual file system; a first determining module, configured to determine whether the target file system has an abnormality by using the target repair function when it is determined that the value of the target field is a first value and the value of a first parameter in the loader for indicating whether to repair the second file system is a second value, wherein the second file system is a real file system included in the hard disk, and the second file system includes the target file system; A first repair module, configured to repair the target file system by using the target repair function when determining that the target file system is abnormal; The third service manager loaded under the operating system is used to perform the following operations: Determine whether a target file of the target file system stored under a target path is missing, wherein the third service manager is used to back up the changed target file under a specific partition in the disk when detecting that the target file of the target file system has changed, the target path is a path pre-allocated by the path allocation service of the third service manager, the specific partition includes other partitions in the disk except the file system partition, and the file system partition is used to store files of the second file system; When it is determined that the target file of the target file system is missing, the target file of the target file system backed up in the specific partition is obtained, and the missing target file is replaced with the backed up target file.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 7 are implemented.
