xref: /freebsd/share/man/man5/fstab.5 (revision e39e854e27f53a784c3982cbeb68f4ad1cfd9162)
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 June 7, 2011
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
74.Dq none .
75.Pp
76The third field,
77.Pq Fa fs_vfstype ,
78describes the type of the file system.
79The system can support various file system types.
80Only the root, /usr, and /tmp file systems need be statically
81compiled into the kernel;
82everything else will be automatically loaded at mount
83time.
84(Exception: the FFS cannot currently be demand-loaded.)
85Some people still prefer to statically
86compile other file systems as well.
87.Pp
88The fourth field,
89.Pq Fa fs_mntops ,
90describes the mount options associated with the file system.
91It is formatted as a comma separated list of options.
92It contains at least the type of mount (see
93.Fa fs_type
94below) plus any additional options appropriate to the file system type.
95See the options flag
96.Pq Fl o
97in the
98.Xr mount 8
99page and the file system specific page, such as
100.Xr mount_nfs 8 ,
101for additional options that may be specified.
102All options that can be given to the file system specific mount commands
103can be used in
104.Nm
105as well.
106They just need to be formatted a bit differently.
107The arguments of the
108.Fl o
109option can be used without the preceding
110.Fl o
111flag.
112Other options need both the file system specific flag and its argument,
113separated by an equal sign.
114For example, mounting an
115.Xr msdosfs 5
116filesystem, the options
117.Bd -literal -offset indent
118-o sync -o noatime -m 644 -M 755 -u foo -g bar
119.Ed
120.Pp
121should be written as
122.Bd -literal -offset indent
123sync,noatime,-m=644,-M=755,-u=foo,-g=bar
124.Ed
125.Pp
126in the option field of
127.Nm .
128.Pp
129If the options
130.Dq userquota
131and/or
132.Dq groupquota
133are specified,
134the file system is automatically processed by the
135.Xr quotacheck 8
136command, and user and/or group disk quotas are enabled with
137.Xr quotaon 8 .
138By default,
139file system quotas are maintained in files named
140.Pa quota.user
141and
142.Pa quota.group
143which are located at the root of the associated file system.
144These defaults may be overridden by putting an equal sign
145and an alternative absolute pathname following the quota option.
146Thus, if the user quota file for
147.Pa /tmp
148is stored in
149.Pa /var/quotas/tmp.user ,
150this location can be specified as:
151.Bd -literal -offset indent
152userquota=/var/quotas/tmp.user
153.Ed
154.Pp
155If the option
156.Dq failok
157is specified,
158the system will ignore any error which happens during the mount of that filesystem,
159which would otherwise cause the system to drop into single user mode.
160This option is implemented by the
161.Xr mount 8
162command and will not be passed to the kernel.
163.Pp
164If the option
165.Dq noauto
166is specified, the file system will not be automatically
167mounted at system startup.
168Note that, for network file systems
169of third party types
170(i.e., types supported by additional software
171not included in the base system)
172to be automatically mounted at system startup,
173the
174.Va extra_netfs_types
175.Xr rc.conf 5
176variable must be used to extend the
177.Xr rc 8
178startup script's list of network file system types.
179.Pp
180The type of the mount is extracted from the
181.Fa fs_mntops
182field and stored separately in the
183.Fa fs_type
184field (it is not deleted from the
185.Fa fs_mntops
186field).
187If
188.Fa fs_type
189is
190.Dq rw
191or
192.Dq ro
193then the file system whose name is given in the
194.Fa fs_file
195field is normally mounted read-write or read-only on the
196specified special file.
197If
198.Fa fs_type
199is
200.Dq sw
201then the special file is made available as a piece of swap
202space by the
203.Xr swapon 8
204command at the end of the system reboot procedure.
205The fields other than
206.Fa fs_spec
207and
208.Fa fs_type
209are unused.
210If
211.Fa fs_type
212is specified as
213.Dq xx
214the entry is ignored.
215This is useful to show disk partitions which are currently unused.
216.Pp
217The fifth field,
218.Pq Fa fs_freq ,
219is used for these file systems by the
220.Xr dump 8
221command to determine which file systems need to be dumped.
222If the fifth field is not present, a value of zero is returned and
223.Nm dump
224will assume that the file system does not need to be dumped.
225If the fifth field is greater than 0, then it specifies the number of days
226between dumps for this file system.
227.Pp
228The sixth field,
229.Pq Fa fs_passno ,
230is used by the
231.Xr fsck 8
232and
233.Xr quotacheck 8
234programs to determine the order in which file system and quota
235checks are done at reboot time.
236The
237.Fa fs_passno
238field can be any value between 0 and
239.Ql INT_MAX Ns -1 .
240.Pp
241The root file system should be specified with a
242.Fa fs_passno
243of 1, and other file systems should have a
244.Fa fs_passno
245of 2 or greater.
246A file system with a
247.Fa fs_passno
248value of 1 is always checked sequentially and be completed before
249another file system is processed, and it will be processed before
250all file systems with a larger
251.Fa fs_passno .
252.Pp
253For any given value of
254.Fa fs_passno ,
255file systems within a drive will be checked sequentially,
256but file systems on different drives will be checked at the
257same time to utilize parallelism available in the hardware.
258Once all file system checks are complete for the current
259.Fa fs_passno ,
260the same process will start over for the next
261.Fa fs_passno .
262.Pp
263If the sixth field is not present or is zero,
264a value of zero is returned and
265.Xr fsck 8
266and
267.Xr quotacheck 8
268will assume that the file system does not need to be checked.
269.Pp
270The
271.Fa fs_passno
272field can be used to implement finer control when
273the system utilities may determine that the file system resides
274on a different physical device, when it actually does not, as with a
275.Xr ccd 4
276device.
277All file systems with a lower
278.Fa fs_passno
279value will be completed before starting on file systems with a
280higher
281.Fa fs_passno
282value.
283E.g. all file systems with a
284.Fa fs_passno
285of 2 will be completed before any file systems with a
286.Fa fs_passno
287of 3 or greater are started.
288Gaps are allowed between the different
289.Fa fs_passno
290values.
291E.g. file systems listed in
292.Pa /etc/fstab
293may have
294.Fa fs_passno
295values such as 0, 1, 2, 15, 100, 200, 300, and may appear in any order
296within
297.Pa /etc/fstab .
298.Bd -literal
299#define	FSTAB_RW	"rw"	/* read/write device */
300#define	FSTAB_RQ	"rq"	/* read/write with quotas */
301#define	FSTAB_RO	"ro"	/* read-only device */
302#define	FSTAB_SW	"sw"	/* swap device */
303#define	FSTAB_XX	"xx"	/* ignore totally */
304
305struct fstab {
306	char	*fs_spec;	/* block special device name */
307	char	*fs_file;	/* file system path prefix */
308	char	*fs_vfstype;	/* File system type, ufs, nfs */
309	char	*fs_mntops;	/* Mount options ala -o */
310	char	*fs_type;	/* FSTAB_* from fs_mntops */
311	int	fs_freq;	/* dump frequency, in days */
312	int	fs_passno;	/* pass number on parallel fsck */
313};
314.Ed
315.Pp
316The proper way to read records from
317.Pa fstab
318is to use the routines
319.Xr getfsent 3 ,
320.Xr getfsspec 3 ,
321.Xr getfstype 3 ,
322and
323.Xr getfsfile 3 .
324.Sh FILES
325.Bl -tag -width /etc/fstab -compact
326.It Pa /etc/fstab
327The file
328.Nm
329resides in
330.Pa /etc .
331.El
332.Sh SEE ALSO
333.Xr getfsent 3 ,
334.Xr getvfsbyname 3 ,
335.Xr ccd 4 ,
336.Xr dump 8 ,
337.Xr fsck 8 ,
338.Xr mount 8 ,
339.Xr quotacheck 8 ,
340.Xr quotaon 8 ,
341.Xr swapon 8 ,
342.Xr umount 8
343.Sh HISTORY
344The
345.Nm
346file format appeared in
347.Bx 4.0 .
348