11. The atime and noatime attribute

Linux records information about when files were created and last modified as well as when it was last accessed. There is a cost associated with recording the last access time. The ext2 file system of Linux has an attribute that allows the super-user to mark individual files such that their last access time is not recorded. This may lead to significant performance improvements on often accessed frequently changing files such as the contents of the /var/spool/news directory.

To set the attribute to a file, use:

           [root@deep] /#chattr +A filename	 1
           

1

For a specific file

For a whole directory tree, do something like:

           [root@deep /root]#chattr -R +A  /var/spool/	  1
           [root@deep /root]#chattr -R +A  /cache/		  2
           [root@deep /root]#chattr -R +A /home/httpd/ona/   3
           

1

For a news and mail

2

For a proxy caches

3

For a web pages

Linux has a special mount option for file systems called noatime that can be added to each line that addresses one file system in the /etc/fstab file. If a file system has been mounted with this option, reading accesses to the file system will no longer result in an update to the atime information associated with the file like we have explained above. The importance of the noatime setting is that it eliminates the need by the system to make writes to the file system for files which are simply being read. Since writes can be somewhat expensive, this can result in measurable performance gains. Note that the write time information to a file will continue to be updated anytime the file is written to. In our example below, we will set the noatime option to our /chroot file system.

Edit the fstab file vi /etc/fstab and add in the line that refer to /chrootfile system the noatime option after the defaults option as show below:

            /dev/sda7          /chroot          ext2          defaults,noatime          1  2
           

You need not reboot your system for the change to take effect, just make the Linux system aware about the modification you have made to the /etc/fstab file. This can be accomplished with the following commands:

           [root@deep] /#mount -oremount /chroot/
           

Then test your results with the flowing command:

           [root@deep]# cat /proc/mounts
           


           /dev/root /             ext2         rw 0 0
           /proc      /proc        proc         rw 0 0
           /dev/sda1  /boot        ext2         rw 0 0
           /dev/sda8  /cache       ext2         rw 0 0
           /dev/sda7  /chroot      ext2 rw,noatime 0 0
           /dev/sda6  /home        ext2         rw 0 0
           /dev/sda11 /tmp         ext2         rw 0 0
           /dev/sda5  /usr         ext2         rw 0 0
           /dev/sda9  /var         ext2         rw 0 0
           none       /dev/pts   devpts         rw 0 0
           

If you see something like: /dev/sda7 /chroot ext2 rw,noatime 0 0, congratulations!