xref: /freebsd/share/man/man5/fstab.5 (revision 54e9e4e72d711fb41f88f793f6c64df1126112f9)
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. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"     @(#)fstab.5	8.1 (Berkeley) 6/5/93
29.\" $FreeBSD$
30.\"
31.Dd April 14, 2014
32.Dt FSTAB 5
33.Os
34.Sh NAME
35.Nm fstab
36.Nd static information about the file systems
37.Sh SYNOPSIS
38.In fstab.h
39.Sh DESCRIPTION
40The file
41.Nm
42contains descriptive information about the various file
43systems.
44.Nm
45is only read by programs, and not written;
46it is the duty of the system administrator to properly create
47and maintain this file.
48Each file system is described on a separate line;
49fields on each line are separated by tabs or spaces.
50The order of records in
51.Nm
52is important because
53.Xr fsck 8 ,
54.Xr mount 8 ,
55and
56.Xr umount 8
57sequentially iterate through
58.Nm
59doing their thing.
60.Pp
61The first field,
62.Pq Fa fs_spec ,
63describes the special device or
64remote file system to be mounted.
65The contents are decoded by the
66.Xr strunvis 3
67function.
68This allows using spaces or tabs in the device name which would be
69interpreted as field separators otherwise.
70.Pp
71The second field,
72.Pq Fa fs_file ,
73describes the mount point for the file system.
74For swap partitions, this field should be specified as
75.Dq none .
76The contents are decoded by the
77.Xr strunvis 3
78function, as above.
79.Pp
80The third field,
81.Pq Fa fs_vfstype ,
82describes the type of the file system.
83The system can support various file system types.
84Only the root, /usr, and /tmp file systems need be statically
85compiled into the kernel;
86everything else will be automatically loaded at mount
87time.
88(Exception: the FFS cannot currently be demand-loaded.)
89Some people still prefer to statically
90compile other file systems as well.
91.Pp
92The fourth field,
93.Pq Fa fs_mntops ,
94describes the mount options associated with the file system.
95It is formatted as a comma separated list of options.
96It contains at least the type of mount (see
97.Fa fs_type
98below) plus any additional options appropriate to the file system type.
99See the options flag
100.Pq Fl o
101in the
102.Xr mount 8
103page and the file system specific page, such as
104.Xr mount_nfs 8 ,
105for additional options that may be specified.
106All options that can be given to the file system specific mount commands
107can be used in
108.Nm
109as well.
110They just need to be formatted a bit differently.
111The arguments of the
112.Fl o
113option can be used without the preceding
114.Fl o
115flag.
116Other options need both the file system specific flag and its argument,
117separated by an equal sign.
118For example, mounting an
119.Xr msdosfs 5
120filesystem, the options
121.Bd -literal -offset indent
122-o sync -o noatime -m 644 -M 755 -u foo -g bar
123.Ed
124.Pp
125should be written as
126.Bd -literal -offset indent
127sync,noatime,-m=644,-M=755,-u=foo,-g=bar
128.Ed
129.Pp
130in the option field of
131.Nm .
132.Pp
133If the options
134.Dq userquota
135and/or
136.Dq groupquota
137are specified,
138the file system is automatically processed by the
139.Xr quotacheck 8
140command, and user and/or group disk quotas are enabled with
141.Xr quotaon 8 .
142By default,
143file system quotas are maintained in files named
144.Pa quota.user
145and
146.Pa quota.group
147which are located at the root of the associated file system.
148These defaults may be overridden by putting an equal sign
149and an alternative absolute pathname following the quota option.
150Thus, if the user quota file for
151.Pa /tmp
152is stored in
153.Pa /var/quotas/tmp.user ,
154this location can be specified as:
155.Bd -literal -offset indent
156userquota=/var/quotas/tmp.user
157.Ed
158.Pp
159If the option
160.Dq failok
161is specified,
162the system will ignore any error which happens during the mount of that filesystem,
163which would otherwise cause the system to drop into single user mode.
164This option is implemented by the
165.Xr mount 8
166command and will not be passed to the kernel.
167.Pp
168If the option
169.Dq noauto
170is specified, the file system will not be automatically
171mounted at system startup.
172Note that, for network file systems
173of third party types
174(i.e., types supported by additional software
175not included in the base system)
176to be automatically mounted at system startup,
177the
178.Va extra_netfs_types
179.Xr rc.conf 5
180variable must be used to extend the
181.Xr rc 8
182startup script's list of network file system types.
183.Pp
184If the option
185.Dq late
186is specified, the file system will be automatically mounted
187at a stage of system startup after remote mount points are mounted.
188For more detail about this option,
189see the
190.Xr mount 8
191manual page.
192.Pp
193If the option
194.Dq update
195is specified, it indicates that the status of an already mounted file
196system should be changed accordingly.
197This allows, for example, file systems mounted read-only to be upgraded
198read-write and vice-versa.
199By default, an entry corresponding to a file systems that is already
200mounted is going to be skipped over when processing
201.Nm ,
202unless it's a root file system, in which case logic similar to
203.Dq update
204is applied automatically.
205.Pp
206The
207.Dq update
208option is typically used in conjuction with two
209.Nm
210files.
211The first
212.Nm
213file is used to set up the initial set of file systems.
214The second
215.Nm
216file is then run to update the initial set of file systems and
217to add additional file systems.
218.Pp
219The type of the mount is extracted from the
220.Fa fs_mntops
221field and stored separately in the
222.Fa fs_type
223field (it is not deleted from the
224.Fa fs_mntops
225field).
226If
227.Fa fs_type
228is
229.Dq rw
230or
231.Dq ro
232then the file system whose name is given in the
233.Fa fs_file
234field is normally mounted read-write or read-only on the
235specified special file.
236.Pp
237If
238.Fa fs_type
239is
240.Dq sw
241then the special file is made available as a piece of swap
242space by the
243.Xr swapon 8
244command at the end of the system reboot procedure.
245For swap devices, the keyword
246.Dq trimonce
247triggers the delivery of a
248.Dv BIO_DELETE
249command to the device to mark
250all blocks as unused.
251For vnode-backed swap spaces,
252.Dq file
253is supported in the
254.Fa fs_mntops
255field.
256When
257.Fa fs_spec
258is an
259.Xr md 4
260device file
261.Pq Do md Dc or Do md[0-9]* Dc
262and
263.Dq file
264is specified in
265.Fa fs_mntopts ,
266an
267.Xr md 4
268device is created with the specified file used as backing store,
269and then the new device is used as swap space.
270Swap entries on
271.Pa .eli
272devices will cause automatic creation of encrypted devices.
273The
274.Dq ealgo ,
275.Dq aalgo ,
276.Dq keylen ,
277.Dq notrim ,
278and
279.Dq sectorsize
280options may be passed to control those
281.Xr geli 8
282parameters.
283The fields other than
284.Fa fs_spec
285and
286.Fa fs_type
287are unused.
288If
289.Fa fs_type
290is specified as
291.Dq xx
292the entry is ignored.
293This is useful to show disk partitions which are currently unused.
294.Pp
295The fifth field,
296.Pq Fa fs_freq ,
297is used for these file systems by the
298.Xr dump 8
299command to determine which file systems need to be dumped.
300If the fifth field is not present, a value of zero is returned and
301.Nm dump
302will assume that the file system does not need to be dumped.
303If the fifth field is greater than 0, then it specifies the number of days
304between dumps for this file system.
305.Pp
306The sixth field,
307.Pq Fa fs_passno ,
308is used by the
309.Xr fsck 8
310and
311.Xr quotacheck 8
312programs to determine the order in which file system and quota
313checks are done at reboot time.
314The
315.Fa fs_passno
316field can be any value between 0 and
317.Ql INT_MAX Ns -1 .
318.Pp
319The root file system should be specified with a
320.Fa fs_passno
321of 1, and other file systems should have a
322.Fa fs_passno
323of 2 or greater.
324A file system with a
325.Fa fs_passno
326value of 1 is always checked sequentially and be completed before
327another file system is processed, and it will be processed before
328all file systems with a larger
329.Fa fs_passno .
330.Pp
331For any given value of
332.Fa fs_passno ,
333file systems within a drive will be checked sequentially,
334but file systems on different drives will be checked at the
335same time to utilize parallelism available in the hardware.
336Once all file system checks are complete for the current
337.Fa fs_passno ,
338the same process will start over for the next
339.Fa fs_passno .
340.Pp
341If the sixth field is not present or is zero,
342a value of zero is returned and
343.Xr fsck 8
344and
345.Xr quotacheck 8
346will assume that the file system does not need to be checked.
347.Pp
348The
349.Fa fs_passno
350field can be used to implement finer control when
351the system utilities may determine that the file system resides
352on a different physical device, when it actually does not, as with a
353.Xr ccd 4
354device.
355All file systems with a lower
356.Fa fs_passno
357value will be completed before starting on file systems with a
358higher
359.Fa fs_passno
360value.
361E.g. all file systems with a
362.Fa fs_passno
363of 2 will be completed before any file systems with a
364.Fa fs_passno
365of 3 or greater are started.
366Gaps are allowed between the different
367.Fa fs_passno
368values.
369E.g. file systems listed in
370.Pa /etc/fstab
371may have
372.Fa fs_passno
373values such as 0, 1, 2, 15, 100, 200, 300, and may appear in any order
374within
375.Pa /etc/fstab .
376.Bd -literal
377#define	FSTAB_RW	"rw"	/* read/write device */
378#define	FSTAB_RQ	"rq"	/* read/write with quotas */
379#define	FSTAB_RO	"ro"	/* read-only device */
380#define	FSTAB_SW	"sw"	/* swap device */
381#define	FSTAB_XX	"xx"	/* ignore totally */
382
383struct fstab {
384	char	*fs_spec;	/* block special device name */
385	char	*fs_file;	/* file system path prefix */
386	char	*fs_vfstype;	/* File system type, ufs, nfs */
387	char	*fs_mntops;	/* Mount options ala -o */
388	char	*fs_type;	/* FSTAB_* from fs_mntops */
389	int	fs_freq;	/* dump frequency, in days */
390	int	fs_passno;	/* pass number on parallel fsck */
391};
392.Ed
393.Pp
394The proper way to read records from
395.Pa fstab
396is to use the routines
397.Xr getfsent 3 ,
398.Xr getfsspec 3 ,
399.Xr getfstype 3 ,
400and
401.Xr getfsfile 3 .
402.Sh FILES
403.Bl -tag -width /etc/fstab -compact
404.It Pa /etc/fstab
405The file
406.Nm
407resides in
408.Pa /etc .
409.El
410.Sh EXAMPLES
411.Bd -literal
412# Device	Mountpoint	FStype	Options		Dump	Pass#
413#
414# UFS file system.
415/dev/da0p2	/		ufs	rw		1	1
416#
417# Swap space on a block device.
418/dev/da0p1	none		swap	sw		0	0
419#
420# Swap space using a block device with GBDE/GELI encyption.
421# aalgo, ealgo, keylen, sectorsize options are available
422# for .eli devices.
423/dev/da1p1.bde	none		swap	sw		0	0
424/dev/da1p2.eli	none		swap	sw		0	0
425#
426# tmpfs.
427tmpfs		/tmp		tmpfs	rw,size=1g,mode=1777	0 0
428#
429# UFS file system on a swap-backed md(4).  /dev/md10 is
430# automatically created.  If it is "md", a unit number
431# will be automatically selected.
432md10		/scratch	mfs	rw,-s1g		0	0
433#
434# Swap space on a vnode-backed md(4).
435md11		none		swap	sw,file=/swapfile	0 0
436#
437# CDROM.  "noauto" option is typically used because the
438# media is removable.
439/dev/cd0	/cdrom		cd9660	ro,noauto	0	0
440#
441# NFS-exported file system.  "serv" is an NFS server name
442# or IP address.
443serv:/export	/nfs		nfs	rw,noinet6	0	0
444.Ed
445.Sh SEE ALSO
446.Xr getfsent 3 ,
447.Xr getvfsbyname 3 ,
448.Xr strunvis 3 ,
449.Xr ccd 4 ,
450.Xr dump 8 ,
451.Xr fsck 8 ,
452.Xr geli 8 ,
453.Xr mount 8 ,
454.Xr quotacheck 8 ,
455.Xr quotaon 8 ,
456.Xr swapon 8 ,
457.Xr umount 8
458.Sh HISTORY
459The
460.Nm
461file format appeared in
462.Bx 4.0 .
463