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 <[email protected]> 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.\" $FreeBSD$ 55.\" 56.Dd September 8, 2017 57.Dt TMPFS 5 58.Os 59.Sh NAME 60.Nm tmpfs 61.Nd "in-memory file system" 62.Sh SYNOPSIS 63To compile this driver into the kernel, 64place the following line in your 65kernel configuration file: 66.Bd -ragged -offset indent 67.Cd "options TMPFS" 68.Ed 69.Pp 70Alternatively, to load the driver as a 71module at boot time, place the following line in 72.Xr loader.conf 5 : 73.Bd -literal -offset indent 74tmpfs_load="YES" 75.Ed 76.Sh DESCRIPTION 77The 78.Nm 79driver implements an in-memory, or 80.Tn tmpfs 81file system. 82The filesystem stores both file metadata and data in main memory. 83This allows very fast and low latency accesses to the data. 84The data is volatile. 85An umount or system reboot invalidates it. 86These properties make the filesystem's mounts suitable for fast 87scratch storage, like 88.Pa /tmp . 89.Pp 90If the system becomes low on memory and swap is configured (see 91.Xr swapon 8 ), 92the system can transfer file data to swap space, freeing memory 93for other needs. 94Metadata, including the directory content, is never swapped out by the 95current implementation. 96Keep this in mind when planning the mount limits, especially when expecting 97to place many small files on a tmpfs mount. 98.Pp 99When 100.Xr mmap 2 101is used on a file from a tmpfs mount, the swap VM object managing the 102file pages is used to implement mapping and avoid double-copying of 103the file data. 104This quirk causes process inspection tools, like 105.Xr procstat 1 , 106to report anonymous memory mappings instead of file mappings. 107.Sh OPTIONS 108The following options are available when 109mounting 110.Nm 111file systems: 112.Bl -tag -width "It Cm maxfilesize" 113.It Cm gid 114Specifies the group ID of the root inode of the file system. 115Defaults to the mount point's GID. 116.It Cm uid 117Specifies the user ID of the root inode of the file system. 118Defaults to the mount point's UID. 119.It Cm mode 120Specifies the mode (in octal notation) of the root inode of the file system. 121Defaults to the mount point's mode. 122.It Cm nonc 123Do not use namecache to resolve names to files for the created mount. 124This saves memory, but currently might impair scalability for highly 125used mounts on large machines. 126.It Cm inodes 127Specifies the maximum number of nodes available to the file system. 128If not specified, the file system chooses a reasonable maximum based on 129the file system size, which can be limited with the 130.Cm size 131option. 132.It Cm size 133Specifies the total file system size in bytes, unless suffixed 134with one of k, m, g, t, or p, which denote byte, kilobyte, 135megabyte, gigabyte, terabyte and petabyte respectively. 136If zero (the default) or a value larger than SIZE_MAX - PAGE_SIZE 137is given, the available amount of memory (including 138main memory and swap space) will be used. 139.It Cm maxfilesize 140Specifies the maximum file size in bytes. 141Defaults to the maximum possible value. 142.El 143.Sh EXAMPLES 144To mount a 145.Nm 146memory file system: 147.Pp 148.Dl "mount -t tmpfs tmpfs /tmp" 149.Sh SEE ALSO 150.Xr procstat 1 , 151.Xr mmap 2 , 152.Xr nmount 2 , 153.Xr unmount 2 , 154.Xr fstab 5 , 155.Xr mdmfs 8 , 156.Xr mount 8 , 157.Xr swapinfo 8 , 158.Xr swapon 8 159.Sh HISTORY 160The 161.Nm 162driver first appeared in 163.Fx 7.0 . 164.Sh AUTHORS 165.An -nosplit 166The 167.Nm 168kernel implementation was written by 169.An Julio M. Merino Vidal Aq Mt [email protected] 170as a Google Summer of Code project. 171.Pp 172.An Rohit Jalan 173and others ported it from 174.Nx 175to 176.Fx . 177.Pp 178This manual page was written by 179.An Xin LI Aq Mt [email protected] . 180