Last updated

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 instead of a persistent storage device. A similar construction is a RAM disk, which appears as a virtual disk drive and hosts a disk file system.



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 /tmp branch of the file system or for shared memory. This can be observed with df as in this example:

Filesystem            Size  Used Avail Use% Mounted on tmpfs                 256M  688K  256M   1%  /tmp

Some Linux distributions (e.g. Debian) do not have a tmpfs mounted on /tmp by default; in this case, files under /tmp will be stored in the same file system as /.

And on almost all Linux distributions, a tmpfs is mounted on /run/ or /var/run/ to store temporary run-time files such as PID files and Unix domain sockets. Temporary system files such as firmware variables are stored in /sys


There are several independent variants of the tmpfs concept. One of the earliest was developed by Sun Microsystems for SunOS, and other operating systems like the BSDs and Linux provided their own.


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. [1] [2]

The Solaris /tmp directory was made a tmpfs file system by default starting with Solaris 2.1, [3] released in December 1992. [4] Output for the Solaris df command will show swap as the background storage for any tmpfs volume:

 # df -k  Filesystem  kbytes  used   avail capacity  Mounted on  swap        601592     0  601592     0%    /tmp/test


tmpfs is supported by the Linux kernel beginning in version 2.4. [5] Linux tmpfs (previously known as shmfs) 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). [6]


4.2BSD introduced MFS, [7] a memory-based file system implemented by applying the existing FFS disk filesystem to a virtual memory region.

tmpfs, a memory filesystem implemented using conventional in-memory data structures in order to improve on the performance of MFS, was merged into the official NetBSD source tree on September 10, 2005; [8] 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. [9]

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. [10] The first release of OpenBSD with tmpfs included was 5.5. [11] OpenBSD 6.0 disabled tmpfs due to lack of maintenance.


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 that the user manually deletes temporary files. In addition, storing files in RAM prevents disks from filling up too quickly and extends the life of solid-state drives by reducing the number of writes.


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.

Related Research Articles

<span class="mw-page-title-main">Disk partitioning</span> Creation of separate accessible storage areas on a secondary computer storage device

Disk partitioning or disk slicing is the creation of one or more regions on secondary storage, so that each region can be managed separately. These regions are called partitions. It is typically the first step of preparing a newly installed disk, before any file system is created. The disk stores the information about the partitions' locations and sizes in an area known as the partition table that the operating system reads before any other part of the disk. Each partition then appears to the operating system as a distinct "logical" disk that uses part of the actual disk. System administrators use a program called a partition editor to create, resize, delete, and manipulate the partitions. Partitioning allows the use of different filesystems to be installed for different kinds of files. Separating user data from system data can prevent the system partition from becoming full and rendering the system unusable. Partitioning can also make backing up easier. A disadvantage is that it can be difficult to properly size partitions, resulting in having one partition with too much free space and another nearly totally allocated.

The Unix file system (UFS) is a family of file systems supported by many Unix and Unix-like operating systems. It is a distant descendant of the original filesystem used by Version 7 Unix.

The Filesystem Hierarchy Standard (FHS) is a reference describing the conventions used for the layout of Unix-like systems. It has been made popular by its use in Linux distributions, but it is used by other Unix-like systems as well. It is maintained by the Linux Foundation. The latest version is 3.0, released on 3 June 2015.

In computer operating systems, memory paging is a memory management scheme by which a computer stores and retrieves data from secondary storage for use in main memory. In this scheme, the operating system retrieves data from secondary storage in same-size blocks called pages. Paging is an important part of virtual memory implementations in modern operating systems, using secondary storage to let programs exceed the size of available physical memory.

fstab is a system file commonly found in the directory /etc on Unix and Unix-like computer systems. In Linux, it is part of the util-linux package. The fstab file typically lists all available disk partitions and other types of file systems and data sources that may not necessarily be disk-based, and indicates how they are to be initialized or otherwise integrated into the larger file system structure.

df (Unix) Standard Unix command

df is a standard Unix command used to display the amount of available disk space for file systems on which the invoking user has appropriate read access. df is typically implemented using the statfs or statvfs system calls.

stat (system call) Unix system call

stat is a Unix system call that returns file attributes about an inode. The semantics of stat vary between operating systems. As an example, Unix command ls uses this system call to retrieve information on files that includes:

Filesystem in Userspace (FUSE) is a software interface for Unix and Unix-like computer operating systems that lets non-privileged users create their own file systems without editing kernel code. This is achieved by running file system code in user space while the FUSE module provides only a bridge to the actual kernel interfaces.

The proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes and other system information in a hierarchical file-like structure, providing a more convenient and standardized method for dynamically accessing process data held in the kernel than traditional tracing methods or direct access to kernel memory. Typically, it is mapped to a mount point named /proc at boot time. The proc file system acts as an interface to internal data structures about running processes in the kernel. In Linux, it can also be used to obtain information about the kernel and to change certain kernel parameters at runtime (sysctl).

File attributes are a type of meta-data that describe and may modify how files and/or directories in a filesystem behave. Typical file attributes may, for example, indicate or specify whether a file is visible, modifiable, compressed, or encrypted. The availability of most file attributes depends on support by the underlying filesystem where attribute data must be stored along with other control structures. Each attribute can have one of two states: set and cleared. Attributes are considered distinct from other metadata, such as dates and times, filename extensions or file system permissions. In addition to files, folders, volumes and other file system objects may have attributes.

In computing, the sticky bit is a user ownership access right flag that can be assigned to files and directories on Unix-like systems.

In computing, a temporary folder or temporary directory is a directory used to hold temporary files. Many operating systems and some software automatically delete the contents of this directory at bootup or at regular intervals, leaving the directory itself intact.

sync is a standard system call in the Unix operating system, which commits all data from the kernel filesystem buffers to non-volatile storage, i.e., data which has been scheduled for writing via low-level I/O system calls. Higher-level I/O layers such as stdio may maintain separate buffers of their own.

The following tables compare general and technical information for a number of file systems.

CacheFS is the name used for several similar software technologies designed to speed up distributed file system file access for networked computers. These technologies operate by storing (cached) copies of files on secondary memory, typically a local hard disk, so that if a file is accessed again, it can be done locally at much higher speeds than networks typically allow.

GEOM is the main storage framework for the FreeBSD operating system. It is available in FreeBSD 5.0 and later releases, and provides a standardized way to access storage layers. GEOM is modular and allows for geom modules to connect to the framework. For example, the geom_mirror module provides RAID1 or mirroring functionality to the system. A number of modules are provided as part of FreeBSD and others have been developed independently and are distributed via (e.g.) GitHub.

zram, formerly called compcache, is a Linux kernel module for creating a compressed block device in RAM, i.e. a RAM disk with on-the-fly disk compression. The block device created with zram can then be used for swap or as general-purpose RAM disk. The two most common uses for zram are for the storage of temporary files and as a swap device. Initially, zram had only the latter function, hence the original name "compcache".

ZFS is a file system with volume management capabilities. It began as part of the Sun Microsystems Solaris operating system in 2001. Large parts of Solaris – including ZFS – were published under an open source license as OpenSolaris for around 5 years from 2005 before being placed under a closed source license when Oracle Corporation acquired Sun in 2009–2010. During 2005 to 2010, the open source version of ZFS was ported to Linux, Mac OS X and FreeBSD. In 2010, the illumos project forked a recent version of OpenSolaris, including ZFS, to continue its development as an open source project. In 2013, OpenZFS was founded to coordinate the development of open source ZFS. OpenZFS maintains and manages the core ZFS code, while organizations using ZFS maintain the specific code and validation processes required for ZFS to integrate within their systems. OpenZFS is widely used in Unix-like systems.


  1. Peter Snyder. "tmpfs: A Virtual Memory File System" (PDF). Retrieved 2007-05-07.
  2. Hal L. Stern. "SunOS 4.1 Performance Tuning". Archived from the original (GZipped PostScript) on 2012-02-07. Retrieved 2007-05-07.
  3. "SPARC: Installing Solaris Software" (PDF). SunSoft. December 1992. p. 9. Retrieved April 23, 2019.
  4. "Solaris Operating System (Unix)".
  5. Daniel Robbins (2001-09-01). "Common threads: Advanced filesystem implementor's guide, Part 3". IBM DeveloperWorks . Retrieved 2013-02-15.
  6. Christoph Rohland; Hugh Dickins; KOSAKI Motohiro. "tmpfs.txt". . Retrieved 2010-03-16.
  7. "NetBSD mount_mfs(8) man page". 2007-12-08. Retrieved 2013-02-15.
  8. Julio M. Merino Vidal (2006-02-24). "NetBSD-SoC: Efficient memory file-system" . Retrieved 2013-02-15.
  9. Xin LI (2013-04-23). "FreeBSD tmpfs(5) manpage" . Retrieved 2008-12-02.
  10. "CVS: src - enable tmpfs so it gets tested some more".
  11. "OpenBSD 5.5". 2014-05-01. Retrieved 2014-05-01.