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