How to Increase ext3 and ReiserFS filesystems Performance
Sponsored Link
ext3 Filesystem
The ext3 or third extended filesystem is a journalled file system that is commonly used by the Linux operating system. It is the default file system for many popular Linux distributions
Features of ext3 File System
The ext3 file system is essentially an enhanced version of the ext2 file system. These improvements provide the following advantages
Availability
After an unexpected power failure or system crash (also called an unclean system shutdown), each mounted ext2 file system on the machine must be checked for consistency by the e2fsck program. This is a time-consuming process that can delay system boot time significantly, especially with large volumes containing a large number of files. During this time, any data on the volumes is unreachable.
The journaling provided by the ext3 file system means that this sort of file system check is no longer necessary after an unclean system shutdown. The only time a consistency check occurs using ext3 is in certain rare hardware failure cases, such as hard drive failures. The time to recover an ext3 file system after an unclean system shutdown does not depend on the size of the file system or the number of files; rather, it depends on the size of the journal used to maintain consistency. The default journal size takes about a second to recover, depending on the speed of the hardware.
Data Integrity
The ext3 file system provides stronger data integrity in the event that an unclean system shutdown occurs. The ext3 file system allows you to choose the type and level of protection that your data receives. By default, Most Linux Distributions configures ext3 volumes to keep a high level of data consistency with regard to the state of the file system.
Speed
Despite writing some data more than once, ext3 has a higher throughput in most cases than ext2 because ext3's journaling optimizes hard drive head motion. You can choose from three journaling modes to optimize speed, but doing so means trade offs in regards to data integrity.
Easy Transition
It is easy to change from ext2 to ext3 and gain the benefits of a robust journaling file system without reformatting. See the Section called Converting to an ext3 File System for more on how to perform this task.
ReiserFS
ReiserFS is a general-purpose, journaled computer file system designed and implemented by a team at Namesys led by Hans Reiser.ReiserFS is currently supported on Linux and may be included in other operating systems in the future. Introduced in version 2.4.1 of the Linux kernel, it was the first journaling file system to be included in the standard kernel.
ReiserFS Features
ReiserFS has fast journaling, which means that you don't spend your life waiting for fsck every time your laptop battery dies, or the UPS for your mission critical server gets its batteries disconnected accidentally by the UPS company's service crew, or your kernel was not as ready for prime time as you hoped, or the silly thing decides you mounted it too many times today.
ReiserFS is based on fast balanced trees. Balanced trees are more robust in their performance, and are a more sophisticated algorithmic foundation for a file system. When we started our project, there was a consensus in the industry that balanced trees were too slow for file system usage patterns. We proved that if you just do them right they are better--take a look at the benchmarks. We have fewer worst case performance scenarios than other file systems and generally better overall performance. If you put 100,000 files in one directory, we think its fine; many other file systems try to tell you that you are wrong to want to do it.
ReiserFS is more space efficient. If you write 100 byte files, we pack many of them into one block. Other file systems put each of them into their own block. We don't have fixed space allocation for inodes. That saves 6% of your disk.
Ext3 & ReiserFS has three kinds of journaling methods
1) Journal Data Writeback
2) Journal Data Ordered
3) Journal Data
By default the the 2nd method is used.To speed things up we will make it use method 1. The price to pay is that it may allow old data to appear in files after a crash and journal recovery.
How to make ext3 or reiserfs use journal data writeback
First you need to take fstab file using the following command
sudo cp /etc/fstab /etc/fstab.orig
Edit the /etc/fstab file using the following command
sudo vi /etc/fstab
Add the thing marked in bold to your fstab root mount line.
/dev/hda1 / ext3 defaults,errors=remount-ro,atime,auto,rw,dev,exec,suid,nouser,data=writeback 0 1
Save that file and exit
You need to take Grubmenu file backup using the following command
sudo cp /boot/grub/menu.lst /boot/grub/menu.lst.orig
Now you need to edit the grub menu list file using the following command
sudo vi /boot/grub/menu.lst
look for the following two lines
# defoptions=quiet splash
# altoptions=(recovery mode) single
change to
# defoptions=quiet splash rootflags=data=writeback
# altoptions=(recovery mode) single rootflags=data=writeback
Save that file and exit
Now you need to update the grub using the following command
sudo update-grub
the added flags will automatically be added to the kernel line and stay there in case of kernel update
Changes to Ext3 FileSystem Only
Note:- tune2fs only works for ext3. Reiserfs can't change the journal method
Before rebooting change the filesystem manually to writeback using the following command
sudo tune2fs -o journal_data_writeback /dev/hda1
Check that it is running or not using the following command
sudo tune2fs -l /dev/hda1
Remove update of access time for files
Having the modified time change you can understand but having the system updating the access time every time a file is accessed is not to my liking. According to the manual the only thing that might happen if you turn this off is that when compiling certain things the make might need that info.
To change this do the following
sudo vi /etc/fstab
add the following marked in bold
/dev/hda1 / ext3 defaults,errors=remount-ro,noatime,auto,rw,dev,exec,suid,nouser,data=writeback 0 1
Now reboot and enjoy a much faster system
Hi,
I’m a linux newbie, but not TOO newbie, since I at least know the terms involved in your article. I followed each step just like you told. But now I can’t boot the system, and, booting with livecd, gparted can’t even see the device (that is /dev/sda1). So I can’t even rollback the modifications as I don’t know how to mount the partition. Can you help me please?
Hi,
I found the problem, for some reason the sata raid bios wasn’t detecting my disks, I restarted it and everything is working fine. Sorry for bothering…
Regards,
Thiago Souza
Please expand this by explaining what everything does. I don’t want to screw up my filesystems blindly copying and pasting commands.
Is necesary uncomment the defoptions and altoptions lines in menu.lst?
My menu.lst file says not to uncomment them just edit to what you need.
Nice article! So i decided to try it out for myself with a ext3 filesystem
and did some measurements with the bonnie++ tool.
Regarding the pure throughput i have approx. two percent performance plus
in respect of MB/sec – not too good :O(
Better results gave the file-operation part of the bonnie++ benchmark.
When creating, reading/accessing or deleting files here was to state an
performance plus of pretty exactly 20 percent – impressive :O)
In numbers measured on Feisty Fawn
47800 K/sec w/o tuning to 48700 K/sec for the throughput
26800 ops/sec w/o tuning to 32300 ops/sec for file operations
Would be nice if you’ll append such benchmark results to your article.
filters 2 cents
BTW: hwls says the disk was
description: ATA Disk
product: Maxtor 6B250R0
vendor: Maxtor
version: BAH41E00
serial: whocares
size: 233GB
and hdparm listed
multcount = 0 (off)
IO_support = 0 (default 16-bit)
unmaskirq = 0 (off)
using_dma = 1 (on)
keepsettings = 0 (off)
readonly = 0 (off)
readahead = 256 (on)
data journaling on ext3 is much better than writeback.
ext3 tips
will tell you how to do it, it’s not specific to gentoo either it will work on any linux distribution, that supports ext3, which I believe is all of them (unless they are using really, really, old kernels).
Let me see if I can rea you right, have you recomended to use the data ordered journal mode and put all your data at risk?
Every time I have had to reinstall my Linux boxes was because of that I was not using the data journal mode.
Yes, I know that this mode is the slowest of the 3, but is also the most bullet proof of them. Are you iterested in top speed? Switch the journal off altogether. Is your data worth more than nothing? Disregard this recommendation and use the data journal mode instead (wich is not the default, by the way).
Just fix your /etc/fstab to read data=journal and then issue this command instead: sudo tune2fs -o journal_data /dev/hda1 instead. True, you will suffer a filesystem speed degration, but you will get instead a almost (not completly) bulletproof security.
Hi!
> Every time I have had to reinstall my Linux boxes was because of that I was not using the
> data journal mode.
Now… did you lost information?, or did you got a filesystem corruption?, under which circumstances? (power failure, etc).
The only time I had to reinstall a Linux machine because of filesystem failure, was when I used reiserfs (a long time ago). I have used ext3 for a long time, with no problem, and I use the “ordered” data mode, which is the default, take a look at:
http://www.mjmwired.net/kernel/Documentation/filesystems/ext3.txt
That’s a copy of the “Documentation/filesystems/ext3.txt” kernel documentation file.
Please note, I don’t have an UPS, and thus every time there is a power failure, my systems goes down uncleanly. This far, to the best of my knowledge, I have not lost any information.
I will try the other journaling options, just to see.
c-ya!
Ildefonso Camargo
The following is a little old, but still relevant.
Basically, don’t write off data=journal
http://www-128.ibm.com/developerworks/library/l-fs8.html
Just in case anyone is wondering, mounting ext3 with writeback just journals the metadata and not the data itself. According to the ext3 FAQ (http://batleth.sapienti-sat.org/projects/FAQs/ext3-faq.html) enabling writeback “is exactly equivalent to running ext2 with a very fast fsck on reboot.”
In other words, just mount as ext2 and you get the same thing. If you care about your data stick with ext3 with the default journalling option.
ohh those commands seem very dangerous to perform, but i will try. thanks for sharing
On my system, I encountered numerous boot problems when attempting this. During boot, I kept getting “waiting for root” and then not getting the partition mounted.
By default, my Ubuntu 7.04 install didn’t have all these paramters in fstab. I needed to add them just like above:
/dev/hda1 / ext3 defaults,errors=remount-ro,noatime,auto,rw,dev,exec,suid,nouser,data=writeback 0 1
That still only worked booting into single-user mode. The final solution was in my grub menu.lst, I had to remove the kernel option (kopt)
root=UUID=....
toroot=/dev/hda2
.There is a line in the automagic kernel options where I set
kopt=root=/dev/hda2 ro
which allows me to rungrub-update /dev/hda1
without overwriting my root=/dev/ settings.This is a helpful HOWTO, but make sure you understand your fstab, menu.lst and how to use grub. I was unable to boot my system all afternoon until I figured this out.
I had been using data=writeback on several of my ext3 filesystems up until recently when I discovered a side effect after clumsily knocking the powercord from my workstation. I was expecting some data loss in any very recently modified files, but what I found was that files that had been modified weeks earler (but in the time since the machine had last booted) had reverted to the old data. I had been relying on the assumption that the periodic commits would get the file data to disk regardless of the order, but data=writeback appears to me to prevent that.
This appears to be a tweaker’s game. EXT3 is surely the slowest – this is not a secret. JFS from IBM is faster, and XFS is also capable of showing more than ten times the speed of EXT3. If you have set up RAID, then these are good options – but XFS is not so clever at finding files. XFS is very capable at copying big tarballs from HDD to HDD> The best journalling is Reiser and ext3.
However, I am at home, not running a server or a supercomputer. I have not the skills of the FBI to recover data, and I need the impressive tools that serve ext3 to get me out of trouble. Without them I am lost, with all my data and hours of setting up.
Sorry, but ext3 only occasionally seems just a little slow to me – most of the time it’s great, and when I get power outages (in Bangkok nearlly every day during rainy season…) then I want a straightforward reboot and carry on working without worrying abot the next time! Safety first.
I am using Mepis 8.0 and I don’t have the following lines in my menu.lst, what to do?
# defoptions=quiet splash
# altoptions=(recovery mode) single