Reducing Disk IO By Mounting Partitions With noatime

Want to support HowtoForge? Become a subscriber!
 
Submitted by falko (Contact Author) (Forums) on Tue, 2008-12-16 11:45. :: Linux

Reducing Disk IO By Mounting Partitions With noatime

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 12/04/2008

Linux has a special mount option for file systems called noatime. If this option is set for a file system in /etc/fstab, then reading accesses will no longer cause the atime information (last access time - don't mix this up with the last modified time - if a file is changed, the modification date will still be set) that is associated with a file to be updated (in reverse this means that if noatime is not set, each read access will also result in a write operation). Therefore, using noatime can lead to significant performance gains.

I do not issue any guarantee that this will work for you!

 

Using noatime

In this example I want to use noatime for my root file system - /. Therefore I open /etc/fstab...

vi /etc/fstab

... and add noatime to the options of the / file system, e.g. like this:

proc /proc proc defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
/dev/md0 /boot ext3 defaults 0 0
/dev/md1 none swap sw 0 0
/dev/md2 / ext3 defaults,noatime 0 0

You don't have to reboot the system for the changes to take effect - the following command will do:

mount -o remount /

That's it. You can run

mount

to check if the partition really got mounted with noatime:

server4:/home/admin# mount
/dev/md2 on / type ext3 (rw,noatime)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/md0 on /boot type ext3 (rw)
server4:/home/admin#

 

A Quick Note For OpenVZ VMs

OpenVZ containers (virtual machines) don't have an /etc/fstab file because the partitioning is controlled from the host system. To set noatime for a VM, you can run

vzctl set veid --noatime yes --save

on the host system and restart the VM (replace veid with the ID of the container; for example, if the container has the ID 101, run

vzctl set 101 --noatime yes --save

and restart the container:

vzctl restart 101

).


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Kumar Ullal (not registered) on Wed, 2012-08-08 02:09.

 some people say that this can causes some program to break:

Unfortunately, turning off atime unconditionally will occasionally break software. Some mail tools will compare modification and access times to determine whether there is unread mail or not. The tmpwatch utility and some backup tools also use atime and can misbehave if atime is not correct. For this reason, distributors tend not to make noatime the default on installed systems.

Also Debian’s popularity contest program (popcon) make use of last access time. So it might report bad data to Debian servers.

 Here is the link

http://linux.koolsolutions.com/2009/01/30/installing-linux-on-usb-part-4-noatime-and-relatime-mount-options/ 

 

Submitted by thehand (not registered) on Sun, 2009-07-26 17:39.

Famous kernel developer Ingo Molnar said the following:

Atime updates are by far the biggest IO performance deficiency that Linux has today.  Getting rid of atime updates would give us more everyday Linux performance than all the pagecache speedups of the past 10 years, _combined_.

http://blogs.koolwal.net/2009/01/30/installing-linux-on-usb-part-4-noatime-and-relatime-mount-options/

And here's some of what the L man said about it:

http://lkml.org/lkml/2007/8/4/73

http://lkml.org/lkml/2007/8/10/200

Noatime is good, but remember that you will not be able to know when something was last accessed, so consider your needs carefully. Many people can do without atime, though you must be careful, as some things like backups, the popularity contest, and other things rely on it.

Be well informed!

Submitted by Adam Ashenfelter (not registered) on Thu, 2008-12-18 16:34.

I'm guessing this will also result in better battery life on a laptop as well.

It would be nice if some kind of atime cache was implemented so file accesses wouldn't cause disk IO.  ATime infomation could then be written at long intervals, and at unmount time.

This kerneltrap.org conversation has a similar suggestion.

http://kerneltrap.org/node/14148

Submitted by Wiggum (not registered) on Thu, 2008-12-18 14:07.

This is in fact an old discussion which is already covered extensively.

One good reference concerning notaime (back in the year 2000!) was:

http://en.tldp.org/LDP/solrhe/Securing-Optimizing-Linux-RH-Edition-v1.3/chap6sec73.html

In the more recent days (2007), there was also a discussion available through Kerneltrap:

http://kerneltrap.org/node/14148

In any case, one could consider using the relatime flag by default to optimse disk IO performance not breaking application functionality.

Wiggum.

Submitted by Christopher Thomas (not registered) on Thu, 2008-12-18 09:30.

I know it sounds obvious, of course it does, not setting the atime of each file accessed or touched by a program sounds like a certain speedup for somethings.

 but the problem is, how much of an improvement is there?

 stats please! I'd like to see your reasoning about this further than "of course it would work" cause I am sure there are lots of things which "look" like they would improve performance but in real practice dont do any actual difference.

 Just look at STL containers like <vector> lots of people think that using them are slow, they say that "of course plain old arrays are faster!!!! they dont have all that STL  junk" yet actually, they dont realise that in reality, it's not faster at all and it's actually more bug prone and the same speed (if you have a good compiler).

 So! with that said: stats please! lets see your proof.

Submitted by awan (registered user) on Wed, 2008-12-17 11:06.

Hi there,

That sounds excellent, especially for people who dish out solutions on worn out hardware (for windows).

Simply putting a swap space on the another physical hard disk  does wonders especially if u have dual/multiple controllers (SCSI/SATA) etc..

I can safely say off the top of my head that performance gains are around 40% at times. (although this figure hasn´t been benchmarked thru standard benchmarkers)

I wonder if u have any experiences testing this in busy environment.

 -

Oz

 

 

Submitted by Stefan Adelbert (not registered) on Wed, 2008-12-17 00:15.
Would "noatime" have any (positive) effect on mounted smbfs (Windows) shares? Or does this apply only to ext2/3 partitions?
Submitted by Krugger (not registered) on Tue, 2008-12-16 14:00.
The relatime option just updates times if access time is newer, it is similar to noatime and does not break some applications which need know last read time of a particular file (mutt for example).