Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have read somewhere that one can put a file on a linux system into memory, and loading it will be superfast.

How do I do this? How do I verify the file is loaded from memory?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

If your operating system is aiming for POSIX compliance, you probably already have an tmpfs filesystem that you can write to at /dev/shm.

$ >/dev/shm/foo
$ df /dev/shm/foo
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                   224088         0    224088   0% /dev/shm

This may use swap, however. For a true ramdisk (that won't swap), you need to use the ramfs filesystem.

mount ramfs -t ramfs /mountpoint
share|improve this answer
Will this be then available to apache/php? I am interested in using this for a chat app and plan to save/retrieve recent lines from memory to avoid HDD write/read overhead. –  Majid Fouladpour Jan 2 '14 at 1:03

It's called a ramdisk. You can simply mount your RAM as follows:

mount tmpfs <mountpoint> -t tmpfs -o size=2G

This creates a ramdisk of 2 GiB. For more information see man mount and search for tmpfs.

share|improve this answer
This is not truly a ramdisk, tmpfs can swap. –  Chris Down Dec 24 '12 at 11:05

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.