In the embedded equipment, the power-down processing has been a more troublesome work, in the equipment with the Linux system, the system of various data processing is to increase the difficulty of power-down processing. Now do the following summary, and then encounter similar problems can be a reference.
1, system-initiated processing
When the system is power-up,/etc/inittab is loaded, initialized, and the individual scripts are executed. such as S13NTP. Similarly, when partitioning the file system in partition 1, the best way to mount is read only, otherwise the system can easily damage the partition if it encounters a blocking condition. Initialization scripts are also optimized to avoid blocking the system.
2. Detect power-down events
Plus a thread dedicated to detecting power-down events, other threads pass the flag if they know about the power-down event and exit as soon as possible.
3,reboot
If there is time to spare after Sync,fflush, try to reboot the system, so there will be some system-level synchronization data.
4. Fsck when power is on again
The purpose of the fsck repair is to delete the file if it is incomplete and not to have an unknown error in the error file.
Linux power-down processing