Tmpfs
Temporary file system on Unix-like systems
title: "Tmpfs" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["special-purpose-file-systems", "special-purpose-file-systems-supported-by-the-linux-kernel", "computer-related-introductions-in-1987", "linux-kernel-features"] description: "Temporary file system on Unix-like systems" topic_path: "technology/operating-systems" source: "https://en.wikipedia.org/wiki/Tmpfs" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Temporary file system on Unix-like systems ::
tmpfs (short for temporary file system) is a temporary file storage paradigm implemented in many Unix-like operating systems. It is intended to appear as a mounted file system, but data is stored in volatile memory rather than on a persistent storage device.
The idea behind tmpfs is similar to that of a RAM disk, in that both provide a file system stored in volatile memory; however, the implementations differ. While tmpfs is implemented at the logical file system layer, a RAM disk is implemented at the physical file system layer. In other words, a RAM disk is a virtual block device with a normal file system running on top of it, while tmpfs is a virtual file system without any underlying block device.
Semantics
Everything stored in tmpfs is temporary in the sense that no files will be directly created on non-volatile storage such as a hard drive (although swap space is used as backing store according to the page replacement policy of the operating system). On reboot, everything in tmpfs will be lost.
The memory used by tmpfs grows and shrinks to accommodate the files it contains.
Many Unix distributions enable and use tmpfs by default for the branch of the file system or for shared memory. This can be observed with as in this example:
Filesystem 1K-blocks Used Available Use% Mounted on tmpfs 1686428 0 1686428 0% /dev/shm tmpfs 674572 1808 672764 1% /run tmpfs 1024 0 1024 0% /run/credentials/systemd-journald.service tmpfs 1686428 1628 1684800 1% /tmp tmpfs 1024 0 1024 0% /run/credentials/getty@tty1.service tmpfs 1024 0 1024 0% /run/credentials/getty@tty3.service tmpfs 337284 32 337252 1% /run/user/0 tmpfs 1024 0 1024 0% /run/credentials/getty@tty4.service tmpfs 337284 280464 56820 84% /run/user/1000
Some Linux distributions (e.g. Debian until Debian 13) do not have a tmpfs mounted on by default; in this case, files under will be stored in the same file system as .
On almost all Linux distributions, a tmpfs is mounted on or to store temporary run-time files such as PID files and Unix domain sockets.
Implementations
There are several independent variants of the tmpfs concept. One of the earliest was developed by Sun Microsystems for SunOS, and other operating systems, such as the BSDs and Linux, provided their own.
SunOS
SunOS 4 includes what is most likely the earliest implementation of tmpfs; it first appeared in SunOS 4.0 in late 1987, together with new orthogonal address-space management that allowed any object to be memory-mapped.{{cite web | url = http://wiki.deimos.fr/images/1/1e/Solaris_tmpfs.pdf | title = tmpfs: A Virtual Memory File System | access-date = 2007-05-07 | author = Peter Snyder | archive-date = 2025-03-11 | archive-url = https://web.archive.org/web/20250311195100/https://wiki.deimos.fr/images/1/1e/Solaris_tmpfs.pdf | url-status = dead | url = http://www.sun3arc.org/papers/Perf/SunOS_4.1_performance_tuning.ps.gz | title = SunOS 4.1 Performance Tuning | access-date = 2007-05-07 | author = Hal L. Stern | format = GZipped PostScript | archive-date = 2012-02-07 | archive-url = https://web.archive.org/web/20120207050201/http://www.sun3arc.org/papers/Perf/SunOS_4.1_performance_tuning.ps.gz | url-status = dead
The Solaris directory was made a tmpfs file system by default starting with Solaris 2.1,{{cite web |title=SPARC: Installing Solaris Software |url=http://www.bitsavers.org/pdf/sun/solaris/2.5/802-1959-10_Solaris_2.5_SPARC_Installing_Solaris_Software_Nov95.pdf |publisher=SunSoft |pages=9 |date=December 1992 |access-date=April 23, 2019
- df -k Filesystem kbytes used avail capacity Mounted on swap 601592 0 601592 0% /tmp/test
Linux
tmpfs is supported by the Linux kernel beginning in version 2.4 (January 4, 2001). Linux tmpfs (previously known as shm fs) is based on the ramfs code used during bootup and also uses the page cache, but, unlike ramfs, it supports swapping out less-used pages to swap space, as well as filesystem size and inode limits to prevent out-of-memory situations (defaulting to half of physical RAM and half the number of RAM pages, respectively).{{cite web | url=https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt | title=tmpfs.txt |author1=Christoph Rohland |author2=Hugh Dickins |author3=KOSAKI Motohiro | access-date=2010-03-16 | publisher=kernel.org
BSD
4.2BSD introduced MFS,{{cite web | url = http://netbsd.gw.com/cgi-bin/man-cgi?mount_mfs++NetBSD-current | title = NetBSD mount_mfs(8) man page | date = 2007-12-08 | access-date = 2013-02-15 | archive-date = 2016-04-16 | archive-url = https://web.archive.org/web/20160416092907/http://netbsd.gw.com/cgi-bin/man-cgi?mount_mfs++NetBSD-current | url-status = dead
tmpfs, a memory filesystem implemented using conventional in-memory data structures to improve on the performance of MFS, was merged into the official NetBSD source tree on September 10, 2005;{{cite web | url = https://netbsd-soc.sourceforge.net/projects/tmpfs/ | title = NetBSD-SoC: Efficient memory file-system | author = Julio M. Merino Vidal | date = 2006-02-24 | access-date = 2013-02-15}} it is available in 4.0 and later versions.
FreeBSD has ported NetBSD's implementation, where it is available in 7.0 and later versions.{{cite web | url = https://www.freebsd.org/cgi/man.cgi?query=tmpfs | title = FreeBSD tmpfs(5) manpage | author = Xin LI | date = 2013-04-23 | access-date = 2008-12-02}}
DragonFly BSD has also ported NetBSD's implementation, where it is available in 2.5.1 and later versions.
OpenBSD ported NetBSD's tmpfs implementation as well, initially started by Pedro Martelletto and improved by many others. It was enabled in builds from December 17, 2013.{{cite web | url = http://marc.info/?l=openbsd-cvs&m=138706370810284&w=2 | title = CVS: cvs.openbsd.org: src - enable tmpfs so it gets tested some more }} The first release of OpenBSD with tmpfs included was 5.5.{{cite web | url = http://www.openbsd.org/55.html | title = OpenBSD 5.5 | date = 2014-05-01 | access-date = 2014-05-01}} OpenBSD 6.0 disabled tmpfs due to lack of maintenance.
Advantages
Due to the higher speeds of RAM compared to disk storage, tmpfs allows cache to be much faster when stored in one, leading to a more efficient overall system, though operating systems with a page cache will see less benefit as recently-used file pages will remain in-memory if free memory is sufficient. Since RAM is cleared upon reboot, tmpfs prevents systems from becoming too cluttered without requiring users to delete temporary files manually. In addition, storing files in RAM prevents disks from filling up too quickly and extends the life of flash-based storage by reducing write operations.
Disadvantages
On systems without swap space, or where swap space is running low, tmpfs may consume large amounts of memory.
If cache files are stored in tmpfs, programs will lose their cached data across reboots.
References
References
- Brockmeier, Joe. (2024-06-03). "Debian's /tmpest in a teapot". LWN.net.
- "Solaris Operating System (Unix)". operating-system.org.
- Daniel Robbins. (2001-09-01). "Common threads: Advanced filesystem implementor's guide, Part 3". IBM DeveloperWorks.
- Daniel Robbins. (2001-09-01). "Common threads: Advanced filesystem implementor's guide, Part 3". IBM DeveloperWorks.
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::