Tmpfs: Difference between revisions
m r2.6.4) (robot Modifying: es:Tmpfs |
Added ramfs mention; cleaned up the Linux section to remove redundencies and the needless example; purged the Windows section as it's blatent shoehorning. |
||
Line 43: | Line 43: | ||
| date = September 1, 2001 |
| date = September 1, 2001 |
||
| quote = |
| quote = |
||
}} Article describing the Linux implementation</ref> tmpfs (previously known as '''shmfs''') |
}} Article describing the Linux implementation</ref> 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 the half the number of RAM pages, respectively)<ref>http://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt</ref>. These options are set at mount time and may be modified by remounting the filesystem. |
||
To prevent "out of memory" situations, tmpfs enforces a maximum filesystem size, this limit defaults to half of the available RAM.<ref>http://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt</ref> The limit can be set at mount time, for example |
|||
mount -t tmpfs -o size=1G,nr_inodes=10k,mode=0700 tmpfs /space |
|||
would mount with a 1 [[GiB]] limit with 10240 inodes and only accessible by the owner of <tt>/space</tt>. The filesystem's maximum size can also be changed on-the-fly, like "<tt>mount -o remount,size=2G /space</tt>". |
|||
/var/run and /var/lock can be tmpfs filesystems, to alleviate having to clean them up at each reboot. |
|||
=== BSD === |
=== BSD === |
||
Line 75: | Line 67: | ||
| date = December 2, 2008 |
| date = December 2, 2008 |
||
}}</ref> [[DragonFly BSD]] has ported NetBSD's implementation, where it is available in 2.5.1 and later versions. |
}}</ref> [[DragonFly BSD]] has ported NetBSD's implementation, where it is available in 2.5.1 and later versions. |
||
=== Microsoft Windows === |
|||
[[Microsoft Windows|Windows]] systems have a rough analog to tmpfs in the form of "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.<ref>{{cite web |
|||
| url = http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx#caching_behavior |
|||
| title = CreateFile Function |
|||
| author = msdn |
|||
| date = October 15, 2010 |
|||
}}</ref> 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. |
|||
==References== |
==References== |
Revision as of 19:21, 23 July 2011
tmpfs is a common name for a temporary file storage facility on many Unix-like operating systems. It is intended to appear as a mounted file system, but 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.
Semantics
Everything stored in tmpfs 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 can be swapped out to swap space.
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
Implementations
SunOS/Solaris
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, released in November 1994. Output for the Solaris df
command will show swap as the filesystem type 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 from version 2.4 and up.[3] 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 the half the number of RAM pages, respectively)[4]. These options are set at mount time and may be modified by remounting the filesystem.
BSD
4.2BSD introduced MFS,[5] 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;[6] 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.[7] DragonFly BSD has ported NetBSD's implementation, where it is available in 2.5.1 and later versions.
References
- ^ Peter Snyder. "tmpfs: A Virtual Memory File System" (PDF). Retrieved 2007-05-07.
- ^ Hal L. Stern. "SunOS 4.1 Performance Tuning" (GZipped PostScript). Retrieved 2007-05-07.
- ^ Daniel Robbins (September 1, 2001). "Advanced filesystem implementor's guide". Retrieved 2007-05-07. Article describing the Linux implementation
- ^ http://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt
- ^ "NetBSD mount_mfs(8) man page". December 8, 2007. Retrieved 2011-03-12.
- ^ Julio M. Merino Vidal (February 24, 2006). "NetBSD-SoC: Efficient memory file-system". Retrieved 2007-05-07.
- ^ Derek Morr (December 2, 2008). "FreeBSD tmpfs manpage". Retrieved 2008-12-02.
External links
- Documentation/filesystems/tmpfs.txt documentation in Linux source tree
- tmpfs(7FS) Solaris 10 man page
- mount_tmpfs(8) NetBSD man page