Mount a RAM disk on boot

I'm running different applications for development purposes: Apache, MySQL, Tomcat and a couple of other products. I would like to set up the logging verbosity of all applications to debug, but when doing so, the disk gets a lot of activity.

Therefore I would like to create a RAM disk, for example 512 megabytes and get it mounted at boot time, so I can set the path of the log files to the RAM disk.

I looked into /etc/fstab, but there is a notice that this file is deprecated.


Solution 1:

You can create and mount a RAM disk with the following Terminal (i.e. shell) command:

diskutil erasevolume HFS+ "diskName" `hdiutil attach -nomount ram://2048`

Where 2048 can be any number and represents the number of 512 byte blocks you want to allocate. So 1,000,000 will get you 512,000,000 bytes. (Of course, you have to leave out the commas.)

So edit the command to your liking and put it in a shell script, then add that shell script to your login items. If you really need to run it at boot instead of when you log in, that is a lot more involved. Either you don't need to do it, because you're not starting Apache etc. before you log in, or you've already done it to get Apache to start before you log in, in which case you can just piggy back on whichever daemon you are starting first.