Creating a Linux ramdisk

While performing some testing a few weeks ago, I needed to create a ramdisk on one of my redhat AS 4.0 servers. I knew Solaris supported tmpfs, and after a bit of googling was surprised to find that Linux supported the tmpfs pseudo-file system as well. To create a ramdisk on a Linux host, you first need to find a suitable place to mount the tmpfs file system. For my tests, I used mkdir to create a directory valled /var/ramdisk:

$ mkdir /var/ramdisk

Once the mount point is identified, you can use the mount command to mount a tmpfs file system on top of that mount point:

$ mount -t tmpfs none /var/ramdisk -o size=28m

Now each time you access /var/ramdisk, your reads and writes will be coming directly from memory. Nice!

4 Comments

David  on July 13th, 2007

Heya,

Every played with the upper limit on ram disks?
A while ago I playe daorund:

http://www.quadratic.net/reference/ramdisk500.html

JWSmythe  on May 21st, 2009

I don’t know what the upper limit is on it. I just created a 20Gb ramdisk on my 64 bit Linux machine (Slamd64). Copying a 1Gb file on the ramdisk took about 2 seconds. Copying the same file on a RAID0 took 13 seconds.

krzemek  on October 3rd, 2010

Thanks mate for this. It’s very useful for me

George Mulak  on September 17th, 2011

I appreciate this a lot. I am having a little problem, though. I cannot seem to just erase a file in fedora. I throw it into the trash and the space is still allocated and used. How do I release or clear the space so that it is usable again?

Leave a Comment