You can simply use command to create a ramdisk.
1 | diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://512000` |
This is 250 MB ramdisk, you can change 512000 to change the volume of the ramdisk.
If you want to use ramdisk for your safari cache
You can close the safari and run these
1 2 3 | rm -rf ~/Library/Caches/com.apple.Safari mkdir /Volumes/ramdisk/com.apple.Safari ln -s /Volumes/ramdisk/com.apple.Safari/ ~/Library/Caches/com.apple.Safari |
Another app’s caches you can just modify path form the code above.
If you need it runs automatically when you reboot.
You need to make a file called rc.local in your /etc/
Use text editor create a file called rc.local and drop to /etc/ and confirm the password.
The code should be like this (for Safari and Chrome cache, Firefox is easier, just search from Google)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #!/bin/sh if [ ! -d "/Volumes/ramdisk" ]; then diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://512000` fi if [ ! -d "/Volumes/ramdisk/com.apple.Safari" ]; then rm -rf ~/Library/Caches/com.apple.Safari mkdir /Volumes/ramdisk/com.apple.Safari ln -s /Volumes/ramdisk/com.apple.Safari/ ~/Library/Caches/com.apple.Safari fi if [ ! -d "/Volumes/ramdisk/Google" ]; then rm -rf ~/Library/Caches/Google mkdir /Volumes/ramdisk/Google ln -s /Volumes/ramdisk/Google/ ~/Library/Caches/Google fi if [ -d "/Volumes/ramdisk/com.apple.Safari" ] && [ -d "/Volumes/ramdisk/Google" ]; then echo "Ramdisk is enabled!" else echo "Error" fi |
You can also modify this if you need.
More information
Testing software: Blackmagic Disk Speed Test
10 Bit YUV 4:2:2 PAL | Default SSD | Default Ramdisk |
Disk Write Speed MB/s | 180 | 800 |
Disk Read Speed MB/s | 210 | 800 |
4 Responses to “How to Use Ramdisk in Your Mac”
I followed your instructions and created a file called rc.local with the above script. Ramdisk is not created upon reboot in 10.8 for me, however.
In my case it worked good on my 10.8.2 mac air.
You might not have privilege to edit the rc.local file.
Try to use sudo vi or sudo open -a TextEdit /etc/rc.local
Also make sure the rc.local file is executable. Use command sudo chmod +x /etc/rc.local
rc.local didn’t work for me. I put the script in to my startup objects. works fine!
doesn’t work on my macmini 2.3ghz core i7 4GB 1600Mhz os X 10.8.2