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