Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to enable /dev/shm RAM disk for MySQL? (temp dir in /dev/shm)

$ vi /etc/fstab
tmpfs /dev/shm tmpfs defaults,size=512m 0 0

$ mount -o remount /dev/shm

Is this correct? Now what?




Server info:

VPS (Xen)
share|improve this question

migrated from Jul 26 '11 at 1:59

This question came from our site for professional and enthusiast programmers.

I think I should have posted this at – Randomprogrammer Jul 20 '11 at 11:02
Creating ramdisks will only starve the server of memory - every byte you allocate to a ramdisk is one byte less for cacheing/buffering and executing code. How about boosting mysql's cache/buffer sizes instead? – Marc B Jul 20 '11 at 15:09
What do you want to do when your VPS is rebooted, and you've lost all your tables ? Maybe you can rather add suitable indexes to speed things up. – nos Jul 20 '11 at 18:39… --- Question closed. – Randomprogrammer Jul 25 '11 at 16:51

The first rule of optimisation is: Don't assume.

Don't assume that you will automatically get better performance by putting (any) files on a ramdisc. Also consider how you are hoping to persist data following the (inevitable) power failure.

In general, SQL is slow because you are using it wrong, so it is an application design fault. The fix is to (re-)design your application correctly.

share|improve this answer
I didn't wrote that app. – Randomprogrammer Jul 25 '11 at 16:28

Just use MEMORY storage engine.

share|improve this answer

Edit your my.cnf file and add/change this

tmpdir = /dev/shm

under the [mysqld] section

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.