People who do not know what a Journaling filesystem is, this should be comprehensive enough: The whole idea of Journaling filesystem is to keep a write-ahead data of all the filesystem changes. In this way, creating/deleting/modifying a file becomes a transaction. Remember atomicity of transaction in DBMS? All or None law? The same idea works here. So in case if some thing goes wrong, the filesystem can always roll back to the last known good state. However, all awesome things come with a cost. Here the cost you pay is the filesystem write performance: anytime you want to write data to a file, the filesystem will write to the journal first and then it will write the actual data.
Here’s why you might want to have an external journal device for your ext4 file system:
1. You are avoiding corruption in the journal data itself by keeping it somewhere else than the original data
2. As in journaling, filesystem writes data twice, keeping a separate journal device i.e a partition or logical volume on a separate physical disk altogether will introduce a significant performance boost
There’s a downside though: You cannot have multiple EXT4 filesystems sharing the same journal device as of now (AIX folks have probably started laughing now).
So how do you actually create a external journal device? Here’s how:
mke2fs -O journal_dev /dev/block_device_name
While creating a new filesystem, you can easily point to the newly created journal device like this:
mke2fs -t ext4 -J device=/dev/journal_device_name /dev/block_device_for_new_fs
To change journaling from internal to external for an existing filesystem, first unmount the filesystem. Then, execute the following:
tune2fs -O ^has_journal /dev/blk_dev_for_existing_fs
tune2fs -o journal_dev -j -J device=/dev/device_name /dev/blk_dev_for_existing_fs
There are few things to remember though:
The size of the journal device should be at least 1024*block size of the file system. So a filesystem with 4kb block size should have a journal device of 4mb at least.
Block size of the journal device should be set to the same as that of the actual filesystem
You can gain around 40% performance boost with external journal device (provided, the journal device resides on a separate physical disk). Amazing huh?