Debian Codegraph @

upstream/debian-unstable/man5/tmpfs.5

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