Search

Top Posts

Comments

  • David: thanks! And Hey I wasn’t calling you a liar just that the image may have been a fake and i said that i...
  • Dagaza: Thanks for the post, itunes also has an option to “Show Exact Duplicates” meaning you don’t...
  • maria Nicolaou: I have a Mac Os X version 10.5.8 and I was wondering if I can change my keyboard to a light one!
  • Mike: Holy cow, I want that! I have 3 monitors and it has greatly increased my productivity, I think it is an...
  • Zachary Waldowski: The Nvidia 9400M, which is on anything current but the high-end MacBook Pros, high-end iMacs, and...

Categories

Recent Posts


Create a RAM Disk in Mac OS X

Another great tip from one of our readers, Stephen Adelson writes: “Back in Mac OS 9 and earlier you could make a RAM disk, a temporary disk that was super fast because it was read from system memory, or RAM, and not a relatively slow moving hard drive. In Mac OS X the feature has been removed from an easy GUI interface, but you can get the same effect and create your own RAM disk directly by typing the following commands in any terminal window.” Follow Stephen’s instructions below to create a 50mb RAM disk:

Type the following exactly in the Terminal (the $ represents a bash prompt and is not to be typed):

$ hdid -nomount ram://52428800
$ newfs_hfs /dev/disk1
$ mkdir /tmp/ramdisk1
$ mount -t hfs /dev/disk1 /tmp/ramdisk1

to ditch the RAM disk and unmount it, just type
$ hdiutil detach /dev/disk1

Thanks Stephen!

Create a RAM Disk in Mac OS X 10.5 or later

Some users report that the above instructions are not working to create a RAM disk in OS X 10.5 or later, if you have troubles with the above commands, try the following to create a 550mb RAM disk:

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

This has been tested and works in OS X 10.5.8, note that to remove the RAM disk you can simply eject it from the desktop as you would any other disk.

Posted by: Editor

Share

Save big on Mac Deals from Amazon.com

Comments:

Comments: 32

Comment from Anon.
Time: March 23, 2007, 7:45 am

While creating a ram disk “by hand” as you’ve shown here is possible, you or your readers may be interested in a donation-ware System Preference Pane by Michaël Parrot called Espérance DV . For one, it uses a GUI. Also, it has a few useful features:

- save its contents in a dmg
- mount the ram disk on login
- move certain caches to the ram disk

Comment from Philip
Time: March 23, 2007, 8:13 am

Any idea if it’s possible to have the ramdisk *NOT* appear on the desktop? I don’t need to see it there, just want to have it…

Comment from anon the other
Time: March 24, 2007, 1:07 pm

what are the security implications for RAM disks?

Comment from hmills
Time: March 26, 2007, 2:33 pm

hey everyone might want to know that a RAM disk disapears on reboot as with the Data on it, so don’t expect to hold files there for a long time securely

Comment from C Dizzle
Time: March 29, 2007, 4:33 pm

Have you tried Esperance DV? It is a freeware app from the developer of ClawMenu that does the same thing, only it does it via it’s own System Preferences pane. I have used it with much success while encoding video files.

Comment from h3rbz
Time: April 23, 2007, 5:54 am

@original-post: http://snippets.dzone.com/posts/show/1808

Yo :)

I have thrown together a quick script for anybody that wants to create a ramdisk regularly. It’s flexible enough for me, but can be edited to offer more options (if u know a little .sh scripting). The disk is dynamicly named and will show up on the desktop when the script is finished. Unmounting can be done as any drive in the finder. The major differences between my and the above approach is that I use diskutil to mount the created drive, so Finder likes it better, and i give the volume a label, so it can be better recognized by the user …

Here it is:

Leila:~ samynew[14:30:55]$ cat ramdisk
#!/bin/bash
if [ -n "$2" ]; then ARG_ERR=ERR; fi
if [ -z "$1" ]; then ARG_ERR=ERR; fi
if [ -n "$ARG_ERR" ];
then
echo 1 argument: size in MB
exit
fi
MB_SIZE=$1
let “MB_SIZE *= 2048″
echo Creating ${MB_SIZE} 512-blocks ramdisk
CREATED_RAMDISK=`hdid -nomount ram://${MB_SIZE}`
echo New block device: ${CREATED_RAMDISK}
DISK_NAME=`basename ${CREATED_RAMDISK}`
echo Creating volume with label: ${DISK_NAME}
newfs_hfs -v ${DISK_NAME} /dev/r$CREATED_RAMDISK
echo Mounting in /Volumes/${DISK_NAME}
mkdir /Volumes/${DISK_NAME}
diskutil mount ${CREATED_RAMDISK}

Make sure it’s chmodded to be executable: chmod u+x ramdisk
Run as: ./ramdisk

I hope u like it.. :)

Grtz

H3rbz

Comment from D Lamblin
Time: May 1, 2007, 2:55 pm

Mac OS 9 (8 and starting with 7) had the awesome feature in Apple ROM that persisted your ramdisk between reboots. It was actually possible to format it; install OS 7 (minimal) onto a 16mb ram disk; select it as your start up disk, and reboot. rebooting would be crazy fast. then you could defrag your original volume or do backups or whatever. I still have a PowerMac 8500 that I can do this on.

