SDB:Speeding up ext3

Jump to: navigation, search
This article will explain how to speed up ext3 by changing the default mount options of the ext3 file system in openSUSE.

The ext3 standard options

The journaling file system ext3 is or was[1] standard on many Linux distributions. Its standard options, "Journal Ordered" mode and "atime" can cause it to run slower than other file systems like XFS or ReiserFS (v3).

Enabling Writeback Mode

Three different ext3 journaling options exist:

  1. Journal Mode (slowest, extremely safe)
  2. Ordered Mode (medium speed, very safe, default openSUSE option)
  3. Writeback Mode (fastest, fairly safe)


openSUSE defaults its ext3 journaling mode to Ordered mode, since this generally provides the best safety-to-speed ratio. However, in most cases, Writeback mode is the fastest mode because it does the least amount of journaling. In some cases this can cause data loss (in the event of a power failure, for example), but many people consider this risk worth the speed increase. Journaled mode is generally the slowest mode because it journals everything twice, however in cases where data needs to be read and written to the file system at the same time, journaled mode can increase performance significantly.

Most people who want to increase their ext3 performance should use Writeback mode, unless they know that they do a lot of simultaneous reading and writing, in which case Journaled mode may be more to their liking.


Icon-warning.png
Warning: Performing the following optimization while the file system is mounted may cause irreparable harm to your partition. Therefore, use the following optimization on the unmounted file system after booting into a LiveCD, or other Linux partition. The openSUSE LiveCD or Knoppix LiveCD work well.


To change the journaling mode of your ext3 partition:

1. With openSUSE started, open your /etc/fstab in the editor of your choice (kate or gedit recommended). You do not need root permissions.
2. Record which partitions contain your / and /home file systems, as well as any other file system you want to optimize. Examples include /dev/hda2 and /dev/hda3, or /dev/sda2 and /dev/sda3.
3. Reboot into the LiveCD.
4. Start a terminal, either konsole or gnome-terminal.
5. Run the command to change the journaling mode, replacing /dev/hda1 with the actual link to the partition you gathered in step 2:

  • Writeback: tune2fs -O has_journal -o journal_data_writeback /dev/hda1
  • Journaled: tune2fs -O has_journal -o journal_data /dev/hda1

6. Repeat step 5 for each partition being optimized.
7. Once completed, reboot into openSUSE Linux.




Enabling Directory Indexing

Directory Indexing increases the speed of reads and writes to and from directories on your hard drive. Because they are pre-indexed, the read speed should noticeably increase. Enabling Directory Indexing is perfectly safe, and is recommended.


Icon-warning.png
Warning: Performing the following optimization while the file system is mounted may cause irreparable harm to your partition. Therefore, use the following optimization on the unmounted file system after booting into a LiveCD, LiveDVD, or other Linux partition. The openSUSE LiveCD or Knoppix LiveCD work well.


To enable directory indexing on your ext3 partition:

1. With openSUSE started, open your /etc/fstab in the editor of your choice (kate or gedit recommended). You do not need root permissions.
2. Record which partitions contain your / and /home file systems, as well as any other file system you want to optimize. Examples include /dev/hda2 and /dev/hda3, or /dev/sda2 and /dev/sda3.
3. Reboot into the LiveCD.
4. Start a terminal, either konsole or gnome-terminal.
5. Run the command to enable directory indexing, replacing /dev/hda1 with the actual link to the partition you gathered in step 2:

  • tune2fs -O dir_index /dev/hda1

6. Run the command to retroactively apply directory indexing to existing folders, /dev/hda1 with the actual link to the partition you gathered in step 2:

  • e2fsck -D /dev/hda1

The e2fsck command may take a while, depending on the size of your partition and the number of directories in it.

7. Repeat steps 5 and 6 for each partition being optimized.
8. Once completed, reboot into openSUSE Linux.





Turning Off atime

If atime is on, every time a file is accessed, whether for read or write, a small change is written to the file detailing the last access time. However, on ext3, this option can slow the read and write operations of a drive significantly. Turning off atime disables this update for file reads, only updating atime on write. This increases the speed of the file system, but may harm programs like tmpreaper and Mutt, which use read-based atime information to perform their operations.

If you find that turning off atime causes your programs to exhibit odd functionality or behaviour, you can re-enable it by deleting the added fstab options at any time. Unlike the previous optimizations, this optimization does not require that the partition be unmounted to perform it.


To disable atime on your ext3 partition:

1. With openSUSE started, start a terminal.
2. Switch to root using the su - command.
3. Open your /etc/fstab in the editor of your choice (nano, kate or gedit recommended). This can be done by issuing the command nano /etc/fstab, kate /etc/fstab, or gedit /etc/fstab.
4. Locate the partitions that contain your / and /home file systems, as well as any other file system you want to optimize. Examples include /dev/hda2 and /dev/hda3, or /dev/sda2 and /dev/sda3.
5. In the fourth section (just before the two numbers at the end of the line) you will see the options section of the fstab.
6. Enter ",noatime,nodiratime" after the existing options for each partition you wish to optimize.
7. Save the fstab file.
8. Reboot.

References

The information found in this article came from the following sources:

Codergeek42's post in the Gentoo Forums

John Markh's post in the SUSEForums.net Forums

Daniel Robbin's paper hosted at IBM.com

FAQ.org's atime and noatime documentation

"Replacing atime with relatime" post on KernelTrap.org

Footnotes

  1. In openSUSE ext4 has succeeded ext3 as stardard filesystem since openSUSE 11.2, see: Product highlights 11.2