Can unexpected power loss harm a Linux install?

Unexpected power cuts may cause corruption of file system data - e.g. if a process has started writing to a file, but not yet finished writing it, the file may end up only half written. Now imagine if the power cut happens when you're half way through a kernel upgrade...

As l0b0 wrote, using a journaling file system will help, since it will be able to keep track of what has actually gotten done. In addition to the wikipedia info that l0b0 linked, you may be interested in https://unix.stackexchange.com/questions/12699/do-journaling-filesystems-guarantee-against-corruption-after-a-power-failure as well.

You as a programmer obviously need to consider carefully how to handle writing to files so that it becomes an atomic process (i.e. it's either fully done or not done at all, but never ever half done). It's a fairly complex issue.


To help minimise the possibility of OS corruption, it's probably best to have separate "system" and "data" partitions on the SD card. That way you can mount the "system" partition read-only and use a highly-resilient FS on the "data" partition.

Additionally, most of those boards have very low power requirements, so a battery backup is possible. The "LiPo rider" board for the Raspberry Pi can be used as a basic UPS to provide a clean shutdown on power loss.


This would depend on

  1. whether you're using a journaling file system and
  2. how well the applications are able to handle aborted processing.

Consider for example an application which processes a file and writes the results as they are computed (one output line per input line) to another file. If the power is cut during processing, and the same application is run after restarting, it can't just restart processing from the start of the input file - that would mean the output file would contain duplicate information.

It could be very difficult to say anything definite about a hypothetical complex system, but most stable Linux software seems to be able to handle crashes quite nicely.


Since no one mentioned any specific filesystems: more modern filesystems (ext3, ext4, ntfs) are able to handle crashes much better than older filesystems (ext2, ext, fat32) due to journaling.

Assuming the hard-drive does not crash and does not lie, a complete power failure should not corrupt the filesystem. Individual files that were being written may still be corrupted, though, so if you were in the middle of updating the OS when the power failure occurred, it is still possible to bring down the OS.