tmpfs

from Wikipedia, the free encyclopedia

tmpfs ( English for temporary file system ) is a file system that in many Unix -like operating systems , as an improved substitute for ramfs for applying a RAM disk is used. As with ramfs, parts of the real working memory can be integrated and written to like a hard disk with tmpfs . In contrast to ramfs, however, tmpfs cannot overflow into the main memory that is still in regular use and thus lead to a system crash. In addition, with tmpfs you can use the virtual memory of the hard disk (swap) in addition to the real memory.

function

Everything that is stored in tmpfs is only temporary as it is not stored on disk and is no longer available after a restart . The advantage of tmpfs lies in its speed: reading and writing from the main memory is much faster than from the hard disk. For this reason, the temporary directory / tmp is often implemented with it. The directories / var / run and / var / lock are also often created using these systems.

The memory used by tmpfs grows and shrinks, depending on the files it contains, and can be swapped out to a swap area.

Many Unix distributions use tmpfs by default for the / tmp branch of the file system or for shared memory . This can be seen with the command df :

Dateisystem    Größe   Benutzt    Verf.    Verw%  Eingehängt auf
tmpfs           256M      688K    256M        1%  /tmp

Implementations

SunOS / Solaris

SunOS and later Solaris contain one of the earliest implementations of tmpfs, where it was used from version 4.1, which was released in March 1990. As of Solaris 2.1, / tmp is a tmpfs file system by default. The df command correctly shows “swap” as the background memory , regardless of what was specified as the background memory with the mount command, since this parameter is ignored by mount_tmpfs .

# df -k
Dateisystem 1K-Blöcke  Benutzt    Verf.    Verw%  Eingehängt auf
swap        601592           0   601592       0%  /tmp/test

Linux

The Linux kernel provides tmpfs version 2.4 or higher. Tmpfs (formerly also known as shmfs ) differs from a Linux RAM disk in that memory is dynamically allocated and less-used pages can be swapped out to a swap area. Ramfs , on the other hand, does not use any virtual memory (which can be both an advantage and a disadvantage). Tmpfs can grow dynamically up to a specified maximum size (preset to half of the available RAM) and only ever occupies as much memory as is required. The limit can be changed using options or e.g. B. by the command mount -t tmpfs -o size = 1G, nr_inodes = 10k, mode = 0700 tmpfs / space , which allows a maximum size of 1 GiB with a maximum of 10240 inodes and exclusive access for the owner of the file system / space . The limit can be changed during operation with the command mount -o remount, size = 2G / space . If the limit is set too large and there is not enough swap space, problems will arise.

BSD

Tmpfs was included in the official NetBSD sources on September 10, 2005 and can be used from version 4.0. The implementation of NetBSD has been ported for FreeBSD and is available from version 7.0.

On systems with little memory, the use of large temporary data in memory can cause instability.

Microsoft Windows

Windows has a similar concept with "temporary files". Files created with the flags FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE are kept in memory and only written to the hard disk when the system has little memory available. It behaves like tmpfs, with the difference that the files are written to a special folder instead of the swap area.

Web links

Individual evidence

  1. Peter Snyder: tmpfs: A Virtual Memory File System (PDF; 26 kB) Retrieved on May 7, 2007.
  2. Hal L. Stern: SunOS 4.1 Performance Tuning ( gzipped PostScript; 39 kB) Accessed February 15, 2013.
  3. ^ Daniel Robbins: Common threads: Advanced filesystem implementor's guide, Part 3 . September 1, 2001. Retrieved February 15, 2013. Description of implementation in Linux
  4. Julio M. Merino Vidal: NetBSD-SoC: Efficient memory file system . February 24, 2006. Retrieved February 15, 2013.
  5. Xin LI: FreeBSD tmpfs (5) manpage . April 23, 2012. Retrieved February 15, 2013.
  6. mount_tmpfs (8) - NetBSD Manual Pages . February 13, 2008. Retrieved February 15, 2013. NetBSD mount_tmpfs man page