xref: /illumos-gate/usr/src/man/man4fs/tmpfs.4fs (revision 08855964b9970604433f7b19dcd71cf5af5e5f14)
1.\"
2.\" Copyright (c) 1990, Sun Microsystems, Inc.
3.\" Copyright 2021 Oxide Computer Company
4.\"
5.\" The contents of this file are subject to the terms of the
6.\" Common Development and Distribution License (the "License").
7.\" You may not use this file except in compliance with the License.
8.\"
9.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10.\" or http://www.opensolaris.org/os/licensing.
11.\" See the License for the specific language governing permissions
12.\" and limitations under the License.
13.\"
14.\" When distributing Covered Code, include this CDDL HEADER in each
15.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16.\" If applicable, add the following below this CDDL HEADER, with the
17.\" fields enclosed by brackets "[]" replaced with your own identifying
18.\" information: Portions Copyright [yyyy] [name of copyright owner]
19.\"
20.Dd October 9, 1990
21.Dt TMPFS 4FS
22.Os
23.Sh NAME
24.Nm tmpfs
25.Nd memory based file system
26.Sh SYNOPSIS
27.In sys/mount.h
28.Fo mount
29.Fa "const char *special"
30.Fa "const char *directory"
31.Fa IMS_DATA
32.Fa \(dqtmpfs\(dq
33.Fa NULL
34.Fa 0
35.Fc
36.Sh DESCRIPTION
37.Nm
38is a memory based file system which uses kernel resources relating to the VM
39system and page cache as a file system.
40Once mounted, a
41.Nm
42file system provides standard file operations and semantics.
43.Nm
44is so named because files and directories are not preserved across
45reboot or unmounts, all files residing on a
46.Nm
47file system that is unmounted will be lost.
48.Pp
49.Nm
50file systems can be mounted with the command:
51.Bd -literal -offset indent
52mount -F tmpfs swap directory
53.Ed
54.Pp
55Alternatively, to mount a
56.Nm
57file system on
58.Pa /tmp
59at multi-user startup time
60.Pq maximizing possible performance improvements  ,
61add the following line to
62.Pa /etc/vfstab :
63.Bd -literal -offset indent
64swap \(mi/tmp tmpfs \(mi yes \(mi
65.Ed
66.Pp
67.Nm
68is designed as a performance enhancement which is achieved by caching the writes
69to files residing on a
70.Nm
71file system.
72Performance improvements are most noticeable when a large number of short lived
73files are written and accessed on a
74.Nm
75file system.
76Large compilations with
77.Nm
78mounted on
79.Pa /tmp
80are a good example of this.
81.Pp
82Users of
83.Nm
84should be aware of some constraints involved in mounting a
85.Nm
86file system.
87The resources used by
88.Nm
89are the same as those used when commands are executed
90.Pq for example, swap space allocation .
91This means that large sized
92.Nm
93files can affect the amount of space left over for programs to execute.
94Likewise, programs requiring large amounts of memory use up the space available
95to
96.Nm
97Users running into this constraint
98.Po
99for example, running out of space on
100.Nm
101.Pc
102can allocate more swap space by using the
103.Xr swap 8
104command.
105.Pp
106Another constraint is that the number of files available in a
107.Nm
108file system is calculated based on the physical memory of the machine and not
109the size of the swap device/partition.
110If you have too many files,
111.Nm
112will print a warning message and you will be unable to create new files.
113You cannot increase this limit by adding swap space.
114.Pp
115Normal file system writes are scheduled to be written to a permanent storage
116medium along with all control information associated with the file
117.Pq for example, modification time, file permissions .
118.Nm
119control information resides only in memory and never needs to be written to
120permanent storage.
121File data remains in core until memory demands are sufficient to cause pages
122associated with
123.Nm
124to be reused at which time they are copied out to swap.
125.Pp
126An additional mount option can be specified to control the size of an individual
127.Nm
128file system.
129See
130.Xr mount_tmpfs 8
131for more details.
132.Sh DIAGNOSTICS
133If
134.Nm
135runs out of space, one of the following messages will display in the console.
136.Bl -tag -width Ds
137.It "directory: File system full, swap space limit exceeded"
138This message appears because a page could not be allocated while writing to a
139file.
140This can occur if
141.Nm
142is attempting to write more than it is allowed, or if currently executing
143programs are using a lot of memory.
144To make more space available, remove unnecessary files, exit from some programs,
145or allocate more swap space using
146.Xr swap 8 .
147.It "directory: File system full, memory allocation failed"
148.Nm
149ran out of physical memory while attempting to create a new file or
150directory.
151Remove unnecessary files or directories or install more physical memory.
152.El
153.Sh SEE ALSO
154.Xr mmap 2 ,
155.Xr mount 2 ,
156.Xr umount 2 ,
157.Xr vfstab 5 ,
158.Xr df 8 ,
159.Xr mount 8 ,
160.Xr mount_tmpfs 8 ,
161.Xr swap 8
162.Sh WARNINGS
163Files and directories on a
164.Nm
165file system are not preserved across reboots or unmounts.
166Command scripts or programs which count on this will not work as expected.
167.Sh NOTES
168Compilers do not necessarily use
169/tmp
170to write intermediate files therefore missing some significant performance
171benefits.
172This can be remedied by setting the environment variable
173.Ev TMPDIR to
174.Pa /tmp .
175Compilers use
176the value in this environment variable as the name of the directory to store
177intermediate files.
178.Pp
179.Sy swap
180to a
181.Nm
182file is not supported.
183.Pp
184.Xr df 8
185output is of limited accuracy since a
186.Nm
187file system size
188is not static and the space available to
189.Nm
190is dependent on the swap space demands of the entire system.
191