1.\" $NetBSD: mount_tmpfs.8,v 1.19 2022/04/12 20:51:42 andvar Exp $ 2.\" 3.\" Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Julio M. Merino Vidal, developed as part of Google's Summer of Code 8.\" 2005 program. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29.\" POSSIBILITY OF SUCH DAMAGE. 30.\" 31.Dd June 7, 2014 32.Dt MOUNT_TMPFS 8 33.Os 34.Sh NAME 35.Nm mount_tmpfs 36.Nd mount an efficient memory file system 37.Sh SYNOPSIS 38.Nm 39.Op Fl g Ar group 40.Op Fl m Ar mode 41.Op Fl n Ar nodes 42.Op Fl o Ar options 43.Op Fl s Ar size 44.Op Fl u Ar user 45.Ar tmpfs 46.Ar mount_point 47.Sh DESCRIPTION 48The 49.Nm 50command attaches an instance of the efficient memory file system to the 51global file system namespace. 52The 53.Ar tmpfs 54parameter only exists for compatibility with the other mount commands and 55is ignored. 56The directory specified by 57.Ar mount_point 58is converted to an absolute path before use and its attributes (owner, 59group and mode) are inherited unless explicitly overridden by the options 60described below. 61.Pp 62The following options are supported: 63.Bl -tag -width XoXoptions 64.It Fl g Ar group 65Specifies the group name or GID of the root inode of the file system. 66Defaults to the mount point's GID. 67.It Fl m Ar mode 68Specifies the mode (in octal notation) of the root inode of the file system. 69Defaults to the mount point's mode. 70.It Fl n Ar nodes 71Specifies the maximum number of nodes available to the file system. 72If not specified, the file system chooses a reasonable maximum given its 73size at mount time, which can be limited with 74.Fl s . 75.It Fl o Ar options 76Options are specified with a 77.Fl o 78flag followed by a comma-separated string of options. 79See the 80.Xr mount 8 81man page for possible options and their meanings. 82.It Fl s Ar size 83Specifies the total file system size in bytes. 84If zero is given (the default), the available amount of memory (including 85main memory and swap space) will be used. 86Note that some memory is always reserved for the system and cannot 87be assigned to the file system. 88The exact amount depends on the available memory and details of the 89kernel memory usage, it might even change slightly during runtime. 90.Ar Size 91can alternatively be specified as a percentage of the available 92system ram by using the notation 93.Ar ram%n 94where 95.Ar n 96is a number between 1 and 100. 97Similarly it can be specified as a fraction of the available system 98ram by using 99.Ar ram/n 100where 101.Ar n 102is the divisor. 103(Using 104.Ar ram%25 105and 106.Ar ram/4 107will result in the same limit.) 108.It Fl u Ar user 109Specifies the user name or UID of the root inode of the file system. 110Defaults to the mount point's UID. 111.El 112.Pp 113Every option that accepts a numerical value as its argument can take a 114trailing 115.Sq b 116to indicate bytes (the default), a 117.Sq k 118to indicate kilobytes, a 119.Sq M 120to indicate megabytes or a 121.Sq G 122to indicate gigabytes. 123Note that both lowercase and uppercase forms of these letters are allowed. 124.Sh EXAMPLES 125The following command mounts a tmpfs instance over the 126.Pa /tmp 127directory, inheriting its owner, group and mode settings: 128.Pp 129.Dl # mount -t tmpfs tmpfs /tmp 130.Pp 131The following command mounts a tmpfs instance over the 132.Pa /mnt 133directory, setting a 20 megabytes limit in space, owned by the 134.Sq joe 135user and belonging to the 136.Sq users 137group, with a restricted 0700 mode: 138.Pp 139.Dl # mount -t tmpfs -o -s20M -o -ujoe -o -gusers -o -m0700 tmpfs /mnt 140.Pp 141See 142.Pa /usr/share/examples/fstab/fstab.ramdisk 143for some examples on how to add tmpfs entries to 144.Pa /etc/fstab . 145.Sh SEE ALSO 146.Xr fstab 5 , 147.Xr mount 8 148.Sh HISTORY 149The 150.Nm 151utility first appeared in 152.Nx 4.0 . 153.Sh BUGS 154File system meta-data is not pageable. 155If there is not enough main memory to hold this information, the system may 156become unstable or very unresponsive because it will not be able to allocate 157required memory. 158A malicious user could trigger this condition if he could create lots of 159files inside a size-unbounded tmpfs file system. 160Limiting the number of nodes per file system 161.Pq Fl n 162will prevent this; the default value for this setting is also often adjusted 163to an adequate value to resolve this. 164