Wednesday, 3 July 2013

Disable OS X file read access time

When OS X reads a file, a timestamp is written to the drive. Disabling the read access time will reduce the number writes to you hard drive. Personally I really don't care about read access time, so I prefer to disable it. To do this create the file /Library/LaunchDaemons/noatime.system.plist with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>noatime.system</string>
    <key>ProgramArguments</key>
    <array>
      <string>mount</string>
      <string>-vuwo</string>
      <string>noatime</string>
      <string>/</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>

(the first v in the -vuwo argument is for verbose and is optional)

After the file has been created, run the following three commands in the terminal.
sudo chown root:wheel /Library/LaunchDaemons/noatime.system.plist
sudo chmod 644 /Library/LaunchDaemons/noatime.system.plist
sudo launchctl load -w /Library/LaunchDaemons/noatime.system.plist

To verify the modification, run the command mount in the terminal and look for the line /dev/disk0s2 on / (hfs, local, journaled, noatime). If the last entry in the parentheses are noatime, the changes has been applied successfully.

If you have more then one partition on your disk, create a plist file for each drive and change the <string>/</string> argument to match the mount point for that partition.