CN117311480A - Method for protecting data during power-down shutdown based on embedded Linux platform - Google Patents
Method for protecting data during power-down shutdown based on embedded Linux platform Download PDFInfo
- Publication number
- CN117311480A CN117311480A CN202311256339.3A CN202311256339A CN117311480A CN 117311480 A CN117311480 A CN 117311480A CN 202311256339 A CN202311256339 A CN 202311256339A CN 117311480 A CN117311480 A CN 117311480A
- Authority
- CN
- China
- Prior art keywords
- gpio
- external power
- state
- power supply
- file system
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 33
- 230000009286 beneficial effect Effects 0.000 abstract description 2
- 239000003990 capacitor Substances 0.000 abstract description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 230000004075 alteration Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/26—Power supply means, e.g. regulation thereof
- G06F1/30—Means for acting in the event of power-supply failure or interruption, e.g. power-supply fluctuations
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Power Sources (AREA)
Abstract
The invention discloses a method for protecting data during power-down and power-off based on an embedded Linux platform, which comprises the following steps: s1: connecting a nonvolatile storage medium to external power supply hardware through a gpio pin to acquire an external power supply state; s2: adding capacitance to the non-volatile storage medium; s3: after the Linux kernel reads the gpio state, acquiring whether external power supply is disconnected or not, providing gpio nodes by the Linux kernel layer through a sys file system, and acquiring the gpio state by the supply application layer; s4: starting a second executable program in script starting, checking the gpio state every 1s in the program, and entering a power-down shutdown process if the gpio state is changed; s5, calling reboot (poweroff) to enable the cpu system to enter a normal shutdown process. The beneficial effects of the invention are as follows: according to the invention, the capacitor is added on hardware, so that the file system can be normally protected from being damaged under the condition of sudden power failure of the embedded Linux platform, the system can normally work for a long time, and the equipment can normally operate for a long time.
Description
Technical Field
The invention relates to the technical field of data protection, in particular to a method for protecting data during power-down and shutdown based on an embedded Linux platform.
Background
Under the condition that the external field is suddenly powered off and shut down, the embedded Linux platform can possibly damage the file system in the process of repeatedly powering on and off the system, so that the file system can not be mounted after the device is started or the file system is abnormal in reading and writing. How to ensure that the file system still can normally run after thousands of times of normal power failure of the system, the protection solution of the embedded Linux platform in the prior art mainly comprises that the file system is self-repaired through fsck after being started, but the method still can not completely modify the file system, and the problem can be solved only by normally powering off the system in the process of powering off and normally assisting the file system.
Disclosure of Invention
The invention aims to provide a method for protecting data during power-down and power-off based on an embedded Linux platform, which aims to solve the problems in the background technology.
In order to achieve the above purpose, the present invention provides the following technical solutions: a method for protecting data during power-down and shutdown based on an embedded Linux platform is characterized by comprising the following steps: the method comprises the following steps:
s1: connecting a nonvolatile storage medium to external power supply hardware through a gpio pin to acquire an external power supply state;
s2: adding a capacitance to the non-volatile storage medium, said capacitance being capable of powering a minimum system for at least 5 seconds;
s3: after the Linux kernel reads the gpio state, acquiring whether external power supply is disconnected or not, providing gpio nodes by the Linux kernel layer through a sys file system, and acquiring the gpio state by the supply application layer;
s4: starting a second executable program in script starting, checking the gpio state every 1s in the program, and entering a power-down shutdown process if the gpio state is changed;
s4.1, terminating one or more processes through a termination command, then closing an external power supply, and unloading the file system through the umount when a file system line remote is in a read-only mode;
s5, calling reboot (poweroff) to enable the CPU system to enter a normal shutdown process, and thus the whole outage shutdown process is completed.
Preferably, if the external power is powered off, the gpio pin will have a level change, and Linux kernel can read the gpio level value to determine whether the external power is off.
Compared with the prior art, the invention has the beneficial effects that: according to the invention, the capacitor is added on hardware, so that the file system can be normally protected from being damaged under the condition of sudden power failure of the embedded Linux platform, the system can normally work for a long time, and the equipment can normally operate for a long time.
Drawings
FIG. 1 is a schematic flow chart of the method of the invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, the present invention provides a technical solution: 1. a method for protecting data during power-down and shutdown based on an embedded Linux platform is characterized by comprising the following steps: the method comprises the following steps:
s1: connecting a nonvolatile storage medium to external power supply hardware through a gpio pin to acquire an external power supply state;
s2: adding a capacitance to the non-volatile storage medium, said capacitance being capable of powering a minimum system for at least 5 seconds;
s3: after the Linux kernel reads the gpio state, acquiring whether external power supply is disconnected or not, providing gpio nodes by the Linux kernel layer through a sys file system, and acquiring the gpio state by the supply application layer;
s4: starting a second executable program in script starting, checking the gpio state every 1s in the program, and entering a power-down shutdown process if the gpio state is changed;
s4.1, terminating one or more processes through a termination command, then closing an external power supply, and unloading the file system through the umount when a file system line remote is in a read-only mode;
s5, calling reboot (poweroff) to enable the CPU system to enter a normal shutdown process, and thus the whole outage shutdown process is completed.
2. The method for protecting data during power-down and shutdown based on the embedded Linux platform according to claim 1, wherein the method comprises the following steps: if the external power is powered off, the gpio pin has level change, and Linux kernel can read the gpio level value to judge whether the external power is off.
Although embodiments of the present invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made therein without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.
Claims (2)
1. A method for protecting data during power-down and shutdown based on an embedded Linux platform is characterized by comprising the following steps: the method comprises the following steps:
s1: connecting a nonvolatile storage medium to external power supply hardware through a gpio pin to acquire an external power supply state;
s2: adding a capacitance to the non-volatile storage medium, said capacitance being capable of powering a minimum system for at least 5 seconds;
s3: after the Linux kernel reads the gpio state, acquiring whether external power supply is disconnected or not, providing gpio nodes by the Linux kernel layer through a sys file system, and acquiring the gpio state by the supply application layer;
s4: starting a second executable program in script starting, checking the gpio state every 1s in the program, and entering a power-down shutdown process if the gpio state is changed;
s4.1, terminating one or more processes through a termination command, then closing an external power supply, and unloading the file system through the umount when a file system line remote is in a read-only mode;
s5, calling reboot (poweroff) to enable the CPU system to enter a normal shutdown process, and thus the whole outage shutdown process is completed.
2. The method for protecting data during power-down and shutdown based on the embedded Linux platform according to claim 1, wherein the method comprises the following steps: if the external power is powered off, the gpio pin has level change, and Linux kernel can read the gpio level value to judge whether the external power is off.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311256339.3A CN117311480A (en) | 2023-09-27 | 2023-09-27 | Method for protecting data during power-down shutdown based on embedded Linux platform |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311256339.3A CN117311480A (en) | 2023-09-27 | 2023-09-27 | Method for protecting data during power-down shutdown based on embedded Linux platform |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117311480A true CN117311480A (en) | 2023-12-29 |
Family
ID=89280567
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311256339.3A Pending CN117311480A (en) | 2023-09-27 | 2023-09-27 | Method for protecting data during power-down shutdown based on embedded Linux platform |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117311480A (en) |
-
2023
- 2023-09-27 CN CN202311256339.3A patent/CN117311480A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US5799200A (en) | Power failure responsive apparatus and method having a shadow dram, a flash ROM, an auxiliary battery, and a controller | |
CN100470450C (en) | Information processing apparatus and power supply control method | |
CN104636217A (en) | Root file system automatic backup and exception recovery method and partition structure | |
CN103902399B (en) | Software system repair processing method and software system repair processing device | |
CN102236569A (en) | Embedded system and starting method thereof | |
CN207281744U (en) | Os starting device and system mainboard | |
CN103425549A (en) | Firmware managing method and system of embedded controller | |
CN101515236B (en) | Restoring method and update module for basic input/output system and computer system | |
US20060206764A1 (en) | Memory reliability detection system and method | |
CN113672306A (en) | Server component self-checking abnormity recovery method, device, system and medium | |
CN102479124A (en) | Test method | |
CN104657232A (en) | BIOS automatic recovery system and BIOS automatic recovery method | |
CN117311480A (en) | Method for protecting data during power-down shutdown based on embedded Linux platform | |
CN112269692A (en) | Remote upgrading power-off self-recovery mechanism for network camera | |
CN115793995B (en) | Pflash-only data storage method for traditional MCU | |
CN105630523A (en) | Computer BIOS data recovery system and method | |
CN116185715A (en) | System, method and device for clearing CMOS (complementary metal oxide semiconductor) settings of domestic Feiteng platform | |
CN102750234B (en) | The control method of memorizer and controller | |
CN117590921A (en) | Method and system for protecting data during power-down shutdown based on embedded Linux platform | |
CN117708886B (en) | File system protection method and device for Internet of things equipment | |
CN111813748A (en) | File system mounting method and device, electronic equipment and storage medium | |
CN112380083B (en) | Method and system for testing master-slave switching stability of BMC (baseboard management controller) | |
CN109271284A (en) | A kind of fault recovery method, device and the equipment of server boot subregion | |
CN114925011B (en) | Method and device for solving problem that PCIE hot plug slot position cannot identify equipment | |
CN114218010B (en) | Data backup and recovery method, system, terminal equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication |