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 thoughts on “Creating a Linux ramdisk”

  1. 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.

  2. 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 Reply

Your email address will not be published. Required fields are marked *