xref: /freebsd/share/man/man5/fstab.5 (revision 7aa383846770374466b1dcb2cefd71bde9acf463)
1.\" Copyright (c) 1980, 1989, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)fstab.5	8.1 (Berkeley) 6/5/93
33.\" $FreeBSD$
34.\"
35.Dd November 23, 2008
36.Dt FSTAB 5
37.Os
38.Sh NAME
39.Nm fstab
40.Nd static information about the file systems
41.Sh SYNOPSIS
42.In fstab.h
43.Sh DESCRIPTION
44The file
45.Nm
46contains descriptive information about the various file
47systems.
48.Nm
49is only read by programs, and not written;
50it is the duty of the system administrator to properly create
51and maintain this file.
52Each file system is described on a separate line;
53fields on each line are separated by tabs or spaces.
54The order of records in
55.Nm
56is important because
57.Xr fsck 8 ,
58.Xr mount 8 ,
59and
60.Xr umount 8
61sequentially iterate through
62.Nm
63doing their thing.
64.Pp
65The first field,
66.Pq Fa fs_spec ,
67describes the special device or
68remote file system to be mounted.
69.Pp
70The second field,
71.Pq Fa fs_file ,
72describes the mount point for the file system.
73For swap partitions, this field should be specified as ``none''.
74.Pp
75The third field,
76.Pq Fa fs_vfstype ,
77describes the type of the file system.
78The system can support various file system types.
79Only the root, /usr, and /tmp file systems need be statically
80compiled into the kernel;
81everything else will be automatically loaded at mount
82time.
83(Exception: the FFS cannot currently be demand-loaded.)
84Some people still prefer to statically
85compile other file systems as well.
86.Pp
87The fourth field,
88.Pq Fa fs_mntops ,
89describes the mount options associated with the file system.
90It is formatted as a comma separated list of options.
91It contains at least the type of mount (see
92.Fa fs_type
93below) plus any additional options appropriate to the file system type.
94See the options flag
95.Pq Fl o
96in the
97.Xr mount 8
98page and the file system specific page, such as
99.Xr mount_nfs 8 ,
100for additional options that may be specified.
101All options that can be given to the file system specific mount commands
102can be used in
103.Nm
104as well.
105They just need to be formatted a bit differently.
106The arguments of the
107.Fl o
108option can be used without the preceding
109.Fl o
110flag.
111Other options need both the file system specific flag and its argument,
112separated by an equal sign.
113For example, mounting an
114.Xr msdosfs 5
115filesystem, the options
116.Bd -literal -offset indent
117-o sync -o noatime -m 644 -M 755 -u foo -g bar
118.Ed
119.Pp
120should be written as
121.Bd -literal -offset indent
122sync,noatime,-m=644,-M=755,-u=foo,-g=bar
123.Ed
124.Pp
125in the option field of
126.Nm .
127.Pp
128If the options ``userquota'' and/or ``groupquota'' are specified,
129the file system is automatically processed by the
130.Xr quotacheck 8
131command, and user and/or group disk quotas are enabled with
132.Xr quotaon 8 .
133By default,
134file system quotas are maintained in files named
135.Pa quota.user
136and
137.Pa quota.group
138which are located at the root of the associated file system.
139These defaults may be overridden by putting an equal sign
140and an alternative absolute pathname following the quota option.
141Thus, if the user quota file for
142.Pa /tmp
143is stored in
144.Pa /var/quotas/tmp.user ,
145this location can be specified as:
146.Bd -literal -offset indent
147userquota=/var/quotas/tmp.user
148.Ed
149.Pp
150If the option ``noauto'' is specified, the file system will not be automatically
151mounted at system startup.
152Note that, for network file systems
153of third party types
154(i.e., types supported by additional software
155not included in the base system)
156to be automatically mounted at system startup,
157the
158.Va extra_netfs_types
159.Xr rc.conf 5
160variable must be used to extend the
161.Xr rc 8
162startup script's list of network file system types.
163.Pp
164The type of the mount is extracted from the
165.Fa fs_mntops
166field and stored separately in the
167.Fa fs_type
168field (it is not deleted from the
169.Fa fs_mntops
170field).
171If
172.Fa fs_type
173is ``rw'' or ``ro'' then the file system whose name is given in the
174.Fa fs_file
175field is normally mounted read-write or read-only on the
176specified special file.
177If
178.Fa fs_type
179is ``sw'' then the special file is made available as a piece of swap
180space by the
181.Xr swapon 8
182command at the end of the system reboot procedure.
183The fields other than
184.Fa fs_spec
185and
186.Fa fs_type
187are unused.
188If
189.Fa fs_type
190is specified as ``xx'' the entry is ignored.
191This is useful to show disk partitions which are currently unused.
192.Pp
193The fifth field,
194.Pq Fa fs_freq ,
195is used for these file systems by the
196.Xr dump 8
197command to determine which file systems need to be dumped.
198If the fifth field is not present, a value of zero is returned and
199.Nm dump
200will assume that the file system does not need to be dumped.
201If the fifth field is greater than 0, then it specifies the number of days
202between dumps for this file system.
203.Pp
204The sixth field,
205.Pq Fa fs_passno ,
206is used by the
207.Xr fsck 8
208and
209.Xr quotacheck 8
210programs to determine the order in which file system and quota
211checks are done at reboot time.
212The
213.Fa fs_passno
214field can be any value between 0 and
215.Ql INT_MAX Ns -1 .
216.Pp
217The root file system should be specified with a
218.Fa fs_passno
219of 1, and other file systems should have a
220.Fa fs_passno
221of 2 or greater.
222A file system with a
223.Fa fs_passno
224value of 1 is always checked sequentially and be completed before
225another file system is processed, and it will be processed before
226all file systems with a larger
227.Fa fs_passno .
228.Pp
229For any given value of
230.Fa fs_passno ,
231file systems within a drive will be checked sequentially,
232but file systems on different drives will be checked at the
233same time to utilize parallelism available in the hardware.
234Once all file system checks are complete for the current
235.Fa fs_passno ,
236the same process will start over for the next
237.Fa fs_passno .
238.Pp
239If the sixth field is not present or is zero,
240a value of zero is returned and
241.Xr fsck 8
242and
243.Xr quotacheck 8
244will assume that the file system does not need to be checked.
245.Pp
246The
247.Fa fs_passno
248field can be used to implement finer control when
249the system utilities may determine that the file system resides
250on a different physical device, when it actually does not, as with a
251.Xr ccd 4
252device.
253All file systems with a lower
254.Fa fs_passno
255value will be completed before starting on file systems with a
256higher
257.Fa fs_passno
258value.
259E.g. all file systems with a
260.Fa fs_passno
261of 2 will be completed before any file systems with a
262.Fa fs_passno
263of 3 or greater are started.
264Gaps are allowed between the different
265.Fa fs_passno
266values.
267E.g. file systems listed in
268.Pa /etc/fstab
269may have
270.Fa fs_passno
271values such as 0, 1, 2, 15, 100, 200, 300, and may appear in any order
272within
273.Pa /etc/fstab .
274.Bd -literal
275#define	FSTAB_RW	"rw"	/* read/write device */
276#define	FSTAB_RQ	"rq"	/* read/write with quotas */
277#define	FSTAB_RO	"ro"	/* read-only device */
278#define	FSTAB_SW	"sw"	/* swap device */
279#define	FSTAB_XX	"xx"	/* ignore totally */
280
281struct fstab {
282	char	*fs_spec;	/* block special device name */
283	char	*fs_file;	/* file system path prefix */
284	char	*fs_vfstype;	/* File system type, ufs, nfs */
285	char	*fs_mntops;	/* Mount options ala -o */
286	char	*fs_type;	/* FSTAB_* from fs_mntops */
287	int	fs_freq;	/* dump frequency, in days */
288	int	fs_passno;	/* pass number on parallel fsck */
289};
290.Ed
291.Pp
292The proper way to read records from
293.Pa fstab
294is to use the routines
295.Xr getfsent 3 ,
296.Xr getfsspec 3 ,
297.Xr getfstype 3 ,
298and
299.Xr getfsfile 3 .
300.Sh FILES
301.Bl -tag -width /etc/fstab -compact
302.It Pa /etc/fstab
303The file
304.Nm
305resides in
306.Pa /etc .
307.El
308.Sh SEE ALSO
309.Xr getfsent 3 ,
310.Xr getvfsbyname 3 ,
311.Xr ccd 4 ,
312.Xr dump 8 ,
313.Xr fsck 8 ,
314.Xr mount 8 ,
315.Xr quotacheck 8 ,
316.Xr quotaon 8 ,
317.Xr swapon 8 ,
318.Xr umount 8
319.Sh HISTORY
320The
321.Nm
322file format appeared in
323.Bx 4.0 .
324