linux-磁盘挂载优化

发布时间:2018-09-11 15:38:12编辑:丝画阁阅读(1046)

前言

默认情况下,Linux ext2/ext3/ext4 文件系统在文件被访问、创建、修改等的时候记录下了文件的一些时间戳,比如:文件创建时间、最近一次修改时间和最近一次访问时间。

因为系统运行的时候要访问大量文件,如果能减少一些动作(比如减少时间戳的记录次数等)将会显著提高磁盘 IO 的效率、提升文件系统的性能。Linux 提供了 noatime 这个参数来禁止记录最近一次访问时间戳。

linux-磁盘挂载优化



设置

在文件系统挂载的时候加上 noatime 参数能大幅提高文件系统性能。

linux-磁盘挂载优化


vim /etc/fstab

UUID=5f543816-8bcb-477a-a356-341b62df19d0 / ext4 defaults,noatime 0 1

修改设置后只需要重新挂载文件系统、不需要重启就可以应用新设置:

mount -o remount /

mount | grep noatime

/dev/sda2 on / type ext4 (rw,noatime)

/dev/sda5 on /data type ext4 (rw,noatime)

/dev/sda3 on /home type ext4 (rw,noatime)


nodiratime需要设置吗?

从帮助文档里面可以找到答案,man mount

nodiratime

Do not update directory inode access times on this filesystem. (This option is implied when noatime is set.)

#帮助文档里面说明了,这个参数是不更新文件系统目录inode的访问时间(当noatime的时候,这个选项就会被设置)

noatime

Do not update inode access times on this filesystem (e.g. for faster access on the news spool to speed up news servers). This works for all inode types (directories too), so it implies nodiratime.

#noatime也说明了,这个参数作用于所有的inode节点(没有分目录节点还是文件节点)

从上面的帮助文档可以看出,只需要设置noatime就足够了。实际操作中也可以看到结果。



关键字