Performance Tip: Disable Optimizefs

Rate this post

CPanel utilizes a script called “optimizefs” that removes the atime attribute from certain files on the system. For larger servers, this can create a lot of i/o load for a problem that can be fixed simply by mounting your file systems with the noatim

e flag if your file system is ext2 or higher.

The atime attribute is used by Linux to mark when a file was last accessed, and is understood to be a resource drain when enabled for an entire filesystem. cPanel attempts to address this by removing atime attributes from a specific list of files. You may see a command like this in your root crontab:

45 */8 * * * /usr/bin/test -x /usr/local/cpanel/bin/optimizefs && /usr/local/cpanel/bin/optimizefs

This cron basically applies the following command to a number of files and directories:

chattr +A /path/to/file/or/directory

Instead of using cPanel’s band-aid fix, it’s preferred to remove the atime attribute from the filesystem altogether. To do this, add noatime to the file system properties for each usable partition listed in /etc/fstab. For example:

LABEL=/ / ext3 defaults,usrquota,noatime 0 0
/tmp /var/tmp ext3 defaults,usrquota,bind,noauto,noatime 0 0

Then remount each file system. For the example above using the root partition ( / ):

mount -o remount /

*In some cases, a reboot may be necessary

Now, you can remove the cron job and still get the same benefits of not having your operating system record file access times:

sed ‘/optimizefs/d’ -i /var/spool/cron/root && service crond reload

Additional Resources:

http://www.faqs.org/docs/securing/chap6sec73.html

3 Comments

  1. Pingback: server overload via cPanel cron /scripts/update_db_cache - cPanel Forums

  2. Wilhelm Reply

    In my case I have a VPS server and /etc/fstab only displays the none filesystem but not the main filesystem /dev/vzfs in use (displayed when executing $ df -v).

    Perhaps you can give some solution on this ?

Leave a Reply to David Cancel reply

Your email address will not be published. Required fields are marked *

Log in