proc.5: tfix
[man-pages.git] / man5 / tmpfs.5
blob9ff18852de2f4661fe72156146f54c4d4b64971b
1 .\" Copyright (c) 2016 by Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH TMPFS 5 2019-03-06 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 tmpfs \- a virtual memory filesystem
28 .SH DESCRIPTION
29 The
30 .B tmpfs
31 facility allows the creation of filesystems whose contents reside
32 in virtual memory.
33 Since the files on such filesystems typically reside in RAM,
34 file access is extremely fast.
35 .PP
36 The filesystem is automatically created when mounting
37 a filesystem with the type
38 .BR tmpfs
39 via a command such as the following:
40 .PP
41 .in +4n
42 .EX
43 $ sudo mount \-t tmpfs -o size=10M tmpfs /mnt/mytmpfs
44 .EE
45 .in
46 .PP
48 .B tmpfs
49 filesystem has the following properties:
50 .IP * 3
51 The filesystem can employ swap space when physical memory pressure
52 demands it.
53 .IP *
54 The filesystem consumes only as much physical memory and swap space
55 as is required to store the current contents of the filesystem.
56 .IP *
57 During a remount operation
58 .RI ( "mount\ \-o\ remount" ),
59 the filesystem size can be changed
60 (without losing the existing contents of the filesystem).
61 .PP
62 If a
63 .B tmpfs
64 filesystem is unmounted, its contents are discarded (lost).
65 .\" See mm/shmem.c:shmem_parse_options for options it supports.
66 .SS Mount options
67 The
68 .B tmpfs
69 filesystem supports the following mount options:
70 .TP
71 .BR size "=\fIbytes\fP"
72 Specify an upper limit on the size of the filesystem.
73 The size is given in bytes, and rounded up to entire pages.
74 .IP
75 The size may have a
76 .BR k ,
77 .BR m ,
79 .B g
80 suffix for Ki, Mi, Gi (binary kilo (kibi), binary mega (mebi) and binary giga
81 (gibi)).
82 .IP
83 The size may also have a % suffix to limit this instance to a percentage of
84 physical RAM.
85 .IP
86 The default, when neither
87 .B size
88 nor
89 .B nr_blocks
90 is specified, is
91 .IR size=50% .
92 .TP
93 .BR nr_blocks "=\fIblocks\fP"
94 The same as
95 .BR size ,
96 but in blocks of
97 .BR PAGE_CACHE_SIZE .
98 .IP
99 Blocks may be specified with
100 .BR k ,
101 .BR m ,
103 .B g
104 suffixes like
105 .BR size ,
106 but not a % suffix.
108 .BR nr_inodes "=\fIinodes\fP"
109 The maximum number of inodes for this instance.
110 The default is half of the number of your physical RAM pages, or (on a
111 machine with highmem) the number of lowmem RAM pages, whichever is smaller.
113 Inodes may be specified with
114 .BR k ,
115 .BR m ,
117 .B g
118 suffixes like
119 .BR size ,
120 but not a % suffix.
122 .BR mode "=\fImode\fP"
123 Set initial permissions of the root directory.
125 .BR gid "=\fIgid\fP (since Linux 2.5.7)"
126 .\" Technically this is also in some version of Linux 2.4.
127 .\" commit 099445b489625b80b1d6687c9b6072dbeaca4096
128 Set the initial group ID of the root directory.
130 .BR uid "=\fIuid\fP (since Linux 2.5.7)"
131 .\" Technically this is also in some version of Linux 2.4.
132 .\" commit 099445b489625b80b1d6687c9b6072dbeaca4096
133 Set the initial user ID of the root directory.
135 .BR huge "=\fIhuge_option\fR (since Linux 4.7.0)"
136 .\" commit 5a6e75f8110c97e2a5488894d4e922187e6cb343
137 Set the huge table memory allocation policy for all files in this instance (if
138 .B CONFIG_TRANSPARENT_HUGE_PAGECACHE
139 is enabled).
142 .I huge_option
143 value is one of the following:
146 .B never
147 Do not allocate huge pages.
148 This is the default.
150 .B always
151 Attempt to allocate huge pages every time a new page is needed.
153 .B within_size
154 Only allocate huge page if it will be fully within
155 .IR i_size .
156 Also respect
157 .BR fadvise (2)/ madvise (2)
158 hints
160 .B advise
161 Only allocate huge pages if requested with
162 .BR fadvise (2)/ madvise (2).
164 .B deny
165 For use in emergencies, to force the huge option off from all mounts.
167 .B force
168 Force the huge option on for all mounts; useful for testing.
171 .BR mpol "=\fImpol_option\fR (since Linux 2.6.15)"
172 .\" commit 7339ff8302fd70aabf5f1ae26e0c4905fa74a495
173 Set the NUMA memory allocation policy for all files in this instance (if
174 .B CONFIG_NUMA
175 is enabled).
178 .I mpol_option
179 value is one of the following:
182 .B default
183 Use the process allocation policy (see
184 .BR set_mempolicy (2)).
186 .BR prefer ":\fInode\fP"
187 Preferably allocate memory from the given
188 .IR node .
190 .BR bind ":\fInodelist\fP"
191 Allocate memory only from nodes in
192 .IR nodelist .
194 .B interleave
195 Allocate from each node in turn.
197 .BR interleave ":\fInodelist\fP"
198 Allocate from each node of
199 .I in
200 turn.
202 .B local
203 Preferably allocate memory from the local node.
206 In the above,
207 .I nodelist
208 is a comma-separated list of decimal numbers and ranges
209 that specify NUMA nodes.
210 A range is a pair of hyphen-separated decimal numbers,
211 the smallest and largest node numbers in the range.
212 For example,
213 .IR mpol=bind:0\-3,5,7,9\-15 .
214 .SH VERSIONS
216 .B tmpfs
217 facility was added in Linux 2.4, as a successor to the older
218 .B ramfs
219 facility, which did not provide limit checking or
220 allow for the use of swap space.
221 .SH NOTES
222 In order for user-space tools and applications to create
223 .B tmpfs
224 filesystems, the kernel must be configured with the
225 .B CONFIG_TMPFS
226 option.
229 .BR tmpfs
230 filesystem supports extended attributes (see
231 .BR xattr (7)),
233 .I user
234 extended attributes are not permitted.
236 An internal shared memory filesystem is used for
237 System V shared memory
238 .RB ( shmget (2))
239 and shared anonymous mappings
240 .RB ( mmap (2)
241 with the
242 .B MAP_SHARED
244 .BR MAP_ANONYMOUS
245 flags).
246 This filesystem is available regardless of whether
247 the kernel was configured with the
248 .B CONFIG_TMPFS
249 option.
252 .B tmpfs
253 filesystem mounted at
254 .IR /dev/shm
255 is used for the implementation of POSIX shared memory
256 .RB ( shm_overview (7))
257 and POSIX semaphores
258 .RB ( sem_overview (7)).
260 The amount of memory consumed by all
261 .B tmpfs
262 filesystems is shown in the
263 .I Shmem
264 field of
265 .IR /proc/meminfo
266 and in the
267 .I shared
268 field displayed by
269 .BR free (1).
272 .B tmpfs
273 facility was formerly called
274 .BR shmfs .
275 .SH SEE ALSO
276 .BR df (1),
277 .BR du (1),
278 .BR memfd_create (2),
279 .BR mmap (2),
280 .BR set_mempolicy (2),
281 .BR shm_open (3),
282 .BR mount (8)
284 The kernel source files
285 .IR Documentation/filesystems/tmpfs.txt
287 .IR Documentation/admin-guide/mm/transhuge.rst .