TMPFS

From Wikipedia, the free encyclopedia

TMPFS is a Linux file system which keeps all files in virtual memory. It is supported by the Linux kernel from version 2.4 and up. TMPFS distinguishes itself from ramdisk by using memory dynamically, through swapping unneeded pages onto swap space.

Everything is temporary in the sense that no files will be created on the hard drive; however, swap space is used as backing store in case of low memory situations. On reboot, everything in tmpfs will be lost.

The memory used by TMPFS grows and shrinks to accommodate the files it contains and is able to swap unneeded pages out to swap space. RAMFS, in contrast, does not make use of virtual memory (which can be an advantage or disadvantage). In addition, MFS and some older versions of ramfs did not grow and shrink dynamically and instead used a fixed amount memory at all times.

SHMFS is another name for TMPFS

Usage of tmpfs for example is "mount -t tmpfs -o size=1G,nr_inodes=10k,mode=0700 tmpfs /space" which will allocate 1GB in RAM/swap with 10240 inodes and only accessible by root (or any other owner of the directory /space). Loop mount is not possible with tmpfs.

Many Linux distributions enable and use tmpfs, this could be checked with df. One example output is this:

tmpfs                   516792         0    516792   0% /dev/shm

See this article for more info: http://www-128.ibm.com/developerworks/library/l-fs3.html

[edit] TMPFS on Windows

Windows systems have a rough analog to TMPFS in the form of "Temporary temporary Files". Files created with both FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE are held in memory and only written to disk if the system experiences low memory pressure. In this way they behave like TMPFS, except the files are written to the specified path during low memory situations rather than swap space. This technique is often used by servers along with TransmitFile to render content to a buffer before sending to the client.

[edit] Reference

  • article (Christoph Rohland, Nov 2001)