Building Quicksilver on a RAM drive

Everyone with a SSD in their Mac has read this, right? I thought the RAM disk was going a bit far and I never implemented it, but since I've been building Quicksilver many times per day lately, I thought I should give it another look.

What I've done isn't that different from the nullVision solution, but I had a couple of reasons to change things around.

  1. I don't need all of /tmp to be on a RAM disk, just /tmp/QS.
  2. My wife is not building Quicksilver on a regular basis. This drive only needs to be available when I log in.
  3. A StartupItem? In 2011? I didn't know they still worked.

So what I wanted was a 256MB RAM disk mounted at /tmp/QS. The first thing you need is a script to create the disk. This'll work:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash

RAMDisk() {
    mntpt=$1
    rdsize=$(($2*1024*2))
    echo "Creating RAMdisk for $mntpt"
    mkdir $mntpt
    # Create the RAM disk.
    dev=`hdid -drivekey system-image=yes -nomount ram://$rdsize`
    # Successfull creation…
    if [ $? -eq 0 ] ; then
        # Create HFS on the RAM volume.
        newfs_hfs $dev
        # Mount the RAM disk to the target mount point.
        mount -t hfs -o union -o nobrowse $dev $mntpt
    fi
}

RAMDisk /private/tmp/QS 256

I called the script qsdevdisk.sh. To make the disk available when you log in, create ~/Library/LaunchAgents/com.qsapp.devdisk.plist and put this in it:

<?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>com.qsapp.devdisk</string>
    <key>ProgramArguments</key>
    <array>
        <string>/path/to/qsdevdisk.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Log out and log back in and it should be there. The only drawback to this (besides the obvious memory it consumes) is that logging out seems to take a long time. I'm guessing the disk appears to be in use and the logout has to wait for a timeout before forcing it to unmount. Anyone know a solution to this?

blog comments powered by Disqus