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