No time like noatime

There are many blogs out there which gives advice… bad advice… on how to speed up Linux. One common speed-up, as mentioned in this blog by Kevin Purdy, is mounting partitions with noatime (No Access Time).

It seems reasonable. Every time the file is accessed the Access time (atime) is recorded. To do that requires finding the inode that stores the file’s data and writing the atime to the file system. However there are programs that look at the atime of particular files to function. In short, mount a partition with noatime and trouble can ensue.

That is where the compromise comes in, relatime. That stands for “Relative Access Time.” Mounting a partition relatime means that when a file is modified both the Modify time (mtime) and atime are set to the current time. This ensures that programs that check the atime don’t miss actual changes to a file while not requiring every access to every file be dutifully noted. What’s more is that virtually no time is lost in the process. The inode already has to be looked up to modify mtime. Data already has to be written. It is a matter of a few extra bytes to modify atime and mtime as opposed to just atime.

In other words, noatime is virtually no faster than noatime but has none of the associated problems. This is why blogs like the one mentioned above are giving out bad advice. Now, I do not know Kevin Purdy and I’m sure he is well meaning but in his blog he describes how to modify /etc/fstab by replacing relatime with noatime. Here’s how he describes finding the correct line to modify, I’m bolding the relevant part.

“Look through the file for the partition line that contains your main system, not your swap partition. You’ll likely see “ext3” on that line, instead of “ntfs” or “swap” or the like. Note the two numbers—usually 0 and/or 1s—at the end of that line, and the section just before them, which should list a series of hard drive options like relatime,errors=remount-ro.”

Most Linux distributions these days mount their partitions with relatime by default. So there is no sense in switching it to noatime since there’s no speed gain and there are real losses to be had from programs which look only at atime. It may have been reasonable advice years ago but every since 2.6.20 was released Feb 5th, 2007, that advice has been moot.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s