Linux vulnerable to corruption in power outage?

10

4

The sysadmins at my company say that Linux is prone to getting nuked by a power outage. They say Windows machines always survive power outages but Linux boxes often become unrecoverable (ie you can no longer boot the machines). This came up because they told me the power company is shutting off power to our offices for a long period of time so the admins wanted me to shut down all the Linux boxes to which I alone have access before the outage.

I thought Linux was supposed to be robust?
My question, - is there some process I should be running to avoid my Linux boxes from getting nuked by a power outage?

Tyler Durden

Posted 2013-08-22T21:58:28.547

Reputation: 4 710

2Well, disregarding different OS problems, power outages affects any machine, simply because every process that is running stops to. It is always preferable to let the machine shut itself off, because then all processes are allowed to stop normally. – Doktoro Reichard – 2013-08-22T22:09:56.083

Doh, I know this. The question is whether Linux is more brittle than Windows for some reason, and if so, is there something I can do to increase its robustness (like forcing it to flush its disk cache more frequently somehow, for example). – Tyler Durden – 2013-08-22T22:22:22.820

2My answer mas meant to be general and encompassing: no matter what you do, there is always a risk of something somewhere failing. If Linux is more brittle I leave it for those who can specifically answer. My personal experience (with Windows and with OSX) shown me that unless I was doing something I cared for the output (simulations, for instance), they bounced back easily. Maybe something you should add is how the machines are used. – Doktoro Reichard – 2013-08-22T22:26:38.630

"Is there some process I should be running to avoid my Linux boxes from getting nuked by a power outage?" The problem is at a hardware level, the only command you can run here that would help is "shutdown computer" If you are concerned about this, I recommend a UPS (though this gets expensive fast if you have a large number of computers) – David – 2013-08-22T22:32:35.677

I'd ask your sysadmins why they believe that. My best guess though would be depending on the file system you're using and what the system is doing when it loses power, the file system could be left in an arbitrary state, which could lead to booting issues. – ernie – 2013-08-22T22:41:45.303

7Always is a big word, its also false. Windows can become corrupt during a power outage. Why don't you have battery backups and configure your system to shutdown? I can safely say that anyone who says "always" will be wrong 99.99999% of the time. – Ramhound – 2013-08-22T23:07:15.197

Answers

14

Is linux more brittle than windows?
The answer is : It Depends.

When someone says "unable to boot" in this situation I translate it to "File system corruption" and the answer Yes or No to the original question all depends on which file system you are using.

Windows does not let you have the full range of choices for filesystems that a Linux box will allow. You almost never see a non NTFS windows system. NTFS has things built in to it to help if there is a power loss, like journaling and file transactions that can roll back in the event of a failure.

A Linux box could have this, and could not. It all depends on how the server was set up. If the server used ext21 you could be very susceptible to file corruption in the event of a power failure. Compare that to a system that used something like Btrfs which has more data integrity features than NTFS does.

So if the sysadmin you where talking to only has ever worked with ext2 systems he very well could be right, but if you used another filesystem he could be wrong.


1: Ext2 was the default for both Debian and Red Hat Linux for a very long time. It has now been replaced mostly with Ext3 which is more on par with NTFS for features for data integrity.

Scott Chamberlain

Posted 2013-08-22T21:58:28.547

Reputation: 28 923

Best answer here +1 – Pimp Juice IT – 2017-07-29T03:35:48.910

Scott - Based on Tyler's answer below regarding the inode table and correlated file pointers, is there anything you could say about that and how that may work differently with different Linus files systems in brief and general. I'm trying to understand if anything in your answer implicitly already contains the inode table? So whatever this inode table mechanism is or however it works for the pointer or being meta data or whatever, is there anything you can say about that in relation to this answer of the comments from his answer below? Respectfully~

– Pimp Juice IT – 2017-07-29T19:31:26.793

What about the filesystems with journaling and file transactions that are not NTFS? I don't dispute the lack of complete and total power in Windows can lead to better stability if something is interrupted though. – Ramhound – 2013-08-22T23:10:44.567

3I mention that in my note on the bottom, Ext3 is the same level as NTFS. I believe that the sysadmin may have only experenced Ext2 filesystems, and from his point of view he would be right. It is like if you where only exposed to Fat32 filesytems and had never seen NTFS you would feel similarly about windows (versions of Windows on Fat32 had a horrible history of file corruption on power loss) – Scott Chamberlain – 2013-08-22T23:13:02.647

