Tag Archives: ram disk

RAM Disk on Mac OS X

One of the things that really annoys me with modern computers is that they don’t use their RAM as much as they should – particularly with video and music playing.

Case in point. I was watching a movie on my new Hackintosh the other day, and the hard disk light was flashing continuously. The computer wasn’t doing anything else except watch the video, and I had more than 6GB of free RAM on the computer. However, the video player (VLC in this instance, but they all do it) wasn’t using that RAM, it was continuously reading from the HD. That’s okay for a desktop computer or a laptop with an SSD, but for a laptop with a regular HD, that’s a real waste of battery power. The 800MB video file could easily be read into RAM, then accessed by the video program.

One of the best ways to get around this problem is to create a RAM disk, something that used to be a regular feature on Apple computers. The obvious ways of doing it were removed with the introduction of Mac OS X, but the underlying capability is still there.

I was able to find out how to do this pretty quickly, through a Terminal command:

diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://3165430`

This creates a RAM disk that’s about 1.6 GB in size. Modify the last number to make the disk larger or smaller.

One thing that the articles didn’t mention is how you can easily turn a Terminal command into an ‘executable’ that you can click on to run. So I thought that I’d post a quick ‘how to’ to show how to do this.

  1. Open up a text editor (I use TextWrangler) and paste the command into it.
  2. Save it as a text file (I call it ‘ramdisk.sh’) to the drive.

Ramdisk script

Once this is done, do a ‘get info’ on the file. Go to the selection ‘open this file with’, and select Terminal.

Ramdisk script Info

Once this is done, when the script is double-clicked, it will open up in Terminal and run:

ramdisk initialisation

This will create the ram disk, and put it on the desktop, like any other type of network or local drive.

ramdisk info

You can then copy your video or other files to it, and get extremely fast access to those files. It’s great as well if you want to do some video editing / photo manipulation, but you have to remember it’s volatile memory. If you lose power for any reason, you’ve totally lost the contents of the drive.