According to Red Hat’s Enterprise Linux 6 Power Management guide, the POSIX family of standards for operating systems “requires that operating systems maintain file system metadata that records when each file was last accessed.” This is called “atime” (a is for access) and is one of three timestamps Linux filesystems keep for their files (the other two are mtime and ctime, modify and change times). You can see these with the ‘stat’ command:
$ stat /bin/ls File: `/bin/ls' Size: 109208 Blocks: 216 IO Block: 4096 regular file Device: fd00h/64768d Inode: 519 Links: 1 Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2013-12-07 21:29:08.068475219 -0600 Modify: 2013-05-23 08:10:31.000000000 -0500 Change: 2013-06-11 19:12:14.577018287 -0500
On the surface this sounds like a good thing to track, but like many decisions it has unintended consequences: every read operation on a filesystem isn’t just a read operation, it’s a write operation, too, since the atime needs to be updated.
Reads are easy for systems to do, and they’re easy for systems to cache. Writes are hard to do, as they need to be done in a timely fashion, in a guaranteed order, journaled, etc. Doing a write for every read is a sure way to sap performance, especially since many executables need to dynamically load system libraries. Each time a library is accessed, even from cache, there are writes being made to update atime. Back in 2007, Ingo Molnar noted that with atime enabled “[Linux gives] Windows a 20%-30% performance edge, for almost nothing.”
How do I get my 30% disk performance back?
Simply add “noatime” to your filesystem mount options in /etc/fstab to prevent atime from being updated on file and directory accesses:
/dev/mapper/Volume00-root / ext4 defaults,noatime 1 1
In this example I want to use noatime for my root file system – /. Therefore I open /etc/fstab…
… and add noatime to the options of the / file system, e.g. like this:
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
to check if the partition really got mounted with noatime:
/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)
Be careful, though. Some applications, like tmpwatch, some backup programs, and some things having to do with email (mutt, pine, sendmail, etc.) care about atime. In those cases you have two options. First, commenter Mike Lowe pointed out that noatime implies nodiratime. If you have an application that cares about file atimes you might gain some performance with using just nodiratime instead of noatime to cover the directories but not the files.