HOME

TheInfoList



OR:

tmpfs (short for Temporary File System) is a
temporary file A temporary file is a file created to store information temporarily, either for a program's intermediate use or for transfer to a permanent file when complete. It may be created by computer programs for a variety of purposes, such as when a progra ...
storage paradigm implemented in many
Unix-like A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
operating systems. It is intended to appear as a mounted
file system In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one larg ...
, but data is stored in volatile memory instead of a persistent storage device. A similar construction is a
RAM disk Ram, ram, or RAM may refer to: Animals * A male sheep * Ram cichlid, a freshwater tropical fish People * Ram (given name) * Ram (surname) * Ram (director) (Ramsubramaniam), an Indian Tamil film director * RAM (musician) (born 1974), Dutch ...
, which appears as a virtual disk drive and hosts a disk file system.


Semantics

Everything stored in tmpfs is temporary in the sense that no files will be directly created on
non-volatile storage Non-volatile memory (NVM) or non-volatile storage is a type of computer memory that can retain stored information even after power is removed. In contrast, volatile memory needs constant power in order to retain data. Non-volatile memory typi ...
such as a
hard drive A hard disk drive (HDD), hard disk, hard drive, or fixed disk is an electro-mechanical data storage device that stores and retrieves digital data using magnetic storage with one or more rigid rapidly rotating platters coated with mag ...
(although swap space is used as backing store in case of low memory situations). On
reboot In computing, rebooting is the process by which a running computer system is restarted, either intentionally or unintentionally. Reboots can be either a cold reboot (alternatively known as a hard reboot) in which the power to the system is physi ...
, everything in tmpfs will be lost. The memory used by tmpfs grows and shrinks to accommodate the files it contains. Many Unix
distribution Distribution may refer to: Mathematics * Distribution (mathematics), generalized functions used to formulate solutions of partial differential equations *Probability distribution, the probability of a particular value or value range of a vari ...
s enable and use tmpfs by default for the branch of the file system or for
shared memory In computer science, shared memory is memory that may be simultaneously accessed by multiple programs with an intent to provide communication among them or avoid redundant copies. Shared memory is an efficient means of passing data between progr ...
. This can be observed with 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 by default; in this case, files under will be stored in the same file system as . And 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. Temporary system files such as firmware variables are stored in /sys


Implementations

There are several independent variants of the tmpfs concept. One of the earliest was developed by
Sun Microsystems Sun Microsystems, Inc. (Sun for short) was an American technology company that sold computers, computer components, software, and information technology services and created the Java programming language, the Solaris operating system, ZFS, t ...
for SunOS, and other operating systems like the BSDs and Linux provided their own.


SunOS

SunOS SunOS is a Unix-branded operating system developed by Sun Microsystems for their workstation and server computer systems. The ''SunOS'' name is usually only used to refer to versions 1.0 to 4.1.4, which were based on BSD, while versions 5.0 an ...
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. The Solaris directory was made a tmpfs file system by default starting with Solaris 2.1, released in December 1992. 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


Linux

tmpfs is supported by the
Linux kernel The Linux kernel is a free and open-source, monolithic, modular, multitasking, Unix-like operating system kernel. It was originally authored in 1991 by Linus Torvalds for his i386-based PC, and it was soon adopted as the kernel for the GNU ...
beginning in version 2.4. Linux tmpfs (previously known as shmfs) is based on the ramfs code used during bootup and also uses the
page cache In computing, a page cache, sometimes also called disk cache, is a transparent cache for the pages originating from a secondary storage device such as a hard disk drive (HDD) or a solid-state drive (SSD). The operating system keeps a 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).


BSD

4.2BSD The History of the Berkeley Software Distribution begins in the 1970s. 1BSD (PDP-11) The earliest distributions of Unix from Bell Labs in the 1970s included the source code to the operating system, allowing researchers at universities to modify an ...
introduced MFS, 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 NetBSD is a free and open-source Unix operating system based on the Berkeley Software Distribution (BSD). It was the first open-source BSD descendant officially released after 386BSD was forked. It continues to be actively developed and is ava ...
source tree on September 10, 2005; it is available in 4.0 and later versions.
FreeBSD FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution (BSD), which was based on Research Unix. The first version of FreeBSD was released in 1993. In 2005, FreeBSD was the most popular ...
has ported NetBSD's implementation, where it is available in 7.0 and later versions.
DragonFly BSD DragonFly BSD is a free and open-source Unix-like operating system forked from FreeBSD 4.8. Matthew Dillon, an Amiga developer in the late 1980s and early 1990s and FreeBSD developer between 1994 and 2003, began working on DragonFly BSD ...
has also ported NetBSD's implementation, where it is available in 2.5.1 and later versions.
OpenBSD OpenBSD is a security-focused, free and open-source, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by forking NetBSD 1.0. According to the website, the OpenBSD project e ...
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. The first release of OpenBSD with tmpfs included was 5.5. 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 Cache, caching, or caché may refer to: Places United States * Cache, Idaho, an unincorporated community * Cache, Illinois, an unincorporated community * Cache, Oklahoma, a city in Comanche County * Cache, Utah, Cache County, Utah * Cache County ...
to be much faster when stored in one, leading to a more efficient overall system. 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 A solid-state drive (SSD) is a solid-state storage device that uses integrated circuit assemblies to store data Persistence (computer science), persistently, typically using flash memory, and functioning as secondary storage in the Computer ...
by reducing the amount of writes.


Disadvantages

On systems with less RAM, a tmpfs will fill up the memory quickly. If cache files are stored in tmpfs, programs will lose their cached data across reboots.


References


External links

* * {{File systems Special-purpose file systems Special-purpose file systems supported by the Linux kernel Computer-related introductions in 1987