I received a question about creating a RAMFS for Mac OS X’ /tmp folder, so I’ll post my reply here as well.

It’s really simple;

  1. Open Terminal (Applications -> Utilities), type "sudo su" and enter your user's password.
  2. Create a new file in /Library/LaunchDaemons, like this: "nano -w /Library/LaunchDaemons/com.yeri.ramfs.plist" (you can rename yeri to whatever you like)
  3. And insert following content (ctrl+x to save - y - [enter]):
  4. <?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.yeri.ramfs</string>
            <key>ProgramArguments</key>
            <array>
                <string>/var/root/ramfs.sh</string>
            </array>
            <key>RunAtLoad</key>
            <true/>
        </dict>
    </plist>
  5. create a second file in /var/root/, like this: "nano -w /var/root/ramfs.sh"
  6. And insert following content:
  7. #!/bin/bash
    ramfs_size_mb=64
    mount_point=/private/tmp
    

    ramfs_size_sectors=$((${ramfs_size_mb}10241024/512)) ramdisk_dev=hdid -nomount ram://${ramfs_size_sectors} newfs_hfs -v ‘Volatile HD’ ${ramdisk_dev} mkdir -p ${mount_point} mount -o noatime -t hfs ${ramdisk_dev} ${mount_point} chown root:wheel ${mount_point} chmod 1777 ${mount_point}

  8. chmod +x ramfs.sh and reboot. Check in Terminal with “mount” or “df -h” is everything is fine. To hide the disk icon on your desktop, check my old blog post.
  9. In case Mac didn’t do so already, you might want to link /tmp to /private/tmp: “rm -r /tmp && ln -s /private/tmp /tmp”.
  10. Should be it !