The past few days people in Linux blogosphere have been bringing back up the noatime/nodiratime mount options. These options disable the updating of file and directory access times. On many standard systems when you read file a “last read,” or access time, timestamp is written to disk. Disabling the writing of access times can provide performance increases in some conditions. Probably in a lot of conditions. Disabling the writing of these access times can be accomplished with the noatime and nodiratime mount options on a typical FS on a Linux system. Well in OS X and hfs+ nodiratime doesn’t exist but noatime does.
These options are old news to some. I had used them in Linux in the past – heck I think it was even in the standard Gentoo install docs – but I had never them a second thought since I moved to OS X. If you know me personally you know I can’t leave something untweaked. And those recent discussions got me to thinking…
Be forewarned, I haven’t gone to great lengths to explain the concepts of the notes below so if you’ve never seen a terminal this isn’t going to be comprehendible.
I wanted to mount my filesystems with the noatime option in OS X to disable the updates to access times for files. Problem is that, at least in 10.5, OS X no longer honors /etc/fstab for system disks, only for automount disks.
After wrestling with it for awhile I gave upon trying to find a location where I could specify mount options for system disks. I decided to just remount the disk later with the correct options. I created a StartupItem entry to remount the disk. I created a directory:
# mkdir /Library/StartupItems/spencer_boot
Then I created the StartupItem plist. Pretty straight forward.
# cat /Library/StartupItems/\
spencer_boot/StartupParameters.plist{
Description = “Spencer’s Boot Script”;
Provides = (“spencer_boot”);
OrderPreference = “None”;
Messages =
{
start = “Starting Spencer’s Boot Script”;
stop = “Stoping Spencer’s Boot Script”;
restart = “Restarting Spencer’s Boot Script”;
};
}
Now I needed the shell script that would be run on boot.
# cat /Library/StartupItems/spencer_boot/spencer_boot
#!/bin/sh
. /etc/rc.common
case “$1″ in
start)ConsoleMessage “Starting Spencer Boot: remounting root fs noatime”
mount_hfs -o noatime /dev/disk0s2 /;;
esacexit 0
This solved the problem for the root fs but I also use Filevault. If you don’t use Filevault you can stop reading here. How would I go about this? Same problem as before, no where to add mount time options. Additionally the fs is mounted upon login, not boot. So our previous method of creating a StartupItem won’t work. We’re going to have to do it later after it has been mounted – again.
<redacted> I did have some other information here but after review I wasn’t happy with advocating the “hack” I’m using. But the gist of it is to run something like this:
/sbin/mount -u -o noatime,nosuid,nodev /dev/disk1s2 /Users/spencer/after the volume is mounted. This happens after you enter your password. So a good place would be login items if you can figure out how to run mount as root from a user’s startup scripts.</redacted>
After you login and the system has completely finished running your startup apps open a terminal and type “mount”. You should see “noatime” listed as a mount option for you system and Filevault disks.
spencer_boot shell script
StartupParameters.plist for the spencer_boot StartupItem
remount_filevault for noatime in Filevault volumes
4 comments
de musicas says:
Thursday, December 11, 2008 at 6:34 am (UTC -5)
thanks..
eric says:
Sunday, January 25, 2009 at 9:14 pm (UTC -5)
Lately in Linux, you can use relatime, which is much less overhead without removing the functionality entirely.
paulo says:
Saturday, September 5, 2009 at 10:18 am (UTC -5)
nice tip pal. I was trying to tune everything here and I didn’t find how to set noatime for my root disk. thanks very much.
Fredrik Poller says:
Friday, August 27, 2010 at 4:14 am (UTC -5)
Hello,
I’ve written an article on how to optimize Mac OS X for SSD drives. The article covers how to enable noatime for FileVault filesystems using a script and login hooks.
http://poller.se/2010/08/optimizing-mac-os-x-for-ssd-drives/