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