tmpfs is a file system which keeps all files in virtual memory. tmpfs uses a combination of computer RAM and disk-based SWAP space to create a filesystem, such as EXT4, that the operating system can use. Because tmpfs is located in RAM, it’s very fast to read and write data to and from it, several times faster than an SSD. As your computer runs out of RAM, some of the data in tmpfs will be flushed to the systems SWAP storage on disk. This will dramatically decrease the speed that the tmpfs can be used, but stop your computer from receiving out of memory errors.


Everything in tmpfs is temporary in the sense that no files will be created on your hard drive. If you unmount a tmpfs instance, everything stored therein is lost.


tmpfs puts everything into the kernel internal caches and grows and shrinks to accommodate the files it contains and can swap unneeded pages out to swap space.


If you compare it to ramfs (which was the template to create tmpfs), you gain swapping and limit checking. Another similar thing is the RAM disk (/dev/ram*), which simulates a fixed size hard drive in physical RAM, where you have to create an ordinary filesystem on top. Ramdisks cannot swap, and you cannot resize them.


Since tmpfs lives entirely in the page cache and on the swap, all tmpfs pages will be shown as “Shmem” in /proc/meminfo and “Shared” in free. Notice that these counters also include shared memory (shmem). The most reliable way to get the count is using df and du.

Was this answer helpful? 0 Users Found This Useful (0 Votes)