Thursday 21 February 2008

Ext3 journaling

Get your journalling mode
cat /proc/mounts | egrep "ext3"

Journal
(slow, but least risky) Both metadata and file contents are written to the journal before being committed to the main file system. This improves reliability at a performance penalty because all data has to be written twice. Without this setting in /etc/fstab, a file being edited in-place during a power outage or kernel panic risks being corrupted, depending on how the application is writing to the file.

Ordered
(medium speed, medium risk) Ordered is as with writeback, but forces file contents to be written before its associated metadata is marked as committed in the journal. This is the default on many Linux distributions.

Writeback
(fastest, most risky; equivalent to ext2 in some sense) Here metadata is journaled but file contents are not. This is faster, but introduces the hazard of out-of-order writes where, for example, files being appended to during a crash may gain a tail of garbage on the next mount.

Set or clear the indicated default mount options in the filesystem
tune2fs -O has_journal -o journal_data /dev/hdXY
tune2fs -O has_journal -o journal_data_ordered /dev/hdXY
tune2fs -O has_journal -o journal_data_writeback/dev/hdXY

Also you can define when you are mounting
mount -o data=journal /dev/hdXY /mountpoint
mount -o data=ordered /dev/hdXY /mountpoint
mount -o data=writeback /dev/hdXY /mountpoint

Or in fstab file
LABEL=test /mountpoint ext3 data=writeback 0 0

No comments: