]>
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 | .\" |
4c1c5274 | 5 | .TH tmpfs 5 (date) "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: | |
22356d97 | 30 | .IP \(bu 3 |
244b15d4 MK |
31 | The filesystem can employ swap space when physical memory pressure |
32 | demands it. | |
22356d97 | 33 | .IP \(bu |
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. | |
22356d97 | 36 | .IP \(bu |
244b15d4 MK |
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 | |
998e8717 AC |
137 | .BR fadvise (2) |
138 | and | |
139 | .BR madvise (2) | |
b230d246 | 140 | hints |
a9e25912 MK |
141 | .TP |
142 | .B advise | |
b230d246 | 143 | Only allocate huge pages if requested with |
998e8717 AC |
144 | .BR fadvise (2) |
145 | or | |
146 | .BR madvise (2). | |
a9e25912 MK |
147 | .TP |
148 | .B deny | |
b230d246 | 149 | For use in emergencies, to force the huge option off from all mounts. |
a9e25912 MK |
150 | .TP |
151 | .B force | |
b230d246 | 152 | Force the huge option on for all mounts; useful for testing. |
a9e25912 | 153 | .RE |
462a385e | 154 | .TP |
a9e25912 | 155 | .BR mpol "=\fImpol_option\fR (since Linux 2.6.15)" |
462a385e CG |
156 | .\" commit 7339ff8302fd70aabf5f1ae26e0c4905fa74a495 |
157 | Set the NUMA memory allocation policy for all files in this instance (if | |
d745d283 MK |
158 | .B CONFIG_NUMA |
159 | is enabled). | |
a9e25912 MK |
160 | .IP |
161 | The | |
162 | .I mpol_option | |
163 | value is one of the following: | |
164 | .RS | |
165 | .TP | |
166 | .B default | |
ac02e57c MK |
167 | Use the process allocation policy (see |
168 | .BR set_mempolicy (2)). | |
a9e25912 | 169 | .TP |
ac02e57c MK |
170 | .BR prefer ":\fInode\fP" |
171 | Preferably allocate memory from the given | |
172 | .IR node . | |
a9e25912 | 173 | .TP |
ac02e57c MK |
174 | .BR bind ":\fInodelist\fP" |
175 | Allocate memory only from nodes in | |
176 | .IR nodelist . | |
a9e25912 MK |
177 | .TP |
178 | .B interleave | |
ac02e57c | 179 | Allocate from each node in turn. |
a9e25912 | 180 | .TP |
ac02e57c MK |
181 | .BR interleave ":\fInodelist\fP" |
182 | Allocate from each node of | |
183 | .I in | |
184 | turn. | |
e1211582 MK |
185 | .TP |
186 | .B local | |
187 | Preferably allocate memory from the local node. | |
a9e25912 | 188 | .RE |
ac02e57c MK |
189 | .IP |
190 | In the above, | |
191 | .I nodelist | |
192 | is a comma-separated list of decimal numbers and ranges | |
193 | that specify NUMA nodes. | |
194 | A range is a pair of hyphen-separated decimal numbers, | |
195 | the smallest and largest node numbers in the range. | |
196 | For example, | |
197 | .IR mpol=bind:0\-3,5,7,9\-15 . | |
244b15d4 MK |
198 | .SH VERSIONS |
199 | The | |
200 | .B tmpfs | |
201 | facility was added in Linux 2.4, as a successor to the older | |
202 | .B ramfs | |
203 | facility, which did not provide limit checking or | |
204 | allow for the use of swap space. | |
205 | .SH NOTES | |
765633a2 | 206 | In order for user-space tools and applications to create |
244b15d4 MK |
207 | .B tmpfs |
208 | filesystems, the kernel must be configured with the | |
209 | .B CONFIG_TMPFS | |
210 | option. | |
2dad4c59 | 211 | .PP |
0d8f84db | 212 | The |
1ae6b2c7 | 213 | .B tmpfs |
0d8f84db MK |
214 | filesystem supports extended attributes (see |
215 | .BR xattr (7)), | |
216 | but | |
217 | .I user | |
218 | extended attributes are not permitted. | |
2dad4c59 | 219 | .PP |
244b15d4 MK |
220 | An internal shared memory filesystem is used for |
221 | System V shared memory | |
690e8267 | 222 | .RB ( shmget (2)) |
244b15d4 MK |
223 | and shared anonymous mappings |
224 | .RB ( mmap (2) | |
225 | with the | |
226 | .B MAP_SHARED | |
227 | and | |
1ae6b2c7 | 228 | .B MAP_ANONYMOUS |
244b15d4 MK |
229 | flags). |
230 | This filesystem is available regardless of whether | |
231 | the kernel was configured with the | |
232 | .B CONFIG_TMPFS | |
233 | option. | |
2dad4c59 | 234 | .PP |
244b15d4 MK |
235 | A |
236 | .B tmpfs | |
237 | filesystem mounted at | |
1ae6b2c7 | 238 | .I /dev/shm |
f2485f5a | 239 | is used for the implementation of POSIX shared memory |
244b15d4 MK |
240 | .RB ( shm_overview (7)) |
241 | and POSIX semaphores | |
242 | .RB ( sem_overview (7)). | |
2dad4c59 | 243 | .PP |
244b15d4 MK |
244 | The amount of memory consumed by all |
245 | .B tmpfs | |
246 | filesystems is shown in the | |
247 | .I Shmem | |
248 | field of | |
1ae6b2c7 | 249 | .I /proc/meminfo |
244b15d4 MK |
250 | and in the |
251 | .I shared | |
252 | field displayed by | |
253 | .BR free (1). | |
2dad4c59 | 254 | .PP |
244b15d4 MK |
255 | The |
256 | .B tmpfs | |
257 | facility was formerly called | |
258 | .BR shmfs . | |
259 | .SH SEE ALSO | |
260 | .BR df (1), | |
261 | .BR du (1), | |
fe340cde MK |
262 | .BR memfd_create (2), |
263 | .BR mmap (2), | |
b8847b59 | 264 | .BR set_mempolicy (2), |
fe340cde | 265 | .BR shm_open (3), |
244b15d4 MK |
266 | .BR mount (8) |
267 | .PP | |
a6fedca9 | 268 | The kernel source files |
1ae6b2c7 | 269 | .I Documentation/filesystems/tmpfs.txt |
a6fedca9 | 270 | and |
b49c2acb | 271 | .IR Documentation/admin\-guide/mm/transhuge.rst . |