Show Table of Contents
3.8. Relatime 驱动器访问优化
POSIX 标准要求操作系统维护记录每个文件最后一次被访问的文件系统元数据。这个时间戳被称为
atime,维护它需要一个重复的对存储的写入操作。这些写入操作让存储是设备及其连接保持忙碌和通电状态。因为很少应用程序会使用 atime 数据,所以这个存储设备活动是在浪费电力。值得注意的是,即使不从存储中读取文件而是从缓存中读取文件,也会发生写入存储的事件。有时,Linux kernel 还支持 mount 的 noatime 选项,并不在使用此选项挂载的文件系统中写入 atime。但是只是关闭这个特性是有问题的,因为有些应用程序会依赖 atime 数据,并在此数据不可用时失败。
Red Hat Enterprise Linux 7 使用的 kernel 支持另一个可替换选项 —
relatime。relatime 维护 atime 数据,但不是每次访问该文件时都更改。启用这个选项,则只在上次更新 atime(mtime)后修改该文件时,或者最后一次访问该文件是在相当长一段时间前(默认为一天)时才会将 atime 数据写入磁盘。
现在,默认情况下会使用启用的
relatime 挂载所有文件系统。您可以将某个文件系统排除在外,而使用 norelatime 挂载该文件系统。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.