xref: /openbsd/share/man/man5/fstab.5 (revision 4bdff4be)
1.\"	$OpenBSD: fstab.5,v 1.55 2023/07/07 13:21:28 job Exp $
2.\"	$NetBSD: fstab.5,v 1.5.2.1 1995/11/16 20:11:11 pk Exp $
3.\"
4.\" Copyright (c) 1980, 1989, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)fstab.5	8.1 (Berkeley) 6/5/93
32.\"
33.Dd $Mdocdate: July 7 2023 $
34.Dt FSTAB 5
35.Os
36.Sh NAME
37.Nm fstab
38.Nd static information about the filesystems
39.Sh SYNOPSIS
40.In fstab.h
41.Sh DESCRIPTION
42The
43.Nm
44file contains descriptive information about the various file systems.
45.Nm
46is only read by programs, and not written;
47it is the duty of the system administrator to properly create
48and maintain this file.
49Each filesystem is described on a separate line;
50fields on each line are separated by tabs or spaces.
51Lines beginning with the
52.Sq #
53character are comments and are ignored.
54The order of records in
55.Nm
56is important because
57.Xr fsck 8
58and
59.Xr mount 8
60sequentially iterate through
61.Nm
62doing their thing.
63.Pp
64A line has the following format:
65.Bd -literal -offset indent
66fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno
67.Ed
68.Pp
69The first field,
70.Fa fs_spec ,
71describes the block special device or remote filesystem to be mounted.
72A block special device may be specified by pathname
73or by
74.Xr disklabel 8
75UID (DUID).
76For filesystems of type MFS
77the special file name is typically that of the primary swap area;
78if the keyword
79.Dq swap
80is used instead of a special file name,
81default configuration parameters are used.
82If a program needs the character special file name,
83the program must create it by appending an
84.Sq r
85after the last
86.Sq /
87in the special file name.
88.Pp
89The second field,
90.Fa fs_file ,
91describes the mount point for the filesystem.
92For swap partitions, this field should be specified as
93.Dq none .
94.Pp
95The third field,
96.Fa fs_vfstype ,
97describes the type of the filesystem.
98The system currently supports the following types of filesystems:
99.Pp
100.Bl -tag -width indent -offset indent -compact
101.It cd9660
102An ISO 9660 CD-ROM filesystem.
103.It ext2fs
104A local Linux compatible ext2fs
105filesystem.
106.It ffs
107A local
108.Ux
109filesystem.
110.It mfs
111A local memory-based
112.Ux
113filesystem.
114.It msdos
115An
116.Tn MS-DOS
117FAT filesystem.
118.It nfs
119A Sun Microsystems compatible Network File System.
120.It ntfs
121An NTFS filesystem.
122.It swap
123A disk partition to be used for swapping.
124.It tmpfs
125A local memory-based
126.Ux
127filesystem.
128.It udf
129A UDF filesystem.
130.It vnd
131A VND image file.
132.El
133.Pp
134The fourth field,
135.Fa fs_mntops ,
136describes the mount options associated with the filesystem.
137It is formatted as a comma separated list of options.
138It contains at least the type of mount (see
139.Fa fs_type
140below) plus any additional options appropriate to the filesystem type.
141.Pp
142The option
143.Dq auto
144can be used in the
145.Dq noauto
146form to cause
147a file system not to be mounted automatically (with
148.Ic mount -A
149or
150.Ic mount -a ,
151or at system boot time).
152Similarly, the option
153.Dq net
154can be used to cause a file system to be considered only if the
155.Fl N
156flag is passed to
157.Xr mount 8
158or
159.Xr fsck 8 .
160.Pp
161If the options
162.Dq userquota
163and/or
164.Dq groupquota
165are specified, the filesystem is automatically processed by the
166.Xr quotacheck 8
167command, and user and/or group disk quotas are enabled with
168.Xr quotaon 8 .
169By default, filesystem quotas are maintained in files named
170.Pa quota.user
171and
172.Pa quota.group
173which are located at the root of the associated filesystem.
174These defaults may be overridden by putting an equal sign
175and an alternative absolute pathname following the quota option.
176Thus, if the user quota file for
177.Pa /tmp
178is stored in
179.Pa /var/quotas/tmp.user ,
180this location can be specified as:
181.Bd -literal -offset indent
182userquota=/var/quotas/tmp.user
183.Ed
184.Pp
185The type of the mount is extracted from the first parameter of the
186.Fa fs_mntops
187field and stored separately in the
188.Fa fs_type
189field (it is not deleted from the
190.Fa fs_mntops
191field).
192If
193.Fa fs_type
194is
195.Dq rw ,
196.Dq rq ,
197or
198.Dq ro
199then the filesystem whose name is given in the
200.Fa fs_file
201field is normally mounted read-write or read-only on the
202specified special file.
203If
204.Fa fs_type
205is
206.Dq sw
207then the special file is made available as a piece of swap space by the
208.Xr swapon 8
209command at the end of the system reboot procedure.
210The fields other than
211.Fa fs_spec
212and
213.Fa fs_type
214are unused.
215If
216.Fa fs_type
217is specified as
218.Dq xx ,
219the entry is ignored.
220This is useful to show disk partitions which are currently unused.
221.Pp
222The fifth field,
223.Fa fs_freq ,
224is used by the
225.Fl W
226and
227.Fl w
228options of
229.Xr dump 8
230to recommend which filesystems should be backed up.
231The value specifies the number of days
232after which a dump is regarded as being old;
233if it is not present, a value of zero is returned and
234.Xr dump 8
235will assume that the filesystem does not need to be dumped.
236.Pp
237The sixth field,
238.Fa fs_passno ,
239is used by the
240.Xr fsck 8
241program to determine the order in which filesystem checks are done
242at reboot time.
243The root filesystem should be specified with a
244.Fa fs_passno
245of 1, and other filesystems should have a
246.Fa fs_passno
247of 2.
248Filesystems within a drive will be checked sequentially,
249but filesystems on different drives will be checked at the
250same time to utilize parallelism available in the hardware.
251If the sixth field is not present or is zero,
252a value of zero is returned and
253.Xr fsck 8
254will assume that the filesystem does not need to be checked.
255.Bd -literal
256#define	FSTAB_RW	"rw"	/* read/write device */
257#define	FSTAB_RQ	"rq"	/* read/write with quotas */
258#define	FSTAB_RO	"ro"	/* read-only device */
259#define	FSTAB_SW	"sw"	/* swap device */
260#define	FSTAB_XX	"xx"	/* ignore totally */
261
262struct fstab {
263	char	*fs_spec;	/* block special device name */
264	char	*fs_file;	/* filesystem path prefix */
265	char	*fs_vfstype;	/* type of filesystem */
266	char	*fs_mntops;	/* comma separated mount options */
267	char	*fs_type;	/* rw, rq, ro, sw, or xx */
268	int	fs_freq;	/* dump frequency, in days */
269	int	fs_passno;	/* pass number on parallel fsck */
270};
271.Ed
272.Pp
273The proper way to read records from
274.Pa fstab
275is to use the routines
276.Xr getfsent 3 ,
277.Xr getfsspec 3 ,
278and
279.Xr getfsfile 3 .
280.Sh FILES
281.Bl -tag -width /etc/fstab -compact
282.It Pa /etc/fstab
283.El
284.Sh EXAMPLES
285Here is a sample
286.Pa /etc/fstab
287file:
288.Bd -literal -offset indent
289/dev/sd0b none swap sw
290/dev/sd1b none swap sw
291/dev/sd0a / ffs rw 1 1
292/dev/sd0e /var ffs rw,nodev,nosuid 1 2
293#/dev/sd0f /tmp ffs rw,nodev,nosuid 1 2
294swap /tmp mfs rw,nodev,nosuid,-s=153600 0 0
295/dev/sd0g /usr ffs rw,nodev 1 2
296/dev/sd0h /usr/local ffs rw,nodev 1 2
297/dev/sd0i /home ffs rw,nodev,nosuid 1 2
298/dev/sd0j /usr/src ffs rw,nodev,nosuid 1 2
299/dev/cd0a /cdrom cd9660 ro,noauto 0 0
3005b27c2761a9b0b06.i /mnt/key msdos rw,noauto 0 0
301server:/export/ports /usr/ports nfs rw,nodev,nosuid,soft,intr 0 0
302.Ed
303.Sh SEE ALSO
304.Xr quota 1 ,
305.Xr getfsent 3 ,
306.Xr fsck 8 ,
307.Xr mount 8 ,
308.Xr quotacheck 8 ,
309.Xr quotaon 8
310.Sh HISTORY
311The
312.Nm
313file format appeared in
314.Bx 4.0 .
315