Name

tmpfs — a virtual memory filesystem

DESCRIPTION

The tmpfs facility allows the creation of filesystems whose contents reside in virtual memory. Since the files on such filesystems typically reside in RAM, file access is extremely fast.

The filesystem is automatically created when mounting a filesystem with the type tmpfs via a command such as the following:

$ sudo mount −t tmpfs -o size=10M tmpfs /mnt/mytmpfs

A tmpfs filesystem has the following properties:

  • The filesystem can employ swap space when physical memory pressure demands it.

  • The size option can be used to specify an upper limit on the size of the filesystem. (The default size is half of the available RAM size.) The filesystem consumes only as much physical memory and swap space as is required to store the current contents of the filesystem.

  • During a remount operation (mount −o remount), the filesystem size can be changed (without losing the existing contents of the filesystem).

If a tmpfs filesystem is unmounted, its contents are discarded (lost).

VERSIONS

The tmpfs facility was added in Linux 2.4, as a successor to the older ramfs facility, which did not provide limit checking or allow for the use of swap space.

NOTES

For a description of the mount options that may be employed when mounting a tmpfs filesystem, see mount(8).

In order for user-space tools and applications to create tmpfs filesystems, the kernel must be configured with the CONFIG_TMPFS option.

The tmpfs filesystem supports extended attributes (see xattr(7)), but user extended attributes are not permitted.

An internal shared memory filesystem is used for System V shared memory (shmget(2)) and shared anonymous mappings (mmap(2) with the MAP_SHARED and MAP_ANONYMOUS flags). This filesystem is available regardless of whether the kernel was configured with the CONFIG_TMPFS option.

A tmpfs filesystem mounted at /dev/shm as used for the implementation of POSIX shared memory (shm_overview(7)) and POSIX semaphores (sem_overview(7)).

The amount of memory consumed by all tmpfs filesystems is shown in the Shmem field of /proc/meminfo and in the shared field displayed by free(1).

The tmpfs facility was formerly called shmfs.

SEE ALSO

df(1), du(1), memfd_create(2), mmap(2), shm_open(3), mount(8)

The kernel source file Documentation/filesystems/tmpfs.txt.

COLOPHON

This page is part of release 4.12 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man−pages/.


  Copyright (c) 2016 by Michael Kerrisk <mtk.manpagesgmail.com>

%%%LICENSE_START(VERBATIM)
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

Since the Linux kernel and libraries are constantly changing, this
manual page may be incorrect or out-of-date.  The author(s) assume no
responsibility for errors or omissions, or for damages resulting from
the use of the information contained herein.  The author(s) may not
have taken the same level of care in the production of this manual,
which is licensed free of charge, as they might when working
professionally.

Formatted or processed versions of this manual, if unaccompanied by
the source, must acknowledge the copyright and authors of this work.
%%%LICENSE_END