11687d771SAlexander Ziaee.\"- 21687d771SAlexander Ziaee.\" Copyright (c) 2007 Xin LI 3*dab59af3SLi-Wen Hsu.\" Copyright (c) 2017 The FreeBSD Foundation 41687d771SAlexander Ziaee.\" 51687d771SAlexander Ziaee.\" Part of this documentation was written by 61687d771SAlexander Ziaee.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship 71687d771SAlexander Ziaee.\" from the FreeBSD Foundation. 81687d771SAlexander Ziaee.\" 91687d771SAlexander Ziaee.\" Redistribution and use in source and binary forms, with or without 101687d771SAlexander Ziaee.\" modification, are permitted provided that the following conditions 111687d771SAlexander Ziaee.\" are met: 121687d771SAlexander Ziaee.\" 1. Redistributions of source code must retain the above copyright 131687d771SAlexander Ziaee.\" notice, this list of conditions and the following disclaimer. 141687d771SAlexander Ziaee.\" 2. Redistributions in binary form must reproduce the above copyright 151687d771SAlexander Ziaee.\" notice, this list of conditions and the following disclaimer in the 161687d771SAlexander Ziaee.\" documentation and/or other materials provided with the distribution. 171687d771SAlexander Ziaee.\" 181687d771SAlexander Ziaee.\" THIS DOCUMENTATION IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 191687d771SAlexander Ziaee.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 201687d771SAlexander Ziaee.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 211687d771SAlexander Ziaee.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 221687d771SAlexander Ziaee.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 231687d771SAlexander Ziaee.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 241687d771SAlexander Ziaee.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 251687d771SAlexander Ziaee.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 261687d771SAlexander Ziaee.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 271687d771SAlexander Ziaee.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 281687d771SAlexander Ziaee.\" 291687d771SAlexander Ziaee.\"- 301687d771SAlexander Ziaee.\" Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. 311687d771SAlexander Ziaee.\" All rights reserved. 321687d771SAlexander Ziaee.\" 331687d771SAlexander Ziaee.\" Redistribution and use in source and binary forms, with or without 341687d771SAlexander Ziaee.\" modification, are permitted provided that the following conditions 351687d771SAlexander Ziaee.\" are met: 361687d771SAlexander Ziaee.\" 1. Redistributions of source code must retain the above copyright 371687d771SAlexander Ziaee.\" notice, this list of conditions and the following disclaimer. 381687d771SAlexander Ziaee.\" 2. Redistributions in binary form must reproduce the above copyright 391687d771SAlexander Ziaee.\" notice, this list of conditions and the following disclaimer in the 401687d771SAlexander Ziaee.\" documentation and/or other materials provided with the distribution. 411687d771SAlexander Ziaee.\" 421687d771SAlexander Ziaee.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 431687d771SAlexander Ziaee.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 441687d771SAlexander Ziaee.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 451687d771SAlexander Ziaee.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 461687d771SAlexander Ziaee.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 471687d771SAlexander Ziaee.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 481687d771SAlexander Ziaee.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 491687d771SAlexander Ziaee.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 501687d771SAlexander Ziaee.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 511687d771SAlexander Ziaee.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 521687d771SAlexander Ziaee.\" POSSIBILITY OF SUCH DAMAGE. 531687d771SAlexander Ziaee.\" 541687d771SAlexander Ziaee.Dd September 18, 2023 551687d771SAlexander Ziaee.Dt TMPFS 4 561687d771SAlexander Ziaee.Os 571687d771SAlexander Ziaee.Sh NAME 581687d771SAlexander Ziaee.Nm tmpfs 591687d771SAlexander Ziaee.Nd "in-memory file system" 601687d771SAlexander Ziaee.Sh SYNOPSIS 611687d771SAlexander ZiaeeTo compile this driver into the kernel, 621687d771SAlexander Ziaeeplace the following line in your 631687d771SAlexander Ziaeekernel configuration file: 641687d771SAlexander Ziaee.Bd -ragged -offset indent 651687d771SAlexander Ziaee.Cd "options TMPFS" 661687d771SAlexander Ziaee.Ed 671687d771SAlexander Ziaee.Pp 681687d771SAlexander ZiaeeAlternatively, to load the driver as a 691687d771SAlexander Ziaeemodule at boot time, place the following line in 701687d771SAlexander Ziaee.Xr loader.conf 5 : 711687d771SAlexander Ziaee.Bd -literal -offset indent 721687d771SAlexander Ziaeetmpfs_load="YES" 731687d771SAlexander Ziaee.Ed 741687d771SAlexander Ziaee.Sh DESCRIPTION 751687d771SAlexander ZiaeeThe 761687d771SAlexander Ziaee.Nm 771687d771SAlexander Ziaeedriver implements an in-memory, or 781687d771SAlexander Ziaee.Nm 791687d771SAlexander Ziaeefile system. 801687d771SAlexander ZiaeeThe filesystem stores both file metadata and data in main memory. 811687d771SAlexander ZiaeeThis allows very fast and low latency accesses to the data. 821687d771SAlexander ZiaeeThe data is volatile. 831687d771SAlexander ZiaeeAn umount or system reboot invalidates it. 841687d771SAlexander ZiaeeThese properties make the filesystem's mounts suitable for fast 851687d771SAlexander Ziaeescratch storage, like 861687d771SAlexander Ziaee.Pa /tmp . 871687d771SAlexander Ziaee.Pp 881687d771SAlexander ZiaeeIf the system becomes low on memory and swap is configured 891687d771SAlexander Ziaee.Po see 901687d771SAlexander Ziaee.Xr swapon 8 Pc , 911687d771SAlexander Ziaeethe system can transfer file data to swap space, freeing memory 921687d771SAlexander Ziaeefor other needs. 931687d771SAlexander ZiaeeMetadata, including the directory content, is never swapped out by the 941687d771SAlexander Ziaeecurrent implementation. 951687d771SAlexander ZiaeeKeep this in mind when planning the mount limits, especially when expecting 961687d771SAlexander Ziaeeto place many small files on a tmpfs mount. 971687d771SAlexander Ziaee.Pp 981687d771SAlexander ZiaeeWhen 991687d771SAlexander Ziaee.Xr mmap 2 1001687d771SAlexander Ziaeeis used on a file from a tmpfs mount, the swap VM object managing the 1011687d771SAlexander Ziaeefile pages is used to implement mapping and avoid double-copying of 1021687d771SAlexander Ziaeethe file data. 1031687d771SAlexander ZiaeeThis quirk causes process inspection tools, like 1041687d771SAlexander Ziaee.Xr procstat 1 , 1051687d771SAlexander Ziaeeto report anonymous memory mappings instead of file mappings. 1061687d771SAlexander Ziaee.Sh OPTIONS 1071687d771SAlexander ZiaeeThe following options are available when 1081687d771SAlexander Ziaeemounting 1091687d771SAlexander Ziaee.Nm 1101687d771SAlexander Ziaeefile systems: 1111687d771SAlexander Ziaee.Bl -tag -width "maxfilesize" 1121687d771SAlexander Ziaee.It Cm easize 1131687d771SAlexander ZiaeeSet the maximum memory size used by extended attributes in bytes. 1141687d771SAlexander ZiaeeThe default is 16 megabytes. 1151687d771SAlexander Ziaee.It Cm export 1161687d771SAlexander ZiaeeAccept the 1171687d771SAlexander Ziaee.Cm export 1181687d771SAlexander Ziaeeoption for compatibility with 1191687d771SAlexander Ziaee.Xr nfsv4 4 . 1201687d771SAlexander ZiaeeThis option does nothing. 1211687d771SAlexander Ziaee.It Cm gid 1221687d771SAlexander ZiaeeSet the group ID of the root inode of the file system. 1231687d771SAlexander ZiaeeThe default is the mount point's GID. 1241687d771SAlexander Ziaee.It Cm inodes 1251687d771SAlexander ZiaeeSet the maximum number of nodes available to the file system. 1261687d771SAlexander ZiaeeIf not specified, the file system chooses a reasonable maximum based on 1271687d771SAlexander Ziaeethe file system size, which can be limited with the 1281687d771SAlexander Ziaee.Cm size 1291687d771SAlexander Ziaeeoption. 1301687d771SAlexander Ziaee.It Cm maxfilesize 1311687d771SAlexander ZiaeeSet the maximum file size in bytes. 1321687d771SAlexander ZiaeeThe default is the maximum possible value. 1331687d771SAlexander Ziaee.It Cm mode 1341687d771SAlexander ZiaeeSet the mode (in octal notation) of the root inode of the file system. 1351687d771SAlexander ZiaeeThe default is the mount point's mode. 1361687d771SAlexander Ziaee.It Cm nomtime 1371687d771SAlexander ZiaeeDisable the tracking of mtime updates caused by writes to the 1381687d771SAlexander Ziaeeshared mapped areas backed by 1391687d771SAlexander Ziaee.Nm 1401687d771SAlexander Ziaeefiles. 1411687d771SAlexander ZiaeeThis option removes periodic scans, 1421687d771SAlexander Ziaeewhich downgrade read-write-mapped pages to read-only to note the writes. 1431687d771SAlexander Ziaee.It Cm nonc 1441687d771SAlexander ZiaeeDo not use namecache to resolve names to files for the created mount. 1451687d771SAlexander ZiaeeThis saves memory, but currently might impair scalability for highly 1461687d771SAlexander Ziaeeused mounts on large machines. 1471687d771SAlexander Ziaee.It Cm nosymfollow 1481687d771SAlexander ZiaeeDo not follow 1491687d771SAlexander Ziaee.Xr symlink 7 Ap s 1501687d771SAlexander Ziaeeon the mounted file system. 1511687d771SAlexander Ziaee.It Cm pgread 1521687d771SAlexander ZiaeeEnable pgcache read for the mount. 1531687d771SAlexander Ziaee.It Cm size 1541687d771SAlexander ZiaeeSet the total file system size in bytes, unless suffixed 1551687d771SAlexander Ziaeewith one of k, m, g, t, or p, which denote byte, kilobyte, 1561687d771SAlexander Ziaeemegabyte, gigabyte, terabyte and petabyte respectively. 1571687d771SAlexander ZiaeeIf zero (the default) or a value larger than SIZE_MAX - PAGE_SIZE 1581687d771SAlexander Ziaeeis given, the available amount of memory (including 1591687d771SAlexander Ziaeemain memory and swap space) will be used. 1601687d771SAlexander Ziaee.It Cm uid 1611687d771SAlexander ZiaeeSet the user ID of the root inode of the file system. 1621687d771SAlexander ZiaeeThe default is the mount point's UID. 1631687d771SAlexander Ziaee.It Cm union 1641687d771SAlexander ZiaeeRefer to 1651687d771SAlexander Ziaee.Xr mount 8 . 1661687d771SAlexander Ziaee.El 1671687d771SAlexander Ziaee.Sh SYSCTL VARIABLES 1681687d771SAlexander ZiaeeThe following 1691687d771SAlexander Ziaee.Xr sysctl 8 1701687d771SAlexander Ziaeevariables are available: 1711687d771SAlexander Ziaee.Bl -tag -width indent 1721687d771SAlexander Ziaee.It Va vfs.tmpfs.memory_percent 1731687d771SAlexander ZiaeeThe percentage of memory plus swap space available at kernel file system 1741687d771SAlexander Ziaeeinitialization that can be used by a file system with a size of 0. 1751687d771SAlexander ZiaeeWhen this amount of space in use is reached, new files cannot be created 1761687d771SAlexander Ziaeeand files cannot be extended. 1771687d771SAlexander ZiaeeThe default is 95%. 1781687d771SAlexander ZiaeeChanging this value also changes 1791687d771SAlexander Ziaee.Va vfs.tmpfs.memory_reserved . 1801687d771SAlexander Ziaee.It Va vfs.tmpfs.memory_reserved 1811687d771SAlexander ZiaeeThe currently-reserved amount of memory plus swap space 1821687d771SAlexander Ziaeebased on the memory percentage. 1831687d771SAlexander ZiaeeThe minimum is compiled into the system, and defaults to 4 MB. 1841687d771SAlexander Ziaee.El 1851687d771SAlexander Ziaee.Sh EXAMPLES 1861687d771SAlexander ZiaeeMount a 1871687d771SAlexander Ziaee.Nm 1881687d771SAlexander Ziaeememory file system: 1891687d771SAlexander Ziaee.Pp 1901687d771SAlexander Ziaee.Dl "mount -t tmpfs tmpfs /tmp" 1911687d771SAlexander Ziaee.Pp 1921687d771SAlexander ZiaeeConfigure a 1931687d771SAlexander Ziaee.Nm 1941687d771SAlexander Ziaeemount via 1951687d771SAlexander Ziaee.Xr fstab 5 : 1961687d771SAlexander Ziaee.Bd -literal -offset indent 1971687d771SAlexander Ziaeetmpfs /tmp tmpfs rw 0 0 1981687d771SAlexander Ziaee.Ed 1991687d771SAlexander Ziaee.Sh SEE ALSO 2001687d771SAlexander Ziaee.Xr procstat 1 , 2011687d771SAlexander Ziaee.Xr mmap 2 , 2021687d771SAlexander Ziaee.Xr nmount 2 , 2031687d771SAlexander Ziaee.Xr unmount 2 , 2041687d771SAlexander Ziaee.Xr fstab 5 , 2051687d771SAlexander Ziaee.Xr mdmfs 8 , 2061687d771SAlexander Ziaee.Xr mount 8 , 2071687d771SAlexander Ziaee.Xr swapinfo 8 , 2081687d771SAlexander Ziaee.Xr swapon 8 2091687d771SAlexander Ziaee.Sh HISTORY 2101687d771SAlexander ZiaeeThe 2111687d771SAlexander Ziaee.Nm 2121687d771SAlexander Ziaeedriver first appeared in 2131687d771SAlexander Ziaee.Fx 7.0 . 2141687d771SAlexander Ziaee.Sh AUTHORS 2151687d771SAlexander Ziaee.An -nosplit 2161687d771SAlexander ZiaeeThe 2171687d771SAlexander Ziaee.Nm 2181687d771SAlexander Ziaeekernel implementation was written by 2191687d771SAlexander Ziaee.An Julio M. Merino Vidal Aq Mt jmmv@NetBSD.org 2201687d771SAlexander Ziaeeas a Google Summer of Code project. 2211687d771SAlexander Ziaee.Pp 2221687d771SAlexander Ziaee.An Rohit Jalan 2231687d771SAlexander Ziaeeand others ported it from 2241687d771SAlexander Ziaee.Nx 2251687d771SAlexander Ziaeeto 2261687d771SAlexander Ziaee.Fx . 2271687d771SAlexander Ziaee.Pp 2281687d771SAlexander ZiaeeThis manual page was written by 2291687d771SAlexander Ziaee.An Xin LI Aq Mt delphij@FreeBSD.org . 230