]>
Commit | Line | Data |
---|---|---|
244b15d4 MK |
1 | .\" Copyright (c) 2016 by Michael Kerrisk <mtk.manpages@gmail.com> |
2 | .\" | |
5fbde956 | 3 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
244b15d4 | 4 | .\" |
45186a5d | 5 | .TH TMPFS 5 2021-03-22 "Linux man-pages (unreleased)" |
244b15d4 MK |
6 | .SH NAME |
7 | tmpfs \- a virtual memory filesystem | |
8 | .SH DESCRIPTION | |
9 | The | |
10 | .B tmpfs | |
11 | facility allows the creation of filesystems whose contents reside | |
12 | in virtual memory. | |
13 | Since the files on such filesystems typically reside in RAM, | |
14 | file access is extremely fast. | |
2dad4c59 | 15 | .PP |
244b15d4 MK |
16 | The filesystem is automatically created when mounting |
17 | a filesystem with the type | |
1ae6b2c7 | 18 | .B tmpfs |
244b15d4 | 19 | via a command such as the following: |
019d9ee8 MK |
20 | .PP |
21 | .in +4n | |
22 | .EX | |
1c8ae9fe | 23 | $ sudo mount \-t tmpfs \-o size=10M tmpfs /mnt/mytmpfs |
019d9ee8 MK |
24 | .EE |
25 | .in | |
26 | .PP | |
244b15d4 MK |
27 | A |
28 | .B tmpfs | |
29 | filesystem has the following properties: | |
30 | .IP * 3 | |
31 | The filesystem can employ swap space when physical memory pressure | |
32 | demands it. | |
33 | .IP * | |
244b15d4 MK |
34 | The filesystem consumes only as much physical memory and swap space |
35 | as is required to store the current contents of the filesystem. | |
36 | .IP * | |
37 | During a remount operation | |
38 | .RI ( "mount\ \-o\ remount" ), | |
39 | the filesystem size can be changed | |
40 | (without losing the existing contents of the filesystem). | |
41 | .PP | |
42 | If a | |
43 | .B tmpfs | |
44 | filesystem is unmounted, its contents are discarded (lost). | |
462a385e CG |
45 | .\" See mm/shmem.c:shmem_parse_options for options it supports. |
46 | .SS Mount options | |
47 | The | |
48 | .B tmpfs | |
49 | filesystem supports the following mount options: | |
50 | .TP | |
51 | .BR size "=\fIbytes\fP" | |
52 | Specify an upper limit on the size of the filesystem. | |
53 | The size is given in bytes, and rounded up to entire pages. | |
d745d283 | 54 | .IP |
462a385e CG |
55 | The size may have a |
56 | .BR k , | |
57 | .BR m , | |
58 | or | |
59 | .B g | |
3ded684c | 60 | suffix for Ki, Mi, Gi (binary kilo (kibi), binary mega (mebi), and binary giga |
462a385e | 61 | (gibi)). |
d745d283 | 62 | .IP |
462a385e CG |
63 | The size may also have a % suffix to limit this instance to a percentage of |
64 | physical RAM. | |
d745d283 MK |
65 | .IP |
66 | The default, when neither | |
67 | .B size | |
68 | nor | |
69 | .B nr_blocks | |
70 | is specified, is | |
71 | .IR size=50% . | |
462a385e CG |
72 | .TP |
73 | .BR nr_blocks "=\fIblocks\fP" | |
74 | The same as | |
75 | .BR size , | |
d745d283 MK |
76 | but in blocks of |
77 | .BR PAGE_CACHE_SIZE . | |
78 | .IP | |
462a385e CG |
79 | Blocks may be specified with |
80 | .BR k , | |
81 | .BR m , | |
82 | or | |
83 | .B g | |
84 | suffixes like | |
85 | .BR size , | |
86 | but not a % suffix. | |
87 | .TP | |
88 | .BR nr_inodes "=\fIinodes\fP" | |
89 | The maximum number of inodes for this instance. | |
90 | The default is half of the number of your physical RAM pages, or (on a | |
91 | machine with highmem) the number of lowmem RAM pages, whichever is smaller. | |
d745d283 | 92 | .IP |
462a385e CG |
93 | Inodes may be specified with |
94 | .BR k , | |
95 | .BR m , | |
96 | or | |
97 | .B g | |
98 | suffixes like | |
99 | .BR size , | |
100 | but not a % suffix. | |
101 | .TP | |
102 | .BR mode "=\fImode\fP" | |
103 | Set initial permissions of the root directory. | |
104 | .TP | |
105 | .BR gid "=\fIgid\fP (since Linux 2.5.7)" | |
106 | .\" Technically this is also in some version of Linux 2.4. | |
107 | .\" commit 099445b489625b80b1d6687c9b6072dbeaca4096 | |
108 | Set the initial group ID of the root directory. | |
109 | .TP | |
110 | .BR uid "=\fIuid\fP (since Linux 2.5.7)" | |
111 | .\" Technically this is also in some version of Linux 2.4. | |
112 | .\" commit 099445b489625b80b1d6687c9b6072dbeaca4096 | |
113 | Set the initial user ID of the root directory. | |
114 | .TP | |
a9e25912 | 115 | .BR huge "=\fIhuge_option\fR (since Linux 4.7.0)" |
462a385e CG |
116 | .\" commit 5a6e75f8110c97e2a5488894d4e922187e6cb343 |
117 | Set the huge table memory allocation policy for all files in this instance (if | |
d745d283 MK |
118 | .B CONFIG_TRANSPARENT_HUGE_PAGECACHE |
119 | is enabled). | |
a9e25912 MK |
120 | .IP |
121 | The | |
122 | .I huge_option | |
123 | value is one of the following: | |
124 | .RS | |
125 | .TP | |
126 | .B never | |
b230d246 MK |
127 | Do not allocate huge pages. |
128 | This is the default. | |
a9e25912 MK |
129 | .TP |
130 | .B always | |
b230d246 | 131 | Attempt to allocate huge pages every time a new page is needed. |
a9e25912 MK |
132 | .TP |
133 | .B within_size | |
b230d246 MK |
134 | Only allocate huge page if it will be fully within |
135 | .IR i_size . | |
136 | Also respect | |
137 | .BR fadvise (2)/ madvise (2) | |
138 | hints | |
a9e25912 MK |
139 | .TP |
140 | .B advise | |
b230d246 MK |
141 | Only allocate huge pages if requested with |
142 | .BR fadvise (2)/ madvise (2). | |
a9e25912 MK |
143 | .TP |
144 | .B deny | |
b230d246 | 145 | For use in emergencies, to force the huge option off from all mounts. |
a9e25912 MK |
146 | .TP |
147 | .B force | |
b230d246 | 148 | Force the huge option on for all mounts; useful for testing. |
a9e25912 | 149 | .RE |
462a385e | 150 | .TP |
a9e25912 | 151 | .BR mpol "=\fImpol_option\fR (since Linux 2.6.15)" |
462a385e CG |
152 | .\" commit 7339ff8302fd70aabf5f1ae26e0c4905fa74a495 |
153 | Set the NUMA memory allocation policy for all files in this instance (if | |
d745d283 MK |
154 | .B CONFIG_NUMA |
155 | is enabled). | |
a9e25912 MK |
156 | .IP |
157 | The | |
158 | .I mpol_option | |
159 | value is one of the following: | |
160 | .RS | |
161 | .TP | |
162 | .B default | |
ac02e57c MK |
163 | Use the process allocation policy (see |
164 | .BR set_mempolicy (2)). | |
a9e25912 | 165 | .TP |
ac02e57c MK |
166 | .BR prefer ":\fInode\fP" |
167 | Preferably allocate memory from the given | |
168 | .IR node . | |
a9e25912 | 169 | .TP |
ac02e57c MK |
170 | .BR bind ":\fInodelist\fP" |
171 | Allocate memory only from nodes in | |
172 | .IR nodelist . | |
a9e25912 MK |
173 | .TP |
174 | .B interleave | |
ac02e57c | 175 | Allocate from each node in turn. |
a9e25912 | 176 | .TP |
ac02e57c MK |
177 | .BR interleave ":\fInodelist\fP" |
178 | Allocate from each node of | |
179 | .I in | |
180 | turn. | |
e1211582 MK |
181 | .TP |
182 | .B local | |
183 | Preferably allocate memory from the local node. | |
a9e25912 | 184 | .RE |
ac02e57c MK |
185 | .IP |
186 | In the above, | |
187 | .I nodelist | |
188 | is a comma-separated list of decimal numbers and ranges | |
189 | that specify NUMA nodes. | |
190 | A range is a pair of hyphen-separated decimal numbers, | |
191 | the smallest and largest node numbers in the range. | |
192 | For example, | |
193 | .IR mpol=bind:0\-3,5,7,9\-15 . | |
244b15d4 MK |
194 | .SH VERSIONS |
195 | The | |
196 | .B tmpfs | |
197 | facility was added in Linux 2.4, as a successor to the older | |
198 | .B ramfs | |
199 | facility, which did not provide limit checking or | |
200 | allow for the use of swap space. | |
201 | .SH NOTES | |
765633a2 | 202 | In order for user-space tools and applications to create |
244b15d4 MK |
203 | .B tmpfs |
204 | filesystems, the kernel must be configured with the | |
205 | .B CONFIG_TMPFS | |
206 | option. | |
2dad4c59 | 207 | .PP |
0d8f84db | 208 | The |
1ae6b2c7 | 209 | .B tmpfs |
0d8f84db MK |
210 | filesystem supports extended attributes (see |
211 | .BR xattr (7)), | |
212 | but | |
213 | .I user | |
214 | extended attributes are not permitted. | |
2dad4c59 | 215 | .PP |
244b15d4 MK |
216 | An internal shared memory filesystem is used for |
217 | System V shared memory | |
690e8267 | 218 | .RB ( shmget (2)) |
244b15d4 MK |
219 | and shared anonymous mappings |
220 | .RB ( mmap (2) | |
221 | with the | |
222 | .B MAP_SHARED | |
223 | and | |
1ae6b2c7 | 224 | .B MAP_ANONYMOUS |
244b15d4 MK |
225 | flags). |
226 | This filesystem is available regardless of whether | |
227 | the kernel was configured with the | |
228 | .B CONFIG_TMPFS | |
229 | option. | |
2dad4c59 | 230 | .PP |
244b15d4 MK |
231 | A |
232 | .B tmpfs | |
233 | filesystem mounted at | |
1ae6b2c7 | 234 | .I /dev/shm |
f2485f5a | 235 | is used for the implementation of POSIX shared memory |
244b15d4 MK |
236 | .RB ( shm_overview (7)) |
237 | and POSIX semaphores | |
238 | .RB ( sem_overview (7)). | |
2dad4c59 | 239 | .PP |
244b15d4 MK |
240 | The amount of memory consumed by all |
241 | .B tmpfs | |
242 | filesystems is shown in the | |
243 | .I Shmem | |
244 | field of | |
1ae6b2c7 | 245 | .I /proc/meminfo |
244b15d4 MK |
246 | and in the |
247 | .I shared | |
248 | field displayed by | |
249 | .BR free (1). | |
2dad4c59 | 250 | .PP |
244b15d4 MK |
251 | The |
252 | .B tmpfs | |
253 | facility was formerly called | |
254 | .BR shmfs . | |
255 | .SH SEE ALSO | |
256 | .BR df (1), | |
257 | .BR du (1), | |
fe340cde MK |
258 | .BR memfd_create (2), |
259 | .BR mmap (2), | |
b8847b59 | 260 | .BR set_mempolicy (2), |
fe340cde | 261 | .BR shm_open (3), |
244b15d4 MK |
262 | .BR mount (8) |
263 | .PP | |
a6fedca9 | 264 | The kernel source files |
1ae6b2c7 | 265 | .I Documentation/filesystems/tmpfs.txt |
a6fedca9 | 266 | and |
b49c2acb | 267 | .IR Documentation/admin\-guide/mm/transhuge.rst . |