Difference between revisions of "Disk Performance Tuning"

From Noah.org
Jump to navigationJump to search
m
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Engineering]]
 
[[Category:Engineering]]
 +
[[Category:Drives_and_Filesystems]]
 +
[[Category:Performance]]
 
== Disk Performance Tuning ==
 
== Disk Performance Tuning ==
  
On my laptop I use EXT3. My fstab is setup for speed.
+
I use ext4. My fstab is setup for speed over data safety. This setup is still more robust than an old ext2/ext3 filesystems.  
I turn off <code>atime</code> and set the mode to journal_data_writeback.
+
 
The data consistency guarantees are the same as the ext2 file system.
+
I turn off <code>atime</code> which stop tracking of when files are accessed (still tracks create and write times). The atime stat attribute is not used by very many applications. The `mutt` mail client can use atime, but runs fine without it. The `tmpwatch` command uses it by default, but can be configured to use ctime instead. You can see the atime of a file using the `stat` command. Other than that, most people don't care about atime.
This is still better than ext2 because file system integrity is maintained  
+
 
continuously, so the file system is always consistent even after an unclean shutdown.
+
As a compromise, you can set <code>relatime</code>.
In other words, you made <em>loose data</em>, but you won't have <em>bad data</em>.
+
 
 +
I set the mode to journal_data_writeback. This basically means that data may be written to the disk before the journal. The data consistency guarantees are the same as the ext3 file system. The downside is that if your system crashes before the journal gets written then you may loose new data -- the old data may magically reappear. This is still better than ext2 because file system integrity is maintained, so the file system is at least consistent even after an unclean shutdown. In other words, you may <em>loose data</em>, but you won't have <em>corrupt data</em>.
  
 
== /etc/fstab ==
 
== /etc/fstab ==
Do not forget to read [[Before you reboot]] before you make changes to /etc/fstab.
+
 
 +
'''Read [[#Before you reboot|Before you reboot]] before you make changes to /etc/fstab.'''
  
 
Edit /etc/fstab to change ext3 mount options:
 
Edit /etc/fstab to change ext3 mount options:
Line 17: Line 21:
 
UUID=d4769677-d2a9-4d87-9165-fc44760495bc / ext3 defaults,errors=remount-ro,noatime,data=writeback 0 1
 
UUID=d4769677-d2a9-4d87-9165-fc44760495bc / ext3 defaults,errors=remount-ro,noatime,data=writeback 0 1
 
</pre>
 
</pre>
 +
 
Older systems might use the /dev/hda1 notation (if upgrading you can get the UUID using the <code>vol_id /dev/hda1</code> command):
 
Older systems might use the /dev/hda1 notation (if upgrading you can get the UUID using the <code>vol_id /dev/hda1</code> command):
 
<pre>
 
<pre>
Line 23: Line 28:
  
 
== Before you reboot ==
 
== Before you reboot ==
Run this before you reboot after changing /etc/fstab.
+
 
 +
Run this before you reboot and after changing /etc/fstab:
 
<pre>
 
<pre>
 
tune2fs -o journal_data_writeback /dev/sda1
 
tune2fs -o journal_data_writeback /dev/sda1
 +
</pre>
 +
 +
== After you reboot ==
 +
 +
You can check the mount options in effect with the following command:
 +
<pre>
 +
cut /proc/mounts -f 2,3,4 -d " " | grep ^/\\W\\+ | grep -v rootfs
 
</pre>
 
</pre>

Latest revision as of 16:54, 26 March 2014

Disk Performance Tuning

I use ext4. My fstab is setup for speed over data safety. This setup is still more robust than an old ext2/ext3 filesystems.

I turn off atime which stop tracking of when files are accessed (still tracks create and write times). The atime stat attribute is not used by very many applications. The `mutt` mail client can use atime, but runs fine without it. The `tmpwatch` command uses it by default, but can be configured to use ctime instead. You can see the atime of a file using the `stat` command. Other than that, most people don't care about atime.

As a compromise, you can set relatime.

I set the mode to journal_data_writeback. This basically means that data may be written to the disk before the journal. The data consistency guarantees are the same as the ext3 file system. The downside is that if your system crashes before the journal gets written then you may loose new data -- the old data may magically reappear. This is still better than ext2 because file system integrity is maintained, so the file system is at least consistent even after an unclean shutdown. In other words, you may loose data, but you won't have corrupt data.

/etc/fstab

Read Before you reboot before you make changes to /etc/fstab.

Edit /etc/fstab to change ext3 mount options:

# /dev/sda1
UUID=d4769677-d2a9-4d87-9165-fc44760495bc / ext3 defaults,errors=remount-ro,noatime,data=writeback 0 1

Older systems might use the /dev/hda1 notation (if upgrading you can get the UUID using the vol_id /dev/hda1 command):

/dev/hda1 / ext3 defaults,errors=remount-ro,noatime,data=writeback 0 1

Before you reboot

Run this before you reboot and after changing /etc/fstab:

tune2fs -o journal_data_writeback /dev/sda1

After you reboot

You can check the mount options in effect with the following command:

cut /proc/mounts -f 2,3,4 -d " " | grep ^/\\W\\+ | grep -v rootfs