1TMPFS(5)                   Linux Programmer's Manual                  TMPFS(5)
2
3
4

NAME

6       tmpfs - a virtual memory filesystem
7

DESCRIPTION

9       The  tmpfs  facility  allows the creation of filesystems whose contents
10       reside in virtual memory.  Since the files on  such  filesystems  typi‐
11       cally reside in RAM, file access is extremely fast.
12
13       The filesystem is automatically created when mounting a filesystem with
14       the type tmpfs via a command such as the following:
15
16           $ sudo mount -t tmpfs -o size=10M tmpfs /mnt/mytmpfs
17
18       A tmpfs filesystem has the following properties:
19
20       *  The filesystem can employ swap space when physical  memory  pressure
21          demands it.
22
23       *  The  filesystem consumes only as much physical memory and swap space
24          as is required to store the current contents of the filesystem.
25
26       *  During a remount operation (mount -o remount), the  filesystem  size
27          can be changed (without losing the existing contents of the filesys‐
28          tem).
29
30       If a tmpfs filesystem is unmounted, its contents are discarded (lost).
31
32   Mount options
33       The tmpfs filesystem supports the following mount options:
34
35       size=bytes
36              Specify an upper limit on the size of the filesystem.  The  size
37              is given in bytes, and rounded up to entire pages.
38
39              The  size  may  have  a k, m, or g suffix for Ki, Mi, Gi (binary
40              kilo (kibi), binary mega (mebi), and binary giga (gibi)).
41
42              The size may also have a % suffix to limit this  instance  to  a
43              percentage of physical RAM.
44
45              The  default,  when  neither size nor nr_blocks is specified, is
46              size=50%.
47
48       nr_blocks=blocks
49              The same as size, but in blocks of PAGE_CACHE_SIZE.
50
51              Blocks may be specified with k, m, or g suffixes like size,  but
52              not a % suffix.
53
54       nr_inodes=inodes
55              The  maximum number of inodes for this instance.  The default is
56              half of the number of your physical RAM pages, or (on a  machine
57              with  highmem)  the  number  of  lowmem  RAM pages, whichever is
58              smaller.
59
60              Inodes may be specified with k, m, or g suffixes like size,  but
61              not a % suffix.
62
63       mode=mode
64              Set initial permissions of the root directory.
65
66       gid=gid (since Linux 2.5.7)
67              Set the initial group ID of the root directory.
68
69       uid=uid (since Linux 2.5.7)
70              Set the initial user ID of the root directory.
71
72       huge=huge_option (since Linux 4.7.0)
73              Set  the  huge  table  memory allocation policy for all files in
74              this instance (if CONFIG_TRANSPARENT_HUGE_PAGECACHE is enabled).
75
76              The huge_option value is one of the following:
77
78              never  Do not allocate huge pages.  This is the default.
79
80              always Attempt to allocate huge pages every time a new  page  is
81                     needed.
82
83              within_size
84                     Only  allocate  huge  page  if  it  will  be fully within
85                     i_size.  Also respect fadvise(2)/madvise(2) hints
86
87              advise Only  allocate  huge  pages  if   requested   with   fad‐
88                     vise(2)/madvise(2).
89
90              deny   For use in emergencies, to force the huge option off from
91                     all mounts.
92
93              force  Force the huge option on for all mounts; useful for test‐
94                     ing.
95
96       mpol=mpol_option (since Linux 2.6.15)
97              Set  the NUMA memory allocation policy for all files in this in‐
98              stance (if CONFIG_NUMA is enabled).
99
100              The mpol_option value is one of the following:
101
102              default
103                     Use the process allocation policy (see set_mempolicy(2)).
104
105              prefer:node
106                     Preferably allocate memory from the given node.
107
108              bind:nodelist
109                     Allocate memory only from nodes in nodelist.
110
111              interleave
112                     Allocate from each node in turn.
113
114              interleave:nodelist
115                     Allocate from each node of in turn.
116
117              local  Preferably allocate memory from the local node.
118
119              In the above, nodelist is a comma-separated list of decimal num‐
120              bers  and  ranges that specify NUMA nodes.  A range is a pair of
121              hyphen-separated decimal numbers, the smallest and largest  node
122              numbers in the range.  For example, mpol=bind:0-3,5,7,9-15.
123

VERSIONS

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

NOTES

130       In order for user-space tools and applications to create tmpfs filesys‐
131       tems, the kernel must be configured with the CONFIG_TMPFS option.
132
133       The tmpfs filesystem supports extended attributes (see  xattr(7)),  but
134       user extended attributes are not permitted.
135
136       An internal shared memory filesystem is used for System V shared memory
137       (shmget(2)) and shared anonymous mappings (mmap(2) with the  MAP_SHARED
138       and  MAP_ANONYMOUS  flags).  This filesystem is available regardless of
139       whether the kernel was configured with the CONFIG_TMPFS option.
140
141       A tmpfs filesystem mounted at /dev/shm is used for  the  implementation
142       of   POSIX   shared   memory  (shm_overview(7))  and  POSIX  semaphores
143       (sem_overview(7)).
144
145       The amount of memory consumed by all tmpfs filesystems is shown in  the
146       Shmem  field  of  /proc/meminfo  and  in  the shared field displayed by
147       free(1).
148
149       The tmpfs facility was formerly called shmfs.
150

SEE ALSO

152       df(1), du(1), memfd_create(2), mmap(2), set_mempolicy(2),  shm_open(3),
153       mount(8)
154
155       The  kernel  source files Documentation/filesystems/tmpfs.txt and Docu‐
156       mentation/admin-guide/mm/transhuge.rst.
157

COLOPHON

159       This page is part of release 5.12 of the Linux  man-pages  project.   A
160       description  of  the project, information about reporting bugs, and the
161       latest    version    of    this    page,    can     be     found     at
162       https://www.kernel.org/doc/man-pages/.
163
164
165
166Linux                             2021-03-22                          TMPFS(5)
Impressum