Marcus von Scotti

Reliable journaling filesystem in Linux

By: Marcus von Scotti, 28th of September 2006

28th of September 2006

We had problems with ext3 filesystem in the past, when bad sectors started corrupting the filesystem. Out-of-the-box ext3 is not fully configured to minimize the risk of creeping file-corruption. Here are a couple of simple steps to beef up the protection quite a bit.

The steps to getting a reliable ext3 journaling file-system are:

  • fsck.ext3 -f /dev/xxx; sleep 5
    for any production filesystem, one needs to do a full -f(orced) fsck clean-up to avoid error propagation followed by a short sleep if you run this in a script

  • tune2fs -O dir_index /dev/xxx
    create directory indexing

  • tune2fs -O has_journal -o journal_data /dev/xxx
    make sure the journal is setup correctly

  • tune2fs -e remount-ro
    prevent the file-system from being gradually trashed in case of errors being detected

  • sleep 5; fsck.ext3 -D -f /dev/xxx
    clean up, re-index and sleep before this to avoid messing things up

Delaying the steps via sleep is very important to avoid really screwing things up (in case you want to stick all this into a clever little script)!

Just in case one can also add

data=journal,errors=remount-ro
to fstab options (I'm not completely sure if the data=journal would apply based on the stuff in superblock otherwise, I have vague recollection that I've seen it picking up data=ordered instead).

It's best to do all of this when you setup your ext3 file-system, but we have managed to convert existing production filesystems by a script outlined above as well. We can obviously give no guarantees, but the above tuning steps have made a difference to us (especially after unintended power-cuts).


Comment

Sepero - 30th March 2007  [«« Reply to this]
errors=remount-ro

Great information here, but I have a problem related to this that I can't find the answer to.

It makes sense to have your partitions remount as read-only after errors are detected, but then what? I didn't find out that anything was wrong until Firefox started locking up. Now after a good solid 37 days uptime, I was forced to reboot. <<shudder>>

How can I have my devices automatically fsck'd and remounted-rw? (Instead of staying read-only and having me find out later when my programs start freaking out?)

PS.
I tried to leave my email, but it said 20 characters was the max.
cowpie2000(at)hotmail.nospam.com (Remove "nospam.")
 



hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.