I entirely missed the footnote :-( – Ramhound – 2013-08-22T23:15:27.270

+1 for referring to the different file systems in use and journaling. – Doktoro Reichard – 2013-08-22T23:32:24.090

3

No, Linux is not inherently less robust then Windows when it comes to sudden power outages. What could happen - in the case of either OS - is that stuff is being written to the filesystem on the harddrive at the precise moment power is lost, and (historically) this could corrupt the filesystem.

The solution to this problem is to use a journaling filesystem which is immune to this problem based on the way it writes information. Most new filesystems - including Ext3 and ExT4 (the most common filesystems for Linux), as, I believe, NTFS is as well. So as long as you are using a journaling filesystem you won't experience this problem.

Later on down the boot process, if you have a database (I'm looking at MYSQL, Postgres does not suffer from this), you may have analogous issues with the MYSQL database - MYSQL is often not particularly robust (Google ACID compliance MYSQL for this topic). You can get around this problem by forcing a check of the indexes on reboot if your MySQL setup is not ACID compliant.

Another (somewhat Jaded and possibly unfair to Windows) view might be this - Linux boxes are more reliable then Windows boxes (as measured by Uptime and the need to do reboots) - thus it is possible that when Linux boxes fail on reboot it is a hardware problem due to old age rather then a software problem - whereas a failing Windows box may be detected sooner because of more frequent reboots)

davidgo

Posted 2013-08-22T21:58:28.547

Reputation: 49 152

1

Dependent on the distro and what file system you have, it could be more or less vulnerable. If you know about a scheduled power cut, you should definitely manually shut down (and use the time for maintenance like vacuuming the systems or maybe rewiring... For those unscheduled power outages, get UPS systems with Linux shutdown software so you don't need to worry. You should be running this anyway. There is a APCUPSD file available for most Linux distributions, if not that, then check with your distro to see what is already inside of it or available for it. Make sure it will shut down your systems cleanly prior to relying on it.

Blackbeagle

Posted 2013-08-22T21:58:28.547

Reputation: 6 424

-9

I did some research on this question and I found that what my IT department is said is essentially correct, Linux is way more vulnerable than Windows to a power outage. The reason why is how the inode table works in Linux/unix. Since it is an unordered list and is constantly being modified, there is no separation between important, static files like kernel binaries, and worthless files like temporary files. What this means is that the inode entries to critical system files are constantly being re-written, a very bad design obviously. In fact, critical system files are actually more likely to be having their inode entries be written at any given time than non-essential files. When power goes out it tends to blow away whatever part of the inode table was being written, which likely as not contains pointers to system files. The system files themselves are fine and intact, but the directory to find them is damaged. The situation is made worse by disk caching which has the effect of increasing the size of the damaged areas of the inode table.

In Windows, even the old FAT file system is way more robust than this. FAT has a table too, but it is an ordered table, so it does not have system files mixed up with temporary files. Usually the system files are in one area of the directory all together and this area is unlikely to be written very often. Also, FAT has a backup directory, so even if the directory is corrupted, it just reverts to the backup. This means that with FAT the user is unlikely to lose any file links in the event of a power failure, even temporary files. With Linux, however, since the inode table is constantly being written, the user is virtually guaranteed to lose access to files in a power failure.

The only thing that can be done to mitigate this is to turn off disk caching.

Tyler Durden

Posted 2013-08-22T21:58:28.547

Reputation: 4 710

2-1. Please support your claims with links, articles, sources etc. and I will revoke my downvote. What Linux filesystem(s) do you refer to? – Kamil Maciorowski – 2017-04-27T14:03:31.677

Tyler - You did read the answer Scott Chamberlain posted on your question, right? Are you 100% certain that the way you explain these inode table storing pointers for Linux files including OS system files is the way this works for all current Linux file systems since you can pick more than just one as explained, & some do have these more robust file meta data inode/journaling/transaction controls than others including some that are more powerful than even NTFS as explained? Maybe you're systems or the one you wrote about is because of the use of an older Linux file system & thus choose wisely? – Pimp Juice IT – 2017-07-29T03:35:06.990

The main reason I find this answer—and the whole question—to be a joke is Linux/Unix powers the Internet, not Windows. If outages can blow away Linux/Unix systems so easily, the Internet would not be able to function. Additionally routers that use Linux would then be useless when they are routinely quickly powered on and off. – JakeGould – 2018-07-27T22:25:53.997

This answer isn't just bad; it's simply nonsense. None of the facts stated in this answer are even remotely accurate. – duskwuff -inactive- – 2018-11-04T07:20:53.373