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
Feed
Comment by de musicas
1 Thursday, December 11, 2008, 6:34 am o'clock |
thanks..