]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man5/tmpfs.5
Merge commit '850ef5ae11d69ea3381bd310f564f025fc8caea3'
[FreeBSD/FreeBSD.git] / share / man / man5 / tmpfs.5
1 .\"-
2 .\" Copyright (c) 2007 Xin LI
3 .\" Copyright (c) 2017 The FreeBSD Foundation, Inc.
4 .\"
5 .\" Part of this documentation was written by
6 .\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
7 .\" from the FreeBSD Foundation.
8 .\"
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in the
16 .\"    documentation and/or other materials provided with the distribution.
17 .\"
18 .\" THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 .\"
29 .\"-
30 .\" Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
31 .\" All rights reserved.
32 .\"
33 .\" Redistribution and use in source and binary forms, with or without
34 .\" modification, are permitted provided that the following conditions
35 .\" are met:
36 .\" 1. Redistributions of source code must retain the above copyright
37 .\"    notice, this list of conditions and the following disclaimer.
38 .\" 2. Redistributions in binary form must reproduce the above copyright
39 .\"    notice, this list of conditions and the following disclaimer in the
40 .\"    documentation and/or other materials provided with the distribution.
41 .\"
42 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
43 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
44 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
46 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
47 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
48 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
49 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
50 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
52 .\" POSSIBILITY OF SUCH DAMAGE.
53 .\"
54 .Dd September 18, 2023
55 .Dt TMPFS 5
56 .Os
57 .Sh NAME
58 .Nm tmpfs
59 .Nd "in-memory file system"
60 .Sh SYNOPSIS
61 To compile this driver into the kernel,
62 place the following line in your
63 kernel configuration file:
64 .Bd -ragged -offset indent
65 .Cd "options TMPFS"
66 .Ed
67 .Pp
68 Alternatively, to load the driver as a
69 module at boot time, place the following line in
70 .Xr loader.conf 5 :
71 .Bd -literal -offset indent
72 tmpfs_load="YES"
73 .Ed
74 .Sh DESCRIPTION
75 The
76 .Nm
77 driver implements an in-memory, or
78 .Nm
79 file system.
80 The filesystem stores both file metadata and data in main memory.
81 This allows very fast and low latency accesses to the data.
82 The data is volatile.
83 An umount or system reboot invalidates it.
84 These properties make the filesystem's mounts suitable for fast
85 scratch storage, like
86 .Pa /tmp .
87 .Pp
88 If the system becomes low on memory and swap is configured
89 .Po see
90 .Xr swapon 8 Pc ,
91 the system can transfer file data to swap space, freeing memory
92 for other needs.
93 Metadata, including the directory content, is never swapped out by the
94 current implementation.
95 Keep this in mind when planning the mount limits, especially when expecting
96 to place many small files on a tmpfs mount.
97 .Pp
98 When
99 .Xr mmap 2
100 is used on a file from a tmpfs mount, the swap VM object managing the
101 file pages is used to implement mapping and avoid double-copying of
102 the file data.
103 This quirk causes process inspection tools, like
104 .Xr procstat 1 ,
105 to report anonymous memory mappings instead of file mappings.
106 .Sh OPTIONS
107 The following options are available when
108 mounting
109 .Nm
110 file systems:
111 .Bl -tag -width "maxfilesize"
112 .It Cm easize
113 Set the maximum memory size used by extended attributes in bytes.
114 The default is 16 megabytes.
115 .It Cm export
116 Accept the
117 .Cm export
118 option for compatibility with
119 .Xr nfsv4 4 .
120 This option does nothing.
121 .It Cm gid
122 Set the group ID of the root inode of the file system.
123 The default is the mount point's GID.
124 .It Cm inodes
125 Set the maximum number of nodes available to the file system.
126 If not specified, the file system chooses a reasonable maximum based on
127 the file system size, which can be limited with the
128 .Cm size
129 option.
130 .It Cm maxfilesize
131 Set the maximum file size in bytes.
132 The default is the maximum possible value.
133 .It Cm mode
134 Set the mode (in octal notation) of the root inode of the file system.
135 The default is the mount point's mode.
136 .It Cm nomtime
137 Disable the tracking of mtime updates caused by writes to the
138 shared mapped areas backed by
139 .Nm
140 files.
141 This option removes periodic scans,
142 which downgrade read-write-mapped pages to read-only to note the writes.
143 .It Cm nonc
144 Do not use namecache to resolve names to files for the created mount.
145 This saves memory, but currently might impair scalability for highly
146 used mounts on large machines.
147 .It Cm nosymfollow
148 Do not follow
149 .Xr symlink 7 Ap s
150 on the mounted file system.
151 .It Cm pgread
152 Enable pgcache read for the mount.
153 .It Cm size
154 Set the total file system size in bytes, unless suffixed
155 with one of k, m, g, t, or p, which denote byte, kilobyte,
156 megabyte, gigabyte, terabyte and petabyte respectively.
157 If zero (the default) or a value larger than SIZE_MAX - PAGE_SIZE
158 is given, the available amount of memory (including
159 main memory and swap space) will be used.
160 .It Cm uid
161 Set the user ID of the root inode of the file system.
162 The default is the mount point's UID.
163 .It Cm union
164 Refer to
165 .Xr mount 8 .
166 .El
167 .Sh SYSCTL VARIABLES
168 The following
169 .Xr sysctl 8
170 variables are available:
171 .Bl -tag -width indent
172 .It Va vfs.tmpfs.memory_percent
173 The percentage of memory plus swap space available at kernel file system
174 initialization that can be used by a file system with a size of 0.
175 When this amount of space in use is reached, new files cannot be created
176 and files cannot be extended.
177 The default is 95%.
178 Changing this value also changes
179 .Va vfs.tmpfs.memory_reserved .
180 .It Va vfs.tmpfs.memory_reserved
181 The currently-reserved amount of memory plus swap space
182 based on the memory percentage.
183 The minimum is compiled into the system, and defaults to 4 MB.
184 .El
185 .Sh EXAMPLES
186 Mount a
187 .Nm
188 memory file system:
189 .Pp
190 .Dl "mount -t tmpfs tmpfs /tmp"
191 .Pp
192 Configure a
193 .Nm
194 mount via
195 .Xr fstab 5 :
196 .Bd -literal -offset indent
197 tmpfs /tmp tmpfs rw 0 0
198 .Ed
199 .Sh SEE ALSO
200 .Xr procstat 1 ,
201 .Xr mmap 2 ,
202 .Xr nmount 2 ,
203 .Xr unmount 2 ,
204 .Xr fstab 5 ,
205 .Xr mdmfs 8 ,
206 .Xr mount 8 ,
207 .Xr swapinfo 8 ,
208 .Xr swapon 8
209 .Sh HISTORY
210 The
211 .Nm
212 driver first appeared in
213 .Fx 7.0 .
214 .Sh AUTHORS
215 .An -nosplit
216 The
217 .Nm
218 kernel implementation was written by
219 .An Julio M. Merino Vidal Aq Mt jmmv@NetBSD.org
220 as a Google Summer of Code project.
221 .Pp
222 .An Rohit Jalan
223 and others ported it from
224 .Nx
225 to
226 .Fx .
227 .Pp
228 This manual page was written by
229 .An Xin LI Aq Mt delphij@FreeBSD.org .