CONTRIBUTING.d/patches: Please provide a git-range-diff(1)
[man-pages.git] / man5 / tmpfs.5
blob69404e1350bdea266b4e549b82502fae9d2f4d6d
1 .\" Copyright (c) 2016 by Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .TH tmpfs 5 (date) "Linux man-pages (unreleased)"
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.
16 The filesystem is automatically created when mounting
17 a filesystem with the type
18 .B tmpfs
19 via a command such as the following:
21 .in +4n
22 .EX
23 $ sudo mount \-t tmpfs \-o size=10M tmpfs /mnt/mytmpfs
24 .EE
25 .in
28 .B tmpfs
29 filesystem has the following properties:
30 .IP \[bu] 3
31 The filesystem can employ swap space when physical memory pressure
32 demands it.
33 .IP \[bu]
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 \[bu]
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).
42 If a
43 .B tmpfs
44 filesystem is unmounted, its contents are discarded (lost).
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.
54 The limit is removed if the size is
55 .BR 0 .
56 .IP
57 The size may have a
58 .BR k ,
59 .BR m ,
61 .B g
62 suffix for Ki, Mi, Gi (binary kilo (kibi), binary mega (mebi), and binary giga
63 (gibi)).
64 .IP
65 The size may also have a % suffix to limit this instance to a percentage of
66 physical RAM.
67 .IP
68 The default, when neither
69 .B size
70 nor
71 .B nr_blocks
72 is specified, is
73 .IR size=50% .
74 .TP
75 .BR nr_blocks "=\fIblocks\fP"
76 The same as
77 .BR size ,
78 but in blocks of
79 .BR PAGE_CACHE_SIZE .
80 .IP
81 Blocks may be specified with
82 .BR k ,
83 .BR m ,
85 .B g
86 suffixes like
87 .BR size ,
88 but not a % suffix.
89 .TP
90 .BR nr_inodes "=\fIinodes\fP"
91 The maximum number of inodes for this instance.
92 The default is half of the number of your physical RAM pages, or (on a
93 machine with highmem) the number of lowmem RAM pages, whichever is smaller.
94 The limit is removed if the number is
95 .BR 0 .
96 .IP
97 Inodes may be specified with
98 .BR k ,
99 .BR m ,
101 .B g
102 suffixes like
103 .BR size ,
104 but not a % suffix.
106 .BR noswap "(since Linux 6.4)"
107 .\" commit 2c6efe9cf2d7841b75fe38ed1adbd41a90f51ba0
108 Disables swap.
109 Remounts must respect the original settings.
110 By default swap is enabled.
112 .BR mode "=\fImode\fP"
113 Set initial permissions of the root directory.
115 .BR gid "=\fIgid\fP (since Linux 2.5.7)"
116 .\" Technically this is also in some version of Linux 2.4.
117 .\" commit 099445b489625b80b1d6687c9b6072dbeaca4096
118 Set the initial group ID of the root directory.
120 .BR uid "=\fIuid\fP (since Linux 2.5.7)"
121 .\" Technically this is also in some version of Linux 2.4.
122 .\" commit 099445b489625b80b1d6687c9b6072dbeaca4096
123 Set the initial user ID of the root directory.
125 .BR huge "=\fIhuge_option\fR (since Linux 4.7.0)"
126 .\" commit 5a6e75f8110c97e2a5488894d4e922187e6cb343
127 Set the huge table memory allocation policy for all files in this instance (if
128 .B CONFIG_TRANSPARENT_HUGEPAGE
129 is enabled).
132 .I huge_option
133 value is one of the following:
136 .B never
137 Do not allocate huge pages.
138 This is the default.
140 .B always
141 Attempt to allocate huge pages every time a new page is needed.
143 .B within_size
144 Only allocate huge page if it will be fully within
145 .IR i_size .
146 Also respect
147 .BR fadvise (2)
149 .BR madvise (2)
150 hints
152 .B advise
153 Only allocate huge pages if requested with
154 .BR fadvise (2)
156 .BR madvise (2).
158 .B deny
159 For use in emergencies, to force the huge option off from all mounts.
161 .B force
162 Force the huge option on for all mounts; useful for testing.
165 .BR mpol "=\fImpol_option\fR (since Linux 2.6.15)"
166 .\" commit 7339ff8302fd70aabf5f1ae26e0c4905fa74a495
167 Set the NUMA memory allocation policy for all files in this instance (if
168 .B CONFIG_NUMA
169 is enabled).
172 .I mpol_option
173 value is one of the following:
176 .B default
177 Use the process allocation policy (see
178 .BR set_mempolicy (2)).
180 .BR prefer ":\fInode\fP"
181 Preferably allocate memory from the given
182 .IR node .
184 .BR bind ":\fInodelist\fP"
185 Allocate memory only from nodes in
186 .IR nodelist .
188 .B interleave
189 Allocate from each node in turn.
191 .BR interleave ":\fInodelist\fP"
192 Allocate from each node of
193 .I in
194 turn.
196 .B local
197 Preferably allocate memory from the local node.
200 In the above,
201 .I nodelist
202 is a comma-separated list of decimal numbers and ranges
203 that specify NUMA nodes.
204 A range is a pair of hyphen-separated decimal numbers,
205 the smallest and largest node numbers in the range.
206 For example,
207 .IR mpol=bind:0\-3,5,7,9\-15 .
208 .SH VERSIONS
210 .B tmpfs
211 facility was added in Linux 2.4, as a successor to the older
212 .B ramfs
213 facility, which did not provide limit checking or
214 allow for the use of swap space.
215 .SH NOTES
216 In order for user-space tools and applications to create
217 .B tmpfs
218 filesystems, the kernel must be configured with the
219 .B CONFIG_TMPFS
220 option.
223 .B tmpfs
224 filesystem supports extended attributes (see
225 .BR xattr (7)),
227 .I user
228 extended attributes are not permitted.
230 An internal shared memory filesystem is used for
231 System V shared memory
232 .RB ( shmget (2))
233 and shared anonymous mappings
234 .RB ( mmap (2)
235 with the
236 .B MAP_SHARED
238 .B MAP_ANONYMOUS
239 flags).
240 This filesystem is available regardless of whether
241 the kernel was configured with the
242 .B CONFIG_TMPFS
243 option.
246 .B tmpfs
247 filesystem mounted at
248 .I /dev/shm
249 is used for the implementation of POSIX shared memory
250 .RB ( shm_overview (7))
251 and POSIX semaphores
252 .RB ( sem_overview (7)).
254 The amount of memory consumed by all
255 .B tmpfs
256 filesystems is shown in the
257 .I Shmem
258 field of
259 .I /proc/meminfo
260 and in the
261 .I shared
262 field displayed by
263 .BR free (1).
266 .B tmpfs
267 facility was formerly called
268 .BR shmfs .
269 .SH SEE ALSO
270 .BR df (1),
271 .BR du (1),
272 .BR memfd_create (2),
273 .BR mmap (2),
274 .BR set_mempolicy (2),
275 .BR shm_open (3),
276 .BR mount (8)
278 The kernel source files
279 .I Documentation/filesystems/tmpfs.txt
281 .IR Documentation/admin\-guide/mm/transhuge.rst .