Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Are there any common or standard ways to make a system more robust against unexpected power loss (I.e., without proper shutdown)? I was using a UPS but the battery is dying and I haven't had a chance to replace it yet.

During the last power loss (when I turned off the UPS to remove it), one of my file systems got thoroughly butchered. It's an ext3 filesystem that was corrupted, and most of my current filesystems are ext3. Are there filesystems that will be more resilient?

Are there any other actions I can take to make the system safer in this regard?

share|improve this question
    
Well, the obvious answer is to find time to replace the battery; even a few minutes runtime on battery will allow a clean shutdown of almost any system. Sudden system shutdowns are always worse than controlled shutdowns, regardless of which file system you're using. –  Michael Kjörling Aug 14 '13 at 9:43
    
Yes, that's of course the safest way to do it, but in practice I've found that I've had more unexpected power losses with the UPS than without, because when the beeper starts shrieking to tell me that the battery is dying, the only way to silence it is to turn off the output, and I can't stand listening to the beeper long enough to turn on my other computer, connect over SSH, and correctly shutdown the machine. –  sh1ftst0rm Aug 15 '13 at 2:02
    
You almost certainly don't have more unexpected power losses; if anything, you might have forcefully shut the computer down a few times when without a UPS it would just have died the instant you lost power. If hearing the power outage or replace battery alarm for long enough to shut the computer down properly is a problem, investigate configuring your system so that pressing the power button initiates a clean shutdown -- even if abruptly killing all running processes means you lose any unsaved changes, that's still much better than any unclean shutdown. And of course, replace the battery. –  Michael Kjörling Aug 15 '13 at 7:18
    
That's a good idea, I will see if I configure it to work that way. As far the power loss, it's just a matter of semantics. From the point of view of the system, if it looses power unexpectedly, it doesn't matter whether it's because of a black out or because I killed the UPS output. My point was that I haven't had any black outs, or even tripped circuits in the entire time I've owned the system, but I have been compelled to cut power without a proper shutdown because of the UPS. –  sh1ftst0rm Aug 15 '13 at 10:28
add comment

3 Answers

up vote 3 down vote accepted

I came across this page on the ArchLinux wiki, titled: What is the most error resistant filesystem?. There are a couple of suggestions in this thread:

journal=data

Use ext3 with the journal=data mount option. You can also make it the default with this command:

tune2fs -o journal_data /dev/your_partition

excerpt from tune2fs man page

journal_data
              When  the  filesystem  is mounted with journalling enabled,
              all data (not just metadata) is committed into the journal 
              prior to being written into the main filesystem.

ext3 vs. ext4 disadvantages

share|improve this answer
    
And what about the JFS, the Journaled File System? en.wikipedia.org/wiki/JFS_%28file_system%29 I post this as a comment and not an answer as I've never actually tried it but its purpose is to make the file system perfectly resilient. –  lgeorget Aug 14 '13 at 9:32
1  
@lgeorget From that Wikipedia page, under "Features: Journal": "JFS journals metadata only, which means that metadata will remain consistent but user files may be corrupted after a crash or power loss." Not what the OP is looking for. Metadata journaling is what ext3 does by default, data journaling is the option on ext3 (and is what slm is suggesting). From a quick glance, I don't see anything in that article indicating JFS2 is particularly well-suited to handle sudden power outages. –  Michael Kjörling Aug 14 '13 at 9:39
    
@MichaelKjörling Ok, thank you for the technical explanation and distinction about metadata and data journaling. –  lgeorget Aug 14 '13 at 9:52
    
@MichaelKjörling - thanks for clarifying this! –  slm Aug 14 '13 at 14:53
add comment

You also could consider FreeBSD with zfs as root-fs and of course for data - zfs seems to be really rock solid (copy-on-write) so you might loose the last seconds but the filesystem should always be consistent.

zfsonlinux is maybe still too early.

share|improve this answer
    
I think that depends on what you mean by "too early". According to the ZFS On Linux 0.6.1 release announcement, "Over two years of use by real users has convinced us ZoL is ready for wide scale deployment on everything from desktops to super computers." The downside of ZoL is that it'll likely never get quite the same exposure as the file systems included in the kernel, simply because it isn't included in the kernel by virtue of its CDDL license. Still, +1 for ZFS, but remember to scrub thoroughly. –  Michael Kjörling Aug 14 '13 at 9:47
add comment

There are several things to do. One of those is reducing the number of daemons or other process that you don't need or use often.

Another action is to reduce the time (delay) for the kernel writes to the hard drive.

share|improve this answer
    
Can you elaborate at all on configuring the kernel write delay? –  sh1ftst0rm Aug 14 '13 at 10:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.