CN113094107B - Data protection method, device, equipment and computer storage medium - Google Patents

Data protection method, device, equipment and computer storage medium Download PDF

Info

Publication number
CN113094107B
CN113094107B CN202110292122.2A CN202110292122A CN113094107B CN 113094107 B CN113094107 B CN 113094107B CN 202110292122 A CN202110292122 A CN 202110292122A CN 113094107 B CN113094107 B CN 113094107B
Authority
CN
China
Prior art keywords
file system
original kernel
monitoring thread
loading
boot loader
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110292122.2A
Other languages
Chinese (zh)
Other versions
CN113094107A (en
Inventor
李国辉
赵含磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Saifang Technology Co ltd
Original Assignee
Shenzhen Saifang Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Saifang Technology Co ltd filed Critical Shenzhen Saifang Technology Co ltd
Priority to CN202110292122.2A priority Critical patent/CN113094107B/en
Publication of CN113094107A publication Critical patent/CN113094107A/en
Application granted granted Critical
Publication of CN113094107B publication Critical patent/CN113094107B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the invention relates to the technical field of data storage, and discloses a data recovery and protection method, a device, equipment and a readable medium, wherein the method comprises the following steps: after the target device is detected to be powered on, loading and starting a boot loader; loading the original kernel through a boot loader; checking the original kernel; when the original kernel is successfully checked, starting the original kernel and performing write protection on the boot loader; after the original kernel is started, starting a preset monitoring thread and loading a file system; determining whether the file system is loaded in a preset time or not through a monitoring thread; when the file system is determined to be loaded within the preset time, the file system is determined to be started. By the mode, the embodiment of the invention improves the safety of the stored data.

Description

Data protection method, device, equipment and computer storage medium
Technical Field
The embodiment of the invention relates to the technical field of data storage, in particular to a data protection method, a device, equipment and a computer storage medium.
Background
NANDFlash devices are one type of Flash Memory devices, and Flash Memory devices are non-volatile storage devices that, during use, can cause bad blocks in the Memory device due to hardware aging, some special reasons (e.g., sudden power down). And bad blocks may cause some functions of the system using the storage device to be not used normally, and in severe cases, the system may not be started normally. In order to avoid bad blocks from affecting normal use of the memory as much as possible, data protection may be performed to avoid bad blocks from being generated, or data recovery may be performed when bad blocks exist.
The method for protecting data in the prior art is generally as follows: the problem of setting the whole system to read-only or writing protection of partial addresses is that: setting the entire system to read-only is not desirable for systems that need to write data, and the address that is write-protected cannot be subsequently upgraded online. The method for recovering the data is generally as follows: the method comprises the steps of respectively carrying out redundancy backup on a kernel and a file system, checking the kernel and the file system before starting the kernel, and replacing according to the backup when the checking is failed, wherein the problem is that: verification for a file system takes a long time, which results in a long system start-up time, and when the file system is readable and writable, the verification method is not applicable.
These problems result in limitations in the application range of data protection in the prior art, and thus, the security of data storage is not high.
Disclosure of Invention
In view of the above problems, an embodiment of the present invention provides a data protection method, which is used to solve the problem in the prior art that the security of data storage is not high.
According to an aspect of an embodiment of the present invention, there is provided a data protection method, including:
loading and starting the boot loader after detecting that the target device is powered on;
Loading the original kernel through the boot loader;
checking the original kernel;
when the original kernel is successfully verified, starting the original kernel and performing write protection on the boot loader;
after the original kernel is started, starting a preset monitoring thread and loading the file system;
determining whether the file system is completely loaded in a preset time or not through the monitoring thread;
and when the file system is determined to be completely loaded in the preset time, determining that the file system is started.
In an alternative, the method further comprises:
dividing a backup partition in the target equipment, wherein an original kernel image corresponding to the original kernel is stored in the backup partition, and write protection is started for a boot loader in the original kernel image;
after the verification of the original kernel, the method further comprises:
when the original kernel verification fails, erasing a partition where the original kernel is located;
loading the original kernel image;
and writing the original kernel image into a partition where the original kernel is located.
In an alternative manner, a file system image is also stored in the backup partition; the method further comprises the steps of:
After determining, by the monitoring thread, whether the file system is loaded in a preset time, the method includes:
when the file system is not loaded in the preset time, erasing the partition where the file system is located;
writing the file system mirror image into a partition where the file system is located;
restarting the target device.
The backup partition is also stored with a write-protection-free kernel image, and write protection of the boot starting program is not started in the write-protection-free kernel image; in an alternative, the method further comprises:
after determining that the file system has been started, the method further comprises:
detecting whether a write operation request for the boot loader is received;
when the write operation request is received, erasing the partition where the original kernel is located;
loading the non-write-protected kernel image, and writing the non-write-protected kernel image into a partition where the original kernel is located;
restarting the target device.
In an alternative, the method further comprises:
loading a preset monitoring thread initialization program through the boot loader to establish a target monitoring thread;
Loading the file system to run an initialization script included in the file system, and starting a system main program;
when the system main program is detected to be started, writing a first flag bit of a first preset value into a monitoring thread file corresponding to the target monitoring thread.
In an alternative, the method further comprises:
when the monitoring thread determines that loading is not completed in the preset time, determining whether a first flag bit of the first preset value is detected in the monitoring thread file;
and when the first flag bit of the first preset value is detected, determining that the file system is started, and terminating the monitoring thread.
In an alternative, the method further comprises:
determining address information to be protected, wherein the address information to be protected comprises a storage address of the boot loader in the target equipment;
determining a write protection instruction according to the address information to be protected, wherein the write protection instruction comprises a second flag bit, the second flag bit is set to a second preset value, and the second flag bit is used for writing and locking the address information to be protected;
and executing the write protection instruction.
According to another aspect of an embodiment of the present invention, there is provided a data protection apparatus including:
the first loading module is used for loading and starting a boot loader after the target equipment is detected to be electrified;
the second loading module is used for loading the original kernel through the boot loader;
the verification module is used for verifying the original kernel;
the first starting module is used for starting the original kernel and performing write protection on the boot loader when the original kernel is successfully verified;
the second starting module is used for starting a preset monitoring thread and loading a file system after the original kernel is started;
the monitoring module is used for determining whether the file system is loaded in a preset time or not through the monitoring thread;
and the determining module is used for determining that the file system is started when the file system is determined to be completely loaded in the preset time.
According to another aspect of an embodiment of the present invention, there is provided a data protection apparatus including:
the device comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete communication with each other through the communication bus;
The memory is configured to store at least one executable instruction that causes the processor to perform the operations of the data protection method according to any one of the foregoing embodiments.
According to yet another aspect of an embodiment of the present invention, there is provided a computer-readable storage medium having stored therein at least one executable instruction for causing a data protection apparatus to perform the operations of the data protection method according to any one of the preceding embodiments.
According to the embodiment of the invention, after the target equipment is detected to be electrified, the boot loader is loaded, the original kernel loaded in the memory is guided to be loaded through the starting of the boot loader, the original kernel loaded in the memory is checked before the starting, when the check is passed, the original kernel is started, the boot loader is started for write protection after the original kernel is started, meanwhile, a preset monitoring thread is started and a file system is loaded, whether the file system is loaded in a preset time or not is determined to be completed through the monitoring thread, and when the file system is determined to be loaded in the preset time, the file system is determined to be started.
Unlike available technology, which has long verification time and is not suitable for readable and writable file system, the present invention can monitor the file system loading condition via setting monitoring thread and thus has low data storing safety.
The foregoing description is only an overview of the technical solutions of the embodiments of the present invention, and may be implemented according to the content of the specification, so that the technical means of the embodiments of the present invention can be more clearly understood, and the following specific embodiments of the present invention are given for clarity and understanding.
Drawings
The drawings are only for purposes of illustrating embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to designate like parts throughout the figures. In the drawings:
fig. 1 shows a flow chart of a data protection method according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a data protection device according to an embodiment of the present invention;
fig. 3 shows a schematic structural diagram of a data protection device according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention may be embodied in various forms and should not be limited to the embodiments set forth herein.
First, technical terms in the embodiments of the present invention are explained:
a boot loader: a ROM (Read-Only Memory) space which can be directly addressed is reserved in a chip in the computer processing equipment, so that after the computer processing equipment is powered on, the instructions stored in the ROM space are automatically executed first, and therefore simple initialization of hardware equipment is carried out, and the boot loader is loaded into a Memory. The boot loader is used for driving and initializing all the subsequent used hardware devices, loading the kernel of the operating system from the external storage device, setting starting parameters for the kernel, and giving control right of the system to the operating system.
Original kernel: the kernel of the operating system is started by a boot loader and is responsible for the initialization of various hardware peripherals and the establishment of a multitasking runtime environment.
File system: the system is a software mechanism responsible for managing and storing file information in an operating system, and is used for organizing and distributing the space of file storage equipment, responsible for storing files, and protecting and retrieving stored files.
Fig. 1 shows a flowchart of a data protection method provided by an embodiment of the present invention, which is performed by a computer processing device. The computer processing device includes a non-volatile storage medium having a boot loader, an original kernel, and a file system stored therein.
In particular, the computer processing device may be a device such as an intelligent camera, a music player, or the like. The non-volatile storage medium may include a Flash Memory (Flash Memory) device, such as a NANDFlash device or a NOR Flash device. The NANDFlash device has been widely used because of its low cost per bit, fast speed, low power consumption, and small size, but at the same time, due to the process design of the NAND Flash device, an invalid block, i.e. a bad block, may be generated, which cannot be erased due to special reasons such as device aging or sudden power failure during use. And bad blocks may cause data in the flash memory device to be read and written abnormally.
In the embodiment of the invention, after the computer processing equipment is powered on, the computer processing equipment enters an operating system starting flow, and firstly, a boot loader, an original kernel and a file system are required to be sequentially read from a storage device into a memory, so that a CPU (Central processing Unit) of the computer processing equipment can process the boot loader, the original kernel and the file system, and finally, the equipment control right is transmitted to the operating system to enter a user mode capable of interacting with a user.
The following describes a data protection method according to the present invention in an embodiment in which the storage device is a NANDFlash device. As shown in fig. 1, the method comprises the steps of:
Step 101: and loading and starting the boot loader after the target device is detected to be powered on.
In the embodiment of the invention, the boot loader is stored in the first partition in the storage device, and the address of the first partition is preset. After the target device is powered on and started, the CPU loads a boot loader from the first partition into the memory of the target device, and starts the boot loader after loading is completed.
Step 102: loading the original kernel through the boot loader.
In the embodiment of the invention, the original kernel is stored in the second partition of the NAND Flash, and the address of the second partition is preset.
After the boot loader is started, the first physical sector of the disk is loaded into the memory, a main boot record of the hard disk is loaded and operated, and the main boot record can search the starting position of the active partition. The boot sector of the active partition is then loaded and executed, and finally the NTLDR file is loaded and initialized from the boot sector. The NTLDR file reads starting parameters, such as a driving program of equipment contained in a control console and services to be loaded, reads an original kernel from a second partition and loads the original kernel into a memory, and simultaneously sets the starting parameters for the kernel so as to give control right of the system to the original kernel of an operating system.
Step 103: and checking the original kernel.
In the embodiment of the invention, before the original kernel is started, the original kernel needs to be checked in order to ensure the integrity and the correctness of kernel data.
A specific verification process may employ an ECC (Error Correcting Code, error correction code) verification algorithm, including: when writing data into a PAGE of NAND Flash, one ECC checksum is generated every 256 bytes as a first ECC checksum, which is saved into an OOB (out-of-band) data area of PAGE. Correspondingly, when data is read from the NAND Flash, one ECC checksum is generated every 256 bytes as a second ECC checksum.
When checking, performing bit exclusive OR on the first ECC checksum and the second ECC checksum read from the OOB area, if the result is 0, indicating that no error exists (or an error which cannot be detected by an ECC algorithm exists); if 11 bits are 1 in the exclusive OR result of 3 bytes, the error of one bit exists and can be corrected; if only 1 bit is 1 in the exclusive OR result of 3 bytes, indicating that the OOB area is in error; other cases indicate uncorrectable errors.
Therefore, when the corresponding results of the OOB areas of the pages of the original kernel of the NAND Flash are all 0, the verification of the original kernel is determined to pass, otherwise, the verification of the original kernel is determined to not pass.
When the verification of the original kernel fails, it indicates that a bad block may occur in the original kernel, and if the bad block exists, the original kernel cannot be started normally, which results in that the target device cannot be started normally, so that the data in the partition of the original kernel needs to be recovered.
In the embodiment of the present invention, after the verification of the original kernel, the method further includes:
step 1031: and when the verification of the original kernel fails, erasing the partition where the original kernel is located.
Since the programming principle of NAND Flash devices is that only 1 can be written as 0, but not 0 as 1, the partition needs to be erased before the data of the partition where the original kernel is located is recovered.
It should be noted that, in step 11, the boot loader already loads the original kernel into the memory, so the second partition in the NAND Flash may be erased here.
In the embodiment of the invention, a backup partition is divided in the target device, and an original kernel image corresponding to the original kernel is stored in the backup partition.
The original kernel image is stored in a first backup partition of the backup partition and is an image file manufactured according to the original kernel. In normal use of NAND Flash, read-write operation is not involved in the partition where the original kernel image is located, so that the integrity and the correctness of the original kernel image can be ensured.
Step 1032: after the second partition erasure is completed, the original kernel image is loaded from the first backup partition.
Step 1033: and writing the original kernel image into a partition where the original kernel is located.
And the loading original kernel image in the first partition is transported to the memory for execution by the boot loader.
Step 104: and when the original kernel is successfully verified, starting the original kernel and performing write protection on the boot loader.
Considering that after the original kernel is started, the control right of the target device is already handed over to the original kernel of the operating system, at this time, the boot loader is no longer required to be read or written, in order to prevent the boot loader from being damaged or modified by improper operation or environmental factors in the subsequent use process, in the embodiment of the present invention, the boot loader may be write-protected after the original kernel is started, and step 104 specifically includes:
Step 1041: and determining address information to be protected, wherein the address information to be protected comprises a storage address of the boot loader in the target equipment.
In yet another embodiment of the present invention, in addition to write protecting the bootloader, write protecting may also be performed for storage locations corresponding to some critical data, which may include, for example, product parameters, system configuration parameters, and the like. And acquiring a storage address corresponding to the key data as information to be protected.
Step 1042: determining a write protection instruction according to the address information to be protected, wherein the write protection instruction comprises a second flag bit, the second flag bit is set to a second preset value, and the second flag bit is used for writing and locking the address information to be protected.
In the embodiment of the present invention, the write protection instruction may be a set_feature instruction provided by NAND Flash, where the instruction includes a Feature Code and Bit [ X: x2], wherein the Feature Code indicates that the current instruction is a write protect instruction. Bit [ X1: x1 in X2 indicates address information to be protected, and X2 is a second flag bit. And the second flag bit indicates that the address information to be protected is written and locked, and when the second flag bit is set to a second preset value, the condition that the address information to be protected cannot be modified in the current power-on period is characterized. The second preset value may be 1.
Step 1043: and executing the write protection instruction.
It should be noted that, in the original kernel image, write protection is also opened for the boot loader according to the above procedure. So that the bootloader can still be protected after the original kernel is replaced.
Step 105: and after the original kernel is started, starting a preset monitoring thread and loading the file system.
The file system is stored in a third partition of the NAND Flash, and the address of the third partition is preset. The monitoring thread is used for monitoring the loading thread of the file system, and the loading thread of the file system can inform the monitoring thread in the form of writing in a preset zone bit or sending a message when the loading is finished, so that the monitoring thread determines that the file system is successfully started.
The monitoring thread can start the monitoring thread initialization program after being started by the kernel, and can also run the monitoring thread initialization program from the virtual memory disk.
In an embodiment of the present invention, step 105 further includes:
step 1051: and loading a preset monitoring thread initializing program through the boot loader so as to establish a target monitoring thread.
The monitoring thread initialization program is stored in the Ramdisk. Ramdisk is a virtual memory technology, and is a technology used by simulating a memory into a disk through software. The Ramdisk is loaded into the memory by a boot loader through a low-level read-write command, such as a NAND read command, instead of a high-level read-write interface provided after the file system is started, so that the Ramdisk file system can be mounted on an original kernel which has been read into the memory, and the read is performed before the file system is started. After the original kernel is started, the Ramdisk is installed as a root file system, so that a monitoring thread initialization program in the Ramdisk is driven and operated.
Different from the scheme that the monitoring thread initialization program is stored in the original kernel for starting, the monitoring thread initialization program is stored in the Ramdisk, so that on one hand, the capacity of the original kernel can be reduced, the starting rate of an operating system is accelerated, and on the other hand, the original kernel is more complicated to program, and the development cost can be reduced.
Step 1052: and loading the file system to run an initialization script included in the file system, and starting a system main program.
Step 1053: when the system main program is detected to be started, writing a first flag bit of a first preset value into a monitoring thread file corresponding to the target monitoring thread. The first flag bit is used to identify whether the main program of the system is started successfully, and the first preset value may be 1.
Step 106: and determining whether the file system is completely loaded in a preset time or not through the monitoring thread.
The manner in which the monitoring thread determines is by reading the value of the first flag bit.
Specifically, step 1061 is included: and when the monitoring thread determines that loading is not completed in the preset time, determining whether a first flag bit of the first preset value is detected in the monitoring thread file.
Step 1062: and when the first flag bit of the first preset value is detected, determining that the file system is started, and terminating the monitoring thread.
When the file system is not completely loaded in the preset time, namely, a bad block appears in the partition where the file system is located, so that the file system cannot be normally loaded, and therefore the partition where the file system is located needs to be repaired. Similar to the original kernel image described above, the file system image is an image file made from the file system stored in the third partition described above.
After determining, by the monitoring thread, whether the file system is completely loaded within a preset time, the method further includes:
step 1063: and when the file system is not completely loaded in the preset time, erasing the partition where the file system is located.
Step 1064: and writing the file system image into a partition where the file system is located.
Step 1065: restarting the target device.
Step 107: and when the file system is determined to be completely loaded in the preset time, determining that the file system is started.
It is considered that in some special cases, the boot loader needs to be upgraded, and at this time, the write protection of the boot loader needs to be released to implement the data writing of the boot loader. However, in the current power-up period, the original kernel or the original kernel image starts the write protection of the boot loader after being started, and the write protection cannot be erased again in the current power-up period.
Therefore, the method adopts a mode of replacing the kernel with write protection with the kernel without write protection, and removes the write protection of the boot loader. In the embodiment of the present invention, the backup partition further includes a third backup partition, where a write-protection kernel image is stored in the third backup partition, where write protection for the boot startup program is not started in the write-protection kernel image. The non-write-protected kernel image is made from the original kernel image and has no write protection to the boot initiator therein.
The process of releasing the boot loader write protection further comprises:
step 1071: it is detected whether a write operation request for the bootloader is received.
The detection of the write operation request may be to obtain a program and data input by a user through a keyboard after the computer device is started, and analyze the input program or data to determine whether the input program or data is a write operation request for the boot loader.
Step 1072: and when the write operation request is received, erasing the partition where the original kernel is located.
Because the original kernel is already loaded into memory, the NAND Flash can be erased.
Step 1073: loading the non-write-protection kernel image, and writing the non-write-protection kernel image into the partition where the original kernel is located.
Step 1074: restarting the target device.
After the target device is powered on again, the memory address of the boot loader is not write-protected in the kernel, so that in a new power-on period, the write operation of the boot loader can be performed again after the loading and starting of the kernel image without write protection.
Fig. 2 is a schematic structural diagram of a data protection device according to an embodiment of the present invention. As shown in fig. 3, the apparatus 200 includes: a first loading module 202, a second loading module 204, a verification module 206, a first starting module 208, a second starting module 210, a monitoring module 212, and a determination module 214.
A first loading module 202, configured to load and start a boot loader after detecting that the target device is powered on;
a second loading module 204, configured to load an original kernel through the bootloader;
A verification module 206, configured to verify the original kernel;
a first starting module 208, configured to start the original kernel and write-protect the bootloader when the original kernel is successfully verified;
the second starting module 210 is configured to start a preset monitoring thread and load a file system after the original kernel is started;
a monitoring module 212, configured to determine, by using the monitoring thread, whether the file system is completely loaded within a preset time;
a determining module 212, configured to determine that the file system has been started when it is determined that the file system is completely loaded within the preset time.
In an alternative approach, the verification module 206 is further configured to:
dividing a backup partition in the target equipment, wherein an original kernel image corresponding to the original kernel is stored in the backup partition, and write protection is started for a boot loader in the original kernel image;
when the original kernel verification fails, erasing a partition where the original kernel is located;
loading the original kernel image;
and writing the original kernel image into a partition where the original kernel is located.
In an alternative approach, the monitoring module 212 is further configured to:
When the file system is not loaded in the preset time, erasing the partition where the file system is located;
writing the file system mirror image into a partition where the file system is located;
restarting the target device.
In an alternative manner, the first initiation module 208 is further configured to:
detecting whether a write operation request for the boot loader is received;
when the write operation request is received, erasing the partition where the original kernel is located;
loading the non-write-protected kernel image, and writing the non-write-protected kernel image into a partition where the original kernel is located;
restarting the target device.
In an alternative approach, the monitoring module 212 is further configured to:
loading a preset monitoring thread initialization program through the boot loader to establish a target monitoring thread;
loading the file system to run an initialization script included in the file system, and starting a system main program;
when the system main program is detected to be started, writing a first flag bit of a first preset value into a monitoring thread file corresponding to the target monitoring thread.
In an alternative approach, the monitoring module 212 is further configured to:
When the monitoring thread determines that loading is not completed in the preset time, determining whether a first flag bit of the first preset value is detected in the monitoring thread file;
and when the first flag bit of the first preset value is detected, determining that the file system is started, and terminating the monitoring thread.
In an alternative manner, the first initiation module 208 is further configured to:
determining address information to be protected, wherein the address information to be protected comprises a storage address of the boot loader in the target equipment;
determining a write protection instruction according to the address information to be protected, wherein the write protection instruction comprises a second flag bit, the second flag bit is set to a second preset value, and the second flag bit is used for writing and locking the address information to be protected;
and executing the write protection instruction.
The implementation process of the data protection device provided in the embodiment of the present invention is the same as that of the data protection method described in any of the foregoing embodiments, and will not be repeated. According to the data protection device, the write protection is started for the boot loader after the original kernel is started, and the preset monitoring thread is started to monitor whether the file system is completely loaded in the preset time or not, so that the problem of low safety of stored data can be solved.
Fig. 3 shows a schematic structural diagram of a data protection device according to an embodiment of the present invention, and the specific embodiment of the present invention is not limited to the specific implementation of the data protection device.
As shown in fig. 3, the data protection apparatus may include: a processor (processor) 302, a communication interface (Communications Interface) 304, a memory (memory) 306, and a communication bus 308.
Wherein: processor 302, communication interface 304, and memory 306 perform communication with each other via communication bus 308. A communication interface 304 for communicating with network elements of other devices, such as clients or other servers. Processor 302 is configured to execute program 310 and may specifically perform the relevant steps described above for the data protection method embodiment.
In particular, program 310 may include program code comprising computer-executable instructions.
The processor 302 may be a central processing unit CPU, or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement embodiments of the present invention. The one or more processors comprised by the data protection device may be the same type of processor, such as one or more CPUs; but may also be different types of processors such as one or more CPUs and one or more ASICs.
Memory 306 for storing programs 310. Memory 306 may comprise high-speed RAM memory or may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
Program 310 may be specifically invoked by processor 302 to cause a data protection device to:
loading and starting the boot loader after detecting that the target device is powered on;
loading the original kernel through the boot loader;
checking the original kernel;
when the original kernel is successfully verified, starting the original kernel and performing write protection on the boot loader;
after the original kernel is started, starting a preset monitoring thread and loading the file system;
determining whether the file system is completely loaded in a preset time or not through the monitoring thread;
and when the file system is determined to be completely loaded in the preset time, determining that the file system is started.
In an alternative, the program 310 is invoked by the processor 302 to cause the data protection device to:
dividing a backup partition in the target equipment, wherein an original kernel image corresponding to the original kernel is stored in the backup partition, and write protection is started for a boot loader in the original kernel image;
After the verification of the original kernel, the method further comprises:
when the original kernel verification fails, erasing a partition where the original kernel is located;
loading the original kernel image;
and writing the original kernel image into a partition where the original kernel is located.
In an alternative, the program 310 is invoked by the processor 302 to cause the data protection device to:
after determining, by the monitoring thread, whether the file system is loaded in a preset time, the method includes:
when the file system is not loaded in the preset time, erasing the partition where the file system is located;
writing the file system mirror image into a partition where the file system is located;
restarting the target device.
In an alternative, the program 310 is invoked by the processor 302 to cause the data protection device to:
after determining that the file system has been started, the method further comprises:
detecting whether a write operation request for the boot loader is received;
when the write operation request is received, erasing the partition where the original kernel is located;
Loading the non-write-protected kernel image, and writing the non-write-protected kernel image into a partition where the original kernel is located;
restarting the target device.
In an alternative, the program 310 is invoked by the processor 302 to cause the data protection device to:
loading a preset monitoring thread initialization program through the boot loader to establish a target monitoring thread;
loading the file system to run an initialization script included in the file system, and starting a system main program;
when the system main program is detected to be started, writing a first flag bit of a first preset value into a monitoring thread file corresponding to the target monitoring thread.
In an alternative, the program 310 is invoked by the processor 302 to cause the data protection device to:
when the monitoring thread determines that loading is not completed in the preset time, determining whether a first flag bit of the first preset value is detected in the monitoring thread file;
and when the first flag bit of the first preset value is detected, determining that the file system is started, and terminating the monitoring thread.
In an alternative, the program 310 is invoked by the processor 302 to cause the data protection device to:
Determining address information to be protected, wherein the address information to be protected comprises a storage address of the boot loader in the target equipment;
determining a write protection instruction according to the address information to be protected, wherein the write protection instruction comprises a second flag bit, the second flag bit is set to a second preset value, and the second flag bit is used for writing and locking the address information to be protected;
and executing the write protection instruction.
The implementation process of the data protection device provided in the embodiment of the present invention is the same as that of the data protection method described in any of the foregoing embodiments, and will not be repeated. According to the data protection device, the problem of low safety of stored data can be solved by starting write protection for the boot loader after the original kernel is started and starting a preset monitoring thread to monitor whether the file system is completely loaded in the preset time.
An embodiment of the present invention provides a computer readable storage medium storing at least one executable instruction that, when executed on a data protection device, causes the data protection device to perform a data protection method according to any of the above method embodiments.
The executable instructions may be specifically operable to cause a data protection device to:
loading and starting the boot loader after detecting that the target device is powered on;
loading the original kernel through the boot loader;
checking the original kernel;
when the original kernel is successfully verified, starting the original kernel and performing write protection on the boot loader;
after the original kernel is started, starting a preset monitoring thread and loading the file system;
determining whether the file system is completely loaded in a preset time or not through the monitoring thread;
and when the file system is determined to be completely loaded in the preset time, determining that the file system is started.
In an alternative form, the executable instructions cause the data protection apparatus to:
dividing a backup partition in the target equipment, wherein an original kernel image corresponding to the original kernel is stored in the backup partition, and write protection is started for a boot loader in the original kernel image;
after the verification of the original kernel, the method further comprises:
When the original kernel verification fails, erasing a partition where the original kernel is located;
loading the original kernel image;
and writing the original kernel image into a partition where the original kernel is located.
In an alternative form, the executable instructions cause the data protection apparatus to:
after determining, by the monitoring thread, whether the file system is loaded in a preset time, the method includes:
when the file system is not loaded in the preset time, erasing the partition where the file system is located;
writing the file system mirror image into a partition where the file system is located;
restarting the target device.
In an alternative form, the executable instructions cause the data protection apparatus to:
after determining that the file system has been started, the method further comprises:
detecting whether a write operation request for the boot loader is received;
when the write operation request is received, erasing the partition where the original kernel is located;
loading the non-write-protected kernel image, and writing the non-write-protected kernel image into a partition where the original kernel is located;
Restarting the target device.
In an alternative form, the executable instructions cause the data protection apparatus to:
loading a preset monitoring thread initialization program through the boot loader to establish a target monitoring thread;
loading the file system to run an initialization script included in the file system, and starting a system main program;
when the system main program is detected to be started, writing a first flag bit of a first preset value into a monitoring thread file corresponding to the target monitoring thread.
In an alternative form, the executable instructions cause the data protection apparatus to:
when the monitoring thread determines that loading is not completed in the preset time, determining whether a first flag bit of the first preset value is detected in the monitoring thread file;
and when the first flag bit of the first preset value is detected, determining that the file system is started, and terminating the monitoring thread.
In an alternative form, the executable instructions cause the data protection apparatus to:
determining address information to be protected, wherein the address information to be protected comprises a storage address of the boot loader in the target equipment;
Determining a write protection instruction according to the address information to be protected, wherein the write protection instruction comprises a second flag bit, the second flag bit is set to a second preset value, and the second flag bit is used for writing and locking the address information to be protected;
and executing the write protection instruction.
The specific implementation process of the computer readable medium provided in the embodiment of the present invention is the same as that of the data protection method described in any of the foregoing embodiments, and will not be repeated. The computer readable medium of the invention can overcome the problem of lower security of stored data by starting write protection for the boot loader after the original kernel is started and starting a preset monitoring thread to monitor whether the file system is completely loaded in a preset time.
The embodiment of the invention provides a data protection device which is used for executing the data protection method.
An embodiment of the present invention provides a computer program that can be invoked by a processor to cause a data protection device to perform the data protection method of any of the method embodiments described above.
Embodiments of the present invention provide a computer program product comprising a computer program stored on a computer readable storage medium, the computer program comprising program instructions which, when run on a computer, cause the computer to perform the data protection method of any of the method embodiments described above.
The algorithms or displays presented herein are not inherently related to any particular computer, virtual system, or other apparatus. Various general-purpose systems may also be used with the teachings herein. The required structure for a construction of such a system is apparent from the description above. In addition, embodiments of the present invention are not directed to any particular writing language. It should be appreciated that the teachings of the present invention as described herein may be implemented in a variety of writing languages and that the foregoing descriptions of specific languages are presented to disclose preferred embodiments of the invention.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the above description of exemplary embodiments of the invention, various features of the embodiments of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be construed as reflecting the intention that: i.e., the claimed invention requires more features than are expressly recited in each claim.
Those skilled in the art will appreciate that the modules in the apparatus of the embodiments may be adaptively changed and disposed in one or more apparatuses different from the embodiments. The modules or units or components of the embodiments may be combined into one module or unit or component, and they may be divided into a plurality of sub-modules or sub-units or sub-components. Any combination of all features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or units of any method or apparatus so disclosed, may be used in combination, except insofar as at least some of such features and/or processes or units are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings), may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably written computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, third, etc. do not denote any order. These words may be interpreted as names. The steps in the above embodiments should not be construed as limiting the order of execution unless specifically stated.

Claims (8)

1. A method of data protection, the method being based on a target device having a boot loader, an original kernel, and a file system stored therein, the method comprising:
loading and starting the boot loader after detecting that the target device is powered on;
loading the original kernel through the boot loader;
checking the original kernel;
when the original kernel is successfully verified, starting the original kernel and performing write protection on the boot loader;
after the original kernel is started, starting a preset monitoring thread and loading the file system; after the original kernel is started, starting a monitoring thread and loading the file system, wherein the method comprises the following steps:
loading a preset monitoring thread initialization program through the boot loader to establish a target monitoring thread;
loading the file system to run an initialization script included in the file system, and starting a system main program;
when the system main program is detected to be started, writing a first flag bit of a first preset value into a monitoring thread file corresponding to the target monitoring thread;
Determining whether the file system is completely loaded in a preset time or not through the monitoring thread;
when the file system is determined to be completely loaded in the preset time, determining that the file system is started; after determining, by the monitoring thread, whether the file system is loaded in a preset time, the method includes:
when the monitoring thread determines that loading is not completed in the preset time, determining whether a first flag bit of the first preset value is detected in the monitoring thread file;
and when the first flag bit of the first preset value is detected, determining that the file system is started, and terminating the monitoring thread.
2. The method of claim 1, wherein prior to verifying the original kernel, further comprising:
dividing a backup partition in the target equipment, wherein an original kernel image corresponding to the original kernel is stored in the backup partition, and write protection is started for a boot loader in the original kernel image;
after the verification of the original kernel, the method further comprises:
when the original kernel verification fails, erasing a partition where the original kernel is located;
Loading the original kernel image;
and writing the original kernel image into a partition where the original kernel is located.
3. The method of claim 2, wherein the backup partition further has a file system image stored therein;
after determining, by the monitoring thread, whether the file system is loaded in a preset time, the method includes:
when the file system is not loaded in the preset time, erasing the partition where the file system is located;
writing the file system mirror image into a partition where the file system is located;
restarting the target device.
4. The method of claim 2, wherein the backup partition further stores a write-protected kernel image, wherein write protection for the boot loader is not enabled in the write-protected kernel image;
after determining that the file system has been started, the method further comprises:
detecting whether a write operation request for the boot loader is received;
when the write operation request is received, erasing the partition where the original kernel is located;
loading the non-write-protected kernel image, and writing the non-write-protected kernel image into a partition where the original kernel is located;
Restarting the target device.
5. The method of claim 1, wherein the write protecting the bootloader comprises:
determining address information to be protected, wherein the address information to be protected comprises a storage address of the boot loader in the target equipment;
determining a write protection instruction according to the address information to be protected, wherein the write protection instruction comprises a second flag bit, the second flag bit is set to a second preset value, and the second flag bit is used for writing and locking the address information to be protected;
and executing the write protection instruction.
6. A data protection device, the device comprising:
the first loading module is used for loading and starting a boot loader after the target equipment is detected to be electrified;
the second loading module is used for loading the original kernel through the boot loader;
the verification module is used for verifying the original kernel;
the first starting module is used for starting the original kernel and performing write protection on the boot loader when the original kernel is successfully verified;
the second starting module is used for starting a preset monitoring thread and loading a file system after the original kernel is started; after the original kernel is started, starting a monitoring thread and loading the file system, wherein the method comprises the following steps:
Loading a preset monitoring thread initialization program through the boot loader to establish a target monitoring thread;
loading the file system to run an initialization script included in the file system, and starting a system main program;
when the system main program is detected to be started, writing a first flag bit of a first preset value into a monitoring thread file corresponding to the target monitoring thread;
the monitoring module is used for determining whether the file system is loaded in a preset time or not through the monitoring thread;
the determining module is used for determining that the file system is started when the file system is determined to be completely loaded in the preset time; after determining, by the monitoring thread, whether the file system is loaded in a preset time, the method includes:
when the monitoring thread determines that loading is not completed in the preset time, determining whether a first flag bit of the first preset value is detected in the monitoring thread file;
and when the first flag bit of the first preset value is detected, determining that the file system is started, and terminating the monitoring thread.
7. A data protection device, comprising: the device comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete communication with each other through the communication bus;
The memory is configured to store at least one executable instruction that causes the processor to perform the operations of the data protection method according to any one of claims 1-5.
8. A computer readable storage medium having stored therein at least one executable instruction that, when executed on a data protection device, causes the data protection device to perform the operations of the data protection method of any one of claims 1-5.
CN202110292122.2A 2021-03-18 2021-03-18 Data protection method, device, equipment and computer storage medium Active CN113094107B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110292122.2A CN113094107B (en) 2021-03-18 2021-03-18 Data protection method, device, equipment and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110292122.2A CN113094107B (en) 2021-03-18 2021-03-18 Data protection method, device, equipment and computer storage medium

Publications (2)

Publication Number Publication Date
CN113094107A CN113094107A (en) 2021-07-09
CN113094107B true CN113094107B (en) 2023-12-22

Family

ID=76668675

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110292122.2A Active CN113094107B (en) 2021-03-18 2021-03-18 Data protection method, device, equipment and computer storage medium

Country Status (1)

Country Link
CN (1) CN113094107B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113642006A (en) * 2021-08-30 2021-11-12 南方电网数字电网研究院有限公司 Safe starting method of dual-core relay protection system

Citations (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1822230A (en) * 2006-03-02 2006-08-23 浙江大学 Method for realizing memory file system based on NAND Flash
CN1973289A (en) * 2004-06-24 2007-05-30 西姆毕恩软件有限公司 Method of operating a file system for a computing device
CN101236498A (en) * 2007-07-31 2008-08-06 北京理工大学 Method for embedding inner core drive program in Window operation system by PCI card start-up
CN102054005A (en) * 2009-10-29 2011-05-11 腾讯科技(深圳)有限公司 Method and device for loading file
CN102812458A (en) * 2011-08-10 2012-12-05 华为技术有限公司 Method, device and system for mounting file system
CN103024060A (en) * 2012-12-20 2013-04-03 中国科学院深圳先进技术研究院 Open type cloud computing monitoring system for large scale cluster and method thereof
CN103514057A (en) * 2012-06-26 2014-01-15 京信通信技术(广州)有限公司 Self-healing method, device and system of Linux system
CN104778060A (en) * 2015-04-07 2015-07-15 珠海全志科技股份有限公司 Rapid and safe starting method for embedded Linux system
CN105335095A (en) * 2014-08-11 2016-02-17 北京兆易创新科技股份有限公司 Flash file system processing method and apparatus
CN106529301A (en) * 2016-09-28 2017-03-22 东软集团股份有限公司 Method and device for controlling vehicle-mounted machine system, and vehicle-mounted machine system
CN107403097A (en) * 2017-08-10 2017-11-28 清远博云软件有限公司 A kind of core system software running guard method
CN107526595A (en) * 2017-08-28 2017-12-29 中南大学 A kind of method for supporting multiple operating system remote loading
CN109033869A (en) * 2018-07-04 2018-12-18 深圳虚觅者科技有限公司 Encrypted file system hanging method and device
CN109902490A (en) * 2019-02-22 2019-06-18 北京易讯通信息技术股份有限公司 A kind of anti-tamper application method of file system of linux kernel rank
CN110780935A (en) * 2019-10-31 2020-02-11 深圳市友华软件科技有限公司 Synchronous starting method and device for multi-system fusion product
CN110795735A (en) * 2019-10-29 2020-02-14 南京邮电大学 Rootkit universality detection method oriented to heterogeneous BIOS environment
CN110874467A (en) * 2018-08-29 2020-03-10 阿里巴巴集团控股有限公司 Information processing method, device, system, processor and storage medium

Patent Citations (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1973289A (en) * 2004-06-24 2007-05-30 西姆毕恩软件有限公司 Method of operating a file system for a computing device
CN1822230A (en) * 2006-03-02 2006-08-23 浙江大学 Method for realizing memory file system based on NAND Flash
CN101236498A (en) * 2007-07-31 2008-08-06 北京理工大学 Method for embedding inner core drive program in Window operation system by PCI card start-up
CN102054005A (en) * 2009-10-29 2011-05-11 腾讯科技(深圳)有限公司 Method and device for loading file
CN102812458A (en) * 2011-08-10 2012-12-05 华为技术有限公司 Method, device and system for mounting file system
CN103514057A (en) * 2012-06-26 2014-01-15 京信通信技术(广州)有限公司 Self-healing method, device and system of Linux system
CN103024060A (en) * 2012-12-20 2013-04-03 中国科学院深圳先进技术研究院 Open type cloud computing monitoring system for large scale cluster and method thereof
CN105335095A (en) * 2014-08-11 2016-02-17 北京兆易创新科技股份有限公司 Flash file system processing method and apparatus
CN104778060A (en) * 2015-04-07 2015-07-15 珠海全志科技股份有限公司 Rapid and safe starting method for embedded Linux system
CN106529301A (en) * 2016-09-28 2017-03-22 东软集团股份有限公司 Method and device for controlling vehicle-mounted machine system, and vehicle-mounted machine system
CN107403097A (en) * 2017-08-10 2017-11-28 清远博云软件有限公司 A kind of core system software running guard method
CN107526595A (en) * 2017-08-28 2017-12-29 中南大学 A kind of method for supporting multiple operating system remote loading
CN109033869A (en) * 2018-07-04 2018-12-18 深圳虚觅者科技有限公司 Encrypted file system hanging method and device
CN110874467A (en) * 2018-08-29 2020-03-10 阿里巴巴集团控股有限公司 Information processing method, device, system, processor and storage medium
CN109902490A (en) * 2019-02-22 2019-06-18 北京易讯通信息技术股份有限公司 A kind of anti-tamper application method of file system of linux kernel rank
CN110795735A (en) * 2019-10-29 2020-02-14 南京邮电大学 Rootkit universality detection method oriented to heterogeneous BIOS environment
CN110780935A (en) * 2019-10-31 2020-02-11 深圳市友华软件科技有限公司 Synchronous starting method and device for multi-system fusion product

Also Published As

Publication number Publication date
CN113094107A (en) 2021-07-09

Similar Documents

Publication Publication Date Title
JP4668416B2 (en) Protecting boot block code when enabling write access to the boot block
KR101375992B1 (en) Handling errors during device bootup from a non-volatile memory
US7702894B2 (en) System and method for loading programs from HDD independent of operating system
US7313682B2 (en) Method and system for updating boot memory that stores a fail-safe reset code and is configured to store boot code and boot updater code
US20150199190A1 (en) System and method for updating firmware
US11314866B2 (en) System and method for runtime firmware verification, recovery, and repair in an information handling system
JP7022809B2 (en) Computer systems, their safety management methods, and computer software products
US20040268116A1 (en) Fault tolerant recovery block with reduced flash footprint
US20150154033A1 (en) Computer system and boot method thereof
US11379330B2 (en) Information handling systems and related methods for testing memory during boot and during operating system (OS) runtime
US20090013167A1 (en) Computer device, method for booting the same, and booting module for the same
CN105786545B (en) Breakpoint recovery method and system based on heterogeneous hybrid memory
US7430683B2 (en) Method and apparatus for enabling run-time recovery of a failed platform
CN113094107B (en) Data protection method, device, equipment and computer storage medium
CN109582332B (en) System upgrading method and device for Internet camera
JPH1091289A (en) Memory initialization device and method
US7882353B2 (en) Method for protecting data in a hard disk
CN103677875A (en) Method for starting electronic equipment, method for controlling permission and electronic equipment
CN114510751A (en) Hardware replacement prevention device and method based on processor security kernel
CN112052112A (en) Bit flipping error detection method and device based on NOR Flash storage and storage medium
CN111783162A (en) Data protection implementation method and device and computer equipment
US20050068842A1 (en) Electronic device, nonvolatile memory and method of overwriting data in nonvolatile memory
US7069471B2 (en) System PROM integrity checker
JP2010282645A (en) Linux program start-up system
CN114265603A (en) System upgrading method and device based on asymmetric partition and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 518000 401, Building B1, Nanshan Zhiyuan, No. 1001, Xueyuan Avenue, Changyuan Community, Taoyuan Street, Nanshan District, Shenzhen, Guangdong

Applicant after: Shenzhen Saifang Technology Co.,Ltd.

Address before: 518000 room 701, building B1, Nanshan wisdom garden, 1001 Xueyuan Avenue, Changyuan community, Taoyuan Street, Nanshan District, Shenzhen City, Guangdong Province

Applicant before: Shenzhen Daotong Intelligent Automobile Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant