Posts Tagged ‘ramdisk’

MacBook Pro SSD tuning

January 21st, 2011 4 comments

As I only use my mac for work/programming/something stuff I chose a SSD (128GB) as storage and upgraded just yesterday from 4 to 8GB of RAM. The following is list of steps I made to maximize IO capabilities and to minimize the SSD usage to prolong its lifetime.

Hint: if something should fail, rebooting into single user mode always works (press command+s during boot). There you can simply rename the RamFS script described below to switch off all changes i describe in the following . . .


Its common knowledge in linux userland that noatime helps to reduce IO as per default on each access of a file the last-access-timestamp has to be renewed. So each read on a file creates a write – noatime (no access time) prevents the write.

Activating that for the disks is done by adding a launchdaemon-script named:


< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
<plist version="1.0">
        <true />

Just to be sure:

sudo chown root:wheel /Library/LaunchDaemons/gpl.selfmade.noatime.plist

After rebooting a “mount” should show that the additional noatime-flag is now active.


The most useful thing to me having 8GB of RAM is working on a RamFS and thus having low latency while developing/compiling (using a local GIT to not loose work on power outage is crucial here). This is what has to be done:

Create a Folder and a file both named RamFS and set access rights accordingly

cd /System/Library/StartupItems
mkdir RamFS
sudo chown -R root:wheel RamFS
sudo chmod -R u+rwX,g+rX,o+rX RamFS
cd RamFS
touch RamFS
sudo chmod u+x,g+x,o+x RamFS

This is my actual version of the RamFS script:

# Create a RAM disk with same perms as mountpoint
RAMDisk() {
    echo "Creating RamFS for $mntpt of size $rdsize 512byte blocks"
    # Create the RAM disk.
    #dev=`hdik -drivekey system-image=yes -nomount ram://$rdsize`
    dev=`hdid -nomount ram://${rdsize}`
    # Successfull creation...
    if [ $? -eq 0 ] ; then
        # Create HFS on the RAM volume.
        newfs_hfs $dev
        # Store permissions from old mount point.
        eval `/usr/bin/stat -s $mntpt`
        # Mount the RAM disk to the target mount point.
        mount -t hfs -o union -o nobrowse $dev $mntpt
        # Restore permissions like they were on old volume.
        chown $st_uid:$st_gid $mntpt
        chmod $st_mode $mntpt
# Test for arguments.
if [ -z $1 ]; then
    echo "Usage: $0 [start|stop|restart] "
    exit 1
# Source the common setup functions for startup scripts
test -r /etc/rc.common || exit 1 
. /etc/rc.common
StartService () {
    ConsoleMessage "Starting RamFS disks..."
    RAMDisk /private/tmp 4096
#    RAMDisk /var/run 64
#    RAMDisk /var/db 1024
#    mkdir -m 1777 /var/db/mds
StopService () {
    ConsoleMessage "Stopping RamFS disks, nothing will be done here…"
    # diskutil unmount /private/tmp /private/var/run
    # diskutil unmount /private/var/run
RestartService () {
    ConsoleMessage "Restarting RamFS disks, nothing will be done here..."
RunService "$1"

We also need a plist-file called “StartupParameters.plist” in that very folder:

< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
        <string>RamFS Disks Manager</string>

If you want to use less than 2GB for the ramdisk please switch the dev line to hdik which is the much more lightweight way of mount the ramfs – i want to have a 3-4GB ramdisk which is something hdik cant do do i reverted back to the old hdid.

The flag nobrowse of mount makes sure i dont see the mountpoint in finder and on the desktop while union merges files already in the folder when the ramdisk is created (for deamons that created pidfiles etc earlier in the boot process)

I have a folder called Software in my home were i keep all my (software)projects. The tmp-folder there actually links to the ramdisk at /private/tmp via a softlink. I use that tmp for buildfiles, caching and so on.

If you use macports (as i do) it might also be a good idea to replace
with softlinks to /private/tmp. Keep in mind that your ramdisk must be sufficient to hold the tar.gz, the unpacked sources as well as all the buildfiles for this to work. As an example, the gcc4.4.5 uses around 2.9GB . . .

I also think about moving ~/Library/Caches to the ramdisk, maybe creating an own ramdisk for that purpose.

If you have more ideas let me know in the comments . . .

Categories: software Tags: , ,