]>
Commit | Line | Data |
---|---|---|
244b15d4 MK |
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 | .\" | |
9ba01802 | 25 | .TH TMPFS 5 2019-03-06 "Linux" "Linux Programmer's Manual" |
244b15d4 MK |
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. | |
2dad4c59 | 35 | .PP |
244b15d4 MK |
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: | |
019d9ee8 MK |
40 | .PP |
41 | .in +4n | |
42 | .EX | |
43 | $ sudo mount \-t tmpfs -o size=10M tmpfs /mnt/mytmpfs | |
44 | .EE | |
45 | .in | |
46 | .PP | |
244b15d4 MK |
47 | A |
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 * | |
244b15d4 MK |
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). | |
462a385e CG |
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. | |
d745d283 | 74 | .IP |
462a385e CG |
75 | The size may have a |
76 | .BR k , | |
77 | .BR m , | |
78 | or | |
79 | .B g | |
80 | suffix for Ki, Mi, Gi (binary kilo (kibi), binary mega (mebi) and binary giga | |
81 | (gibi)). | |
d745d283 | 82 | .IP |
462a385e CG |
83 | The size may also have a % suffix to limit this instance to a percentage of |
84 | physical RAM. | |
d745d283 MK |
85 | .IP |
86 | The default, when neither | |
87 | .B size | |
88 | nor | |
89 | .B nr_blocks | |
90 | is specified, is | |
91 | .IR size=50% . | |
462a385e CG |
92 | .TP |
93 | .BR nr_blocks "=\fIblocks\fP" | |
94 | The same as | |
95 | .BR size , | |
d745d283 MK |
96 | but in blocks of |
97 | .BR PAGE_CACHE_SIZE . | |
98 | .IP | |
462a385e CG |
99 | Blocks may be specified with |
100 | .BR k , | |
101 | .BR m , | |
102 | or | |
103 | .B g | |
104 | suffixes like | |
105 | .BR size , | |
106 | but not a % suffix. | |
107 | .TP | |
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. | |
d745d283 | 112 | .IP |
462a385e CG |
113 | Inodes may be specified with |
114 | .BR k , | |
115 | .BR m , | |
116 | or | |
117 | .B g | |
118 | suffixes like | |
119 | .BR size , | |
120 | but not a % suffix. | |
121 | .TP | |
122 | .BR mode "=\fImode\fP" | |
123 | Set initial permissions of the root directory. | |
124 | .TP | |
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. | |
129 | .TP | |
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. | |
134 | .TP | |
a9e25912 | 135 | .BR huge "=\fIhuge_option\fR (since Linux 4.7.0)" |
462a385e CG |
136 | .\" commit 5a6e75f8110c97e2a5488894d4e922187e6cb343 |
137 | Set the huge table memory allocation policy for all files in this instance (if | |
d745d283 MK |
138 | .B CONFIG_TRANSPARENT_HUGE_PAGECACHE |
139 | is enabled). | |
a9e25912 MK |
140 | .IP |
141 | The | |
142 | .I huge_option | |
143 | value is one of the following: | |
144 | .RS | |
145 | .TP | |
146 | .B never | |
b230d246 MK |
147 | Do not allocate huge pages. |
148 | This is the default. | |
a9e25912 MK |
149 | .TP |
150 | .B always | |
b230d246 | 151 | Attempt to allocate huge pages every time a new page is needed. |
a9e25912 MK |
152 | .TP |
153 | .B within_size | |
b230d246 MK |
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 | |
a9e25912 MK |
159 | .TP |
160 | .B advise | |
b230d246 MK |
161 | Only allocate huge pages if requested with |
162 | .BR fadvise (2)/ madvise (2). | |
a9e25912 MK |
163 | .TP |
164 | .B deny | |
b230d246 | 165 | For use in emergencies, to force the huge option off from all mounts. |
a9e25912 MK |
166 | .TP |
167 | .B force | |
b230d246 | 168 | Force the huge option on for all mounts; useful for testing. |
a9e25912 | 169 | .RE |
462a385e | 170 | .TP |
a9e25912 | 171 | .BR mpol "=\fImpol_option\fR (since Linux 2.6.15)" |
462a385e CG |
172 | .\" commit 7339ff8302fd70aabf5f1ae26e0c4905fa74a495 |
173 | Set the NUMA memory allocation policy for all files in this instance (if | |
d745d283 MK |
174 | .B CONFIG_NUMA |
175 | is enabled). | |
a9e25912 MK |
176 | .IP |
177 | The | |
178 | .I mpol_option | |
179 | value is one of the following: | |
180 | .RS | |
181 | .TP | |
182 | .B default | |
ac02e57c MK |
183 | Use the process allocation policy (see |
184 | .BR set_mempolicy (2)). | |
a9e25912 | 185 | .TP |
ac02e57c MK |
186 | .BR prefer ":\fInode\fP" |
187 | Preferably allocate memory from the given | |
188 | .IR node . | |
a9e25912 | 189 | .TP |
ac02e57c MK |
190 | .BR bind ":\fInodelist\fP" |
191 | Allocate memory only from nodes in | |
192 | .IR nodelist . | |
a9e25912 MK |
193 | .TP |
194 | .B interleave | |
ac02e57c | 195 | Allocate from each node in turn. |
a9e25912 | 196 | .TP |
ac02e57c MK |
197 | .BR interleave ":\fInodelist\fP" |
198 | Allocate from each node of | |
199 | .I in | |
200 | turn. | |
e1211582 MK |
201 | .TP |
202 | .B local | |
203 | Preferably allocate memory from the local node. | |
a9e25912 | 204 | .RE |
ac02e57c MK |
205 | .IP |
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 . | |
244b15d4 MK |
214 | .SH VERSIONS |
215 | The | |
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 | |
765633a2 | 222 | In order for user-space tools and applications to create |
244b15d4 MK |
223 | .B tmpfs |
224 | filesystems, the kernel must be configured with the | |
225 | .B CONFIG_TMPFS | |
226 | option. | |
2dad4c59 | 227 | .PP |
0d8f84db MK |
228 | The |
229 | .BR tmpfs | |
230 | filesystem supports extended attributes (see | |
231 | .BR xattr (7)), | |
232 | but | |
233 | .I user | |
234 | extended attributes are not permitted. | |
2dad4c59 | 235 | .PP |
244b15d4 MK |
236 | An internal shared memory filesystem is used for |
237 | System V shared memory | |
690e8267 | 238 | .RB ( shmget (2)) |
244b15d4 MK |
239 | and shared anonymous mappings |
240 | .RB ( mmap (2) | |
241 | with the | |
242 | .B MAP_SHARED | |
243 | and | |
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. | |
2dad4c59 | 250 | .PP |
244b15d4 MK |
251 | A |
252 | .B tmpfs | |
253 | filesystem mounted at | |
254 | .IR /dev/shm | |
f2485f5a | 255 | is used for the implementation of POSIX shared memory |
244b15d4 MK |
256 | .RB ( shm_overview (7)) |
257 | and POSIX semaphores | |
258 | .RB ( sem_overview (7)). | |
2dad4c59 | 259 | .PP |
244b15d4 MK |
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). | |
2dad4c59 | 270 | .PP |
244b15d4 MK |
271 | The |
272 | .B tmpfs | |
273 | facility was formerly called | |
274 | .BR shmfs . | |
275 | .SH SEE ALSO | |
276 | .BR df (1), | |
277 | .BR du (1), | |
fe340cde MK |
278 | .BR memfd_create (2), |
279 | .BR mmap (2), | |
b8847b59 | 280 | .BR set_mempolicy (2), |
fe340cde | 281 | .BR shm_open (3), |
244b15d4 MK |
282 | .BR mount (8) |
283 | .PP | |
a6fedca9 MK |
284 | The kernel source files |
285 | .IR Documentation/filesystems/tmpfs.txt | |
286 | and | |
a2463bae | 287 | .IR Documentation/admin-guide/mm/transhuge.rst . |