]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man5/tmpfs.5
Removed trailing white space at end of lines
[thirdparty/man-pages.git] / man5 / tmpfs.5
CommitLineData
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
27tmpfs \- a virtual memory filesystem
28.SH DESCRIPTION
29The
30.B tmpfs
31facility allows the creation of filesystems whose contents reside
32in virtual memory.
33Since the files on such filesystems typically reside in RAM,
34file access is extremely fast.
2dad4c59 35.PP
244b15d4
MK
36The filesystem is automatically created when mounting
37a filesystem with the type
38.BR tmpfs
39via 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
47A
48.B tmpfs
49filesystem has the following properties:
50.IP * 3
51The filesystem can employ swap space when physical memory pressure
52demands it.
53.IP *
244b15d4
MK
54The filesystem consumes only as much physical memory and swap space
55as is required to store the current contents of the filesystem.
56.IP *
57During a remount operation
58.RI ( "mount\ \-o\ remount" ),
59the filesystem size can be changed
60(without losing the existing contents of the filesystem).
61.PP
62If a
63.B tmpfs
64filesystem 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
67The
68.B tmpfs
69filesystem supports the following mount options:
70.TP
71.BR size "=\fIbytes\fP"
72Specify an upper limit on the size of the filesystem.
73The size is given in bytes, and rounded up to entire pages.
d745d283 74.IP
462a385e
CG
75The size may have a
76.BR k ,
77.BR m ,
78or
79.B g
80suffix for Ki, Mi, Gi (binary kilo (kibi), binary mega (mebi) and binary giga
81(gibi)).
d745d283 82.IP
462a385e
CG
83The size may also have a % suffix to limit this instance to a percentage of
84physical RAM.
d745d283
MK
85.IP
86The default, when neither
87.B size
88nor
89.B nr_blocks
90is specified, is
91.IR size=50% .
462a385e
CG
92.TP
93.BR nr_blocks "=\fIblocks\fP"
94The same as
95.BR size ,
d745d283
MK
96but in blocks of
97.BR PAGE_CACHE_SIZE .
98.IP
462a385e
CG
99Blocks may be specified with
100.BR k ,
101.BR m ,
102or
103.B g
104suffixes like
105.BR size ,
106but not a % suffix.
107.TP
108.BR nr_inodes "=\fIinodes\fP"
109The maximum number of inodes for this instance.
110The default is half of the number of your physical RAM pages, or (on a
111machine with highmem) the number of lowmem RAM pages, whichever is smaller.
d745d283 112.IP
462a385e
CG
113Inodes may be specified with
114.BR k ,
115.BR m ,
116or
117.B g
118suffixes like
119.BR size ,
120but not a % suffix.
121.TP
122.BR mode "=\fImode\fP"
123Set 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
128Set 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
133Set 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
137Set the huge table memory allocation policy for all files in this instance (if
d745d283
MK
138.B CONFIG_TRANSPARENT_HUGE_PAGECACHE
139is enabled).
a9e25912
MK
140.IP
141The
142.I huge_option
143value is one of the following:
144.RS
145.TP
146.B never
b230d246
MK
147Do not allocate huge pages.
148This is the default.
a9e25912
MK
149.TP
150.B always
b230d246 151Attempt to allocate huge pages every time a new page is needed.
a9e25912
MK
152.TP
153.B within_size
b230d246
MK
154Only allocate huge page if it will be fully within
155.IR i_size .
156Also respect
157.BR fadvise (2)/ madvise (2)
158hints
a9e25912
MK
159.TP
160.B advise
b230d246
MK
161Only allocate huge pages if requested with
162.BR fadvise (2)/ madvise (2).
a9e25912
MK
163.TP
164.B deny
b230d246 165For use in emergencies, to force the huge option off from all mounts.
a9e25912
MK
166.TP
167.B force
b230d246 168Force 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
173Set the NUMA memory allocation policy for all files in this instance (if
d745d283
MK
174.B CONFIG_NUMA
175is enabled).
a9e25912
MK
176.IP
177The
178.I mpol_option
179value is one of the following:
180.RS
181.TP
182.B default
ac02e57c
MK
183Use the process allocation policy (see
184.BR set_mempolicy (2)).
a9e25912 185.TP
ac02e57c
MK
186.BR prefer ":\fInode\fP"
187Preferably allocate memory from the given
188.IR node .
a9e25912 189.TP
ac02e57c
MK
190.BR bind ":\fInodelist\fP"
191Allocate memory only from nodes in
192.IR nodelist .
a9e25912
MK
193.TP
194.B interleave
ac02e57c 195Allocate from each node in turn.
a9e25912 196.TP
ac02e57c
MK
197.BR interleave ":\fInodelist\fP"
198Allocate from each node of
199.I in
200turn.
e1211582
MK
201.TP
202.B local
203Preferably allocate memory from the local node.
a9e25912 204.RE
ac02e57c
MK
205.IP
206In the above,
207.I nodelist
208is a comma-separated list of decimal numbers and ranges
209that specify NUMA nodes.
210A range is a pair of hyphen-separated decimal numbers,
211the smallest and largest node numbers in the range.
212For example,
213.IR mpol=bind:0\-3,5,7,9\-15 .
244b15d4
MK
214.SH VERSIONS
215The
216.B tmpfs
217facility was added in Linux 2.4, as a successor to the older
218.B ramfs
219facility, which did not provide limit checking or
220allow for the use of swap space.
221.SH NOTES
765633a2 222In order for user-space tools and applications to create
244b15d4
MK
223.B tmpfs
224filesystems, the kernel must be configured with the
225.B CONFIG_TMPFS
226option.
2dad4c59 227.PP
0d8f84db
MK
228The
229.BR tmpfs
230filesystem supports extended attributes (see
231.BR xattr (7)),
232but
233.I user
234extended attributes are not permitted.
2dad4c59 235.PP
244b15d4
MK
236An internal shared memory filesystem is used for
237System V shared memory
690e8267 238.RB ( shmget (2))
244b15d4
MK
239and shared anonymous mappings
240.RB ( mmap (2)
241with the
242.B MAP_SHARED
243and
244.BR MAP_ANONYMOUS
245flags).
246This filesystem is available regardless of whether
247the kernel was configured with the
248.B CONFIG_TMPFS
249option.
2dad4c59 250.PP
244b15d4
MK
251A
252.B tmpfs
253filesystem mounted at
254.IR /dev/shm
f2485f5a 255is used for the implementation of POSIX shared memory
244b15d4
MK
256.RB ( shm_overview (7))
257and POSIX semaphores
258.RB ( sem_overview (7)).
2dad4c59 259.PP
244b15d4
MK
260The amount of memory consumed by all
261.B tmpfs
262filesystems is shown in the
263.I Shmem
264field of
265.IR /proc/meminfo
266and in the
267.I shared
268field displayed by
269.BR free (1).
2dad4c59 270.PP
244b15d4
MK
271The
272.B tmpfs
273facility 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
284The kernel source files
285.IR Documentation/filesystems/tmpfs.txt
286and
a2463bae 287.IR Documentation/admin-guide/mm/transhuge.rst .