RAM Disk under OS X

by Jon, Jon@smalldog.com (written by Jon, posted by Ed)

RAM disks could be easily created in the Classic MacOS, going all the way back to System 6. Many users would copy their System Folders to a RAM disk to keep the hard drive spun down and maximize battery life. A 14” Wallstreet running 8.6 off a RAM disk could run for 7 hours off two installed batteries, with screen brightness down. Things have changed since then: installation of OS X onto a RAM disk is not financially practical due to its sheer size, and there is no GUI-based method for creating a RAM disk. RAM disks were great—since RAM is so much faster than any hard drive out there, the computer could boot in 10 seconds, and things were overall incredibly snappy when running off a RAM disk.

Following a few steps in Terminal will allow you have a RAM disk again. Be careful here: incorrect syntax or typos can result in catastrophe! Your mileage may vary.

line 1 prompt$ hdid -nomount ram://52428800
According to the man page, hdid was historically a user-level process that handled the loading and decompression of disk image data for HDI disk images in the kernel. These disk images have no permissions, and the current logged-in user is the owner of the disk. If you have multiple users on your machine, and wish for the data on your RAM disk to be hidden, don’t do this.

line 2 prompt$ newfs_hfs /dev/disk1
This constructs a volume called disk1, formatted as HFS+.

line 3 prompt$ mkdir /tmp/ramdisk1
This makes a new directory called ramdisk1 on the newly created HFS+ volume

line 4 prompt$ mount t hfs /dev/disk1 /tmp/ramdisk1
This mounts the temporary RAM disk to the desktop, as if it were removable media or a disk image. Drag stuff at will, and savor the speed! Oooh, aaaah, look how fast! Try editing huge files in photoshop with this as your scratch disk, and hang on tight: the data is fed to the processor(s) in your computer at crazy fast speeds your hard drive can only dream of.

When you’re finished, type in Terminal:
prompt$ hdiutil detach /dev/disk1

It’s important to consider that creating a RAM disk uses RAM, which means it is not available for other applications to use. Be careful in selecting the size of your RAM disk, especially on an Intel machine with integrated graphics processing-MacBooks, Minis, and the entry-level 17” iMac. More RAM is always better, and it’s extremely inexpensive right now: 1GB PC5300 chips are $59.99, and 2GB PC5300 chips are $142.99, while two months ago 1GB was $135 and 2GB chips were almost $400!

Similar Posts

  • Playing Blu-Ray on a Mac

    Steve Jobs has said for some time that Apple will not support Blu-Ray, calling the licensing “a bag of hurt.” Despite how popular…

  • MacFuse and MacFusion

    Ever since I moved to the Mac I had the need for a GUI SSH client. As much as love using command line…

  • Use Disk Utility to Copy CDs / DVDs

    Note: This tip originally ran in our Kibbles & Bytes newsletter as Kibbles & Bytes Mac Treat #5. Subscribe here: Kibbles & Bytes…

  • Dashboard – Love It or Leave It

    By Matt@Smalldog.com (written by Matt, posted by Ed) Dashboard is a love-or-hate feature of MacOS X 10.4 Tiger. I still haven’t decided whether…

  • Spruce Up Google Reader

    I found this nifty little trick while looking around Digg.com. It allows you to skin or theme Google Reader (http://reader.google.com) and it sure…

  • Useful OS X Keyboard Shortcuts!

    Print it out, fold in two, and trim around the edges – keep it on your desk next to your Mac to master…