Pingback from links for 2007-05-02 | Napolux.com
Time: May 2, 2007, 7:33 am

[...] Create a RAM Disk in Mac OS X – OS X Daily (tags: howto mac osx disk ram) [...]

Comment from DD
Time: July 17, 2007, 5:28 pm

the following does not work in osx 10.4.9 on intel core 2 duo

$ hdid -nomount ram://52428800
$ newfs_hfs /dev/disk1
$ mkdir /tmp/ramdisk1
$ mount -t hfs /dev/disk1 /tmp/ramdisk1

to ditch the RAM disk and unmount it, just type
$ hdiutil detach /dev/disk1

OS 8 was great!
Dave

Comment from Jeff Clark
Time: September 22, 2007, 4:52 pm

Two comments…
1. The size argument is calculated as MEGABYTES * 2048. So if you want a 256mb ram disk…. 256 * 2048 = 524288
2. Under 10.4.8+ use the hdik tool to allocate the ram device….
hdik -nomount ram://524288

Rest of the commands will be the same.

Pingback from How to use a RAM / memory disk for MySQL in Rails at JJB Blog
Time: September 29, 2007, 1:58 pm

[...] (thanks to this tutorial for how-to create a RAM disk in OS X) [...]

Comment from NVR
Time: October 14, 2007, 1:02 am

Well… I see two problems with the RAMdisk:

1) I tested it – it clocked in at 51 MBps from/to internal HD in my MBP C2D. This is lower than what I got when using a FW800 HD (57 MBps). The internal HD (7200 RPM) might not be able to deliver more than 50-60 MBps anyway. So – there is really no big deal in actually using a RAM-disk. Has it occurred to you that there might be a reason there’s no RAM-disk easily available in Mac OS X? Maybe it’s because there’s no point! Back in the days when harddisks were slumbering around 1-5 MBps, a RAMdisk would really speed up the computer. OK – I didn’t test multiple rapid transactions – it’ll probably outclass any harddisk in terms of seektime, etc. Good for databases?

2) I couldn’t help noticing that MenuMeters didn’t catch the fact that my RAM use increased by 1 GB! So – unless this is a bug with MenuMeters, the computer is unaware that this space is occupied! This sounds like a potential for disaster.

Any thoughts and reflections on this observation, anyone? Are RAM-disks really that useful?

Comment from ALC
Time: October 15, 2007, 4:02 pm

It was possible under Windows to create a Ramdisk and then set the Web browser to write temp files to it. This increased the snappiness of the browser considerably.
I wouldn’t mind doing this with Safari, but see no way to tell it where to put the temp files…. in the same way that everyone says that OS X disks don’t need to be defragged, everyone says that Ramdisks are unnecessary. I would love to know if this is the case.

Comment from ohbogus
Time: October 22, 2007, 2:32 pm

i use two 2GB RAM-disks in my G5 dual 2Ghz which is equipped with 8GB of RAM, and a few internal 160 and 250 GB disks.

when instructing photoshop to use these two ramdisks as primary scratch disks, the performance is improved significantly, mainly when saving large files (>500MB). the time photoshop needs to “prepare for saving” is reduced by about 80%.

i figure this is because photoshop needs to reshuffle the scratch data from all the fragmented places on the scratch disks in order to correctly write these large files. this seems to be alot faster on a RAM disk.

any comments?

Comment from Sharath
Time: October 23, 2007, 6:38 am

How do you change the size of the RAMdisk without using the script in bash shell.

Comment from rdlfo
Time: November 20, 2007, 8:21 pm

On a intelcore2duo mac running 10.4.10:

I tested the tip, but the only way to ’see’ the ram disk (on the desktop, and photoshop’s preference pane for scratch disk) was logging out after creating it and then logging in again. Then, for ‘erasing’ i have to reboot. I’ve also tried the hdik tool but it only work as root so, as user, a you don’t have write permissions on the created volume.

Any thoughts?

Best regards.

Comment from seff
Time: June 17, 2008, 4:54 pm

a simple way

There is a simpler way to create a ram disk described here:
http://mac.wikia.com/wiki/RAM_disk#Creating_a_RAM_disk
You can do in a single line.

Pingback from The Cave » Blog Archive » Mac RAM Disk
Time: October 29, 2008, 12:58 pm

[...] Simple enough: [...]

Comment from mikey
Time: January 26, 2009, 5:18 am

I tried these commands and fter a couple errors and guessing, I ended up with an unknown volume that I cannot access or delete!

df
Filesystem 512-blocks Used Avail Cap Mounted on
/dev/disk2 985 19 966 2% /private/tmp

hdiutil detach /dev/disk2
“disk2″ unmounted.
hdiutil:couldn’t eject “disk2″ – error 49168

Any thoughts?
thanks,
mikey

Comment from CrashPlan.nl online backup
Time: March 28, 2009, 7:57 am

Over here on OS X 10.5.6 (on intel mac mini 2,1) we receive the same error as mikey.

Unknown volume, that is unmountable.

$ hdiutil detach /dev/disk1
“disk1″ unmounted.
hdiutil: couldn’t eject “disk1″ – error 49168

$ df
Filesystem 512-blocks Used Available Capacity Mounted on
/dev/disk0s2 254341856 13817784 240012072 6% /
devfs 211 211 0 100% /dev
fdesc 2 2 0 100% /dev
map -hosts 0 0 0 100% /net
map auto_home 0 0 0 100% /home
/dev/disk1 2097152 24664 2072488 2% /private/tmp/ramdisk1

Comment from Gedeon
Time: June 24, 2009, 11:23 pm

I have just downloaded the free RAMDISK program .dmg file and it puts a ramdisk on the desktop which takes room from the internal hard disk so is it indeed a RAM disk? it does not seem so – therefore what is the point of it – a disk within the hard disk!?

Comment from Gedeon
Time: June 24, 2009, 11:23 pm

I have just downloaded the free RAMDISK program .dmg file and it puts a ramdisk on the desktop which takes room from the internal hard disk so is it indeed a RAM disk? it does not seem so – therefore what is the point of it – a disk within the hard disk!?

Comment from Tesselator
Time: August 13, 2009, 2:30 pm

I haven tried these scripts but I used “Espérance DV” mentioned in the first reply here. It’s great but it only allows 2 GB in size. :( I want 20 GB and then just keep 12 (or the 32 GB total) for apps and stuff. I benchmarked the Espérance DV RAM drive and the results can be seen here:

http://forums.macrumors.com/showpost.php?p=7838758&postcount=4

Enjoy.

Comment from Tesselator
Time: August 13, 2009, 2:35 pm

Edit:

(or the 32 GB total) should read: (of the 32 GB total) in the above message.

Sorry. :)

Comment from Peter Bjorn
Time: August 13, 2009, 7:49 pm

diskutil erasevolume HFS+ “ramdisks” `hdiutil attach -nomount ram://1165430`;

I used that to make a ram disk that is 500mb

Comment from Timo
Time: August 17, 2009, 1:57 am

Will ramdisk increase perfomance of webserver with mysql & php?

Pingback from Easily make a RAM or Scratch Disk in Mac OS X – OS X Daily
Time: August 26, 2009, 8:03 am

[...] you’d rather not download anything, you can follow our command line instructions to create a ram disk in mac os x using no third party downloads or utilities, only the [...]

Comment from Joel
Time: August 30, 2009, 6:31 pm

Created 2 1GB RAM disks on my MacPro, hit 405MB/s transfer rate – This is a terrific idea for Photoshop, the GUI should be built into OS X.

http://www.youtube.com/watch?v=Cs2nZiZsVdA

Comment from Mario
Time: November 5, 2009, 7:18 pm

Created 10 GB RAM disk and I get up 1.1 GB/s write speeds, and 1 GB/s read speeds.

Now if I could get an SSD with these transfer rates, I’d be a happy camper :D .

Photoshop performance is improve significantly if you put your PS cache into RAM disk (and since I have 32 GB of RAM, and PS CS4 is still only 32 bit in OS X, I can create 20 GB RAM disk and still have plenty of RAM to run PS and lots of other apps).

Comment from James Smith João Pessoa, Brazil
Time: December 7, 2009, 2:57 pm

This doesn’t work with Snow Leopard. I’d like to have something that works with 10.6.2. As a scratch disk for Final Cut Express, a RAM disk would be great.

Comment from Colin Dean
Time: December 12, 2009, 1:52 pm

“diskutil erasevolume HFS+ “ramdisk” `hdiutil attach -nomount ram://1165430`” works fine for me on 10.6.2.

Comment from Dasher
Time: March 11, 2010, 6:06 pm

Any experience creating a RAM disk, specifically for helping iTunes run faster? I am on a 2006 Imac 21″ CoreDuo with 2GB RAM. Snow leopard latest. ITunes library is 500GB, so library file is 25MB and the library xml is 136MG. The genius lib file is 1.2GB.
Anyway, running alone, iTunes is sluggish giving the spinning wheel anytime I ask it to do anything that writes to or reads from disk the itunes Library file. So managing the collection, sorting names playlist creations and modification, all the daliy doings of my music maintenance involve this library file being accessed all the time. I think this is at the core of my sluggish iTunes. Mac OS activiity monitor shows free ram, and a modest 40GB virtual memory use. Even when other apps are involved, there is still free RAM. anyway, as soon as I ask itunes to do something in a new field, like go from scrolling artists to viewing the main list, and clicking sort all songs by date added..boom boom pow, i get the damned rainbow wheel.
Would a RAM disk help. Can I direct iTunes to use RAM disk scratch space, or perhaps create an applet that will pair with Itunes launching, create a RAM disk and create a fresh copy of the iTune library there, and keep it synced with the master library file there on the internal HD. Then tell iTunes to use this new RAM disk copy of the library file.
any thoughts or advice appreciated!

Write a comment






March 23rd, 2007