What is tmpfs ?

April 04, 2012
tmpfs is a file system that stores all the files in virtual memory. tmpfs doesn't create any files on your hard drive. So if you unmount a tmpfs file system, all the files residing in it are lost for ever.

tmpfs is similar to ramfs and RAM disk but with a few additional features. tmpfs is able to grow or shrink its space to accommodate files,and it can use swap space to store unneeded data. ramfs and RAM disk doesn't have this capability.

Use of tmpfs in Linux

Debian, Ubuntu, Fedora, openSUSE, and many other Linux distributions use tmpfs file system to store all their run time data.

For example, in Ubuntu, if I execute the following command, I find that /run is mounted on a tmpfs file system.

$ df -h | grep tmpfs
tmpfs  401M  880K  400M   1% /run

The /run directory and its sub-directories store run time data of Linux processes and any running applications that may want to store their data.

You can check the actual [RAM + Swap] use of a tmpfs using df and du commands

Since tmpfs lives completely in the page cache and on swap, all tmpfs pages currently in memory will show up as cached.

tmpfs in some form or other is currently implemented in Sun/Solaris, Linux, and BSDs.


tmpfs @ Wikipedia.org

tmpfs @ kernel.org