3.7. Relatime Drive Access Optimization
The POSIX standard requires that operating systems maintain file system metadata that records when each file was last accessed. This timestamp is called atime
, and maintaining it requires a constant series of write operations to storage. These writes keep storage devices and their links busy and powered up. Since few applications make use of the atime
data, this storage device activity wastes power. Significantly, the write to storage would occur even if the file was not read from storage, but from cache. For some time, the Linux kernel has supported a noatime
option for mount and would not write atime
data to file systems mounted with this option. However, simply turning off this feature is problematic because some applications rely on atime
data and will fail if it is not available.
The kernel used in Red Hat Enterprise Linux 6 supports another alternative — relatime
. Relatime
maintains atime
data, but not for each time that a file is accessed. With this option enabled, atime
data is written to the disk only if the file has been modified since the atime
data was last updated (mtime
), or if the file was last accessed more than a certain length of time ago (by default, one day).
By default, all filesystems are now mounted with relatime
enabled. To suppress this feature across an entire system, use the boot parameter default_relatime=0
. If relatime
is enabled on a system by default, you can suppress it for any particular file system by mounting that file system with the option norelatime
. Finally, to vary the default length of time before which the system will update a file's atime
data, use the relatime_interval=
boot parameter, specifying the period in seconds. The default value is 86400
.