xref: /netbsd-src/share/man/man5/fstab.5 (revision f3cfa6f6ce31685c6c4a758bc430e69eb99f50a4)
1.\"	$NetBSD: fstab.5,v 1.44 2018/10/06 13:09:53 jmcneill Exp $
2.\"
3.\" Copyright (c) 1980, 1989, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"     @(#)fstab.5	8.1 (Berkeley) 6/5/93
31.\"
32.Dd October 6, 2018
33.Dt FSTAB 5
34.Os
35.Sh NAME
36.Nm fstab
37.Nd file system table for devices, types, and mount points
38.Sh SYNOPSIS
39.In fstab.h
40.Sh DESCRIPTION
41The file
42.Nm
43contains descriptive information about the various file systems.
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.
50Lines beginning
51with
52.Dq #
53are comments.
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 respective tasks.
64.Pp
65Each configuration line/record in
66.Nm
67has the format:
68.Dl fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno
69.Pp
70The first field,
71.Pq Fa fs_spec ,
72describes the block special device or
73remote file system to be mounted.
74For file systems of type
75.Em ffs ,
76the special file name is the block special file name,
77and not the character special file name.
78If a program needs the character special file name,
79the program must create it by appending a
80.Dq r
81after the
82last
83.Dq /
84in the special file name.
85.Pp
86If the first field is of the form
87.Dq NAME=<value>
88then all the
89.Xr dk 4
90wedge partitions are searched for one that has a wedge name equal to
91.Ar <value>
92and the device corresponding to it is selected.
93.Pp
94If the first field starts with the prefix
95.Dq ROOT.
96the prefix is replaced with
97.Dq /dev/[root_device] ,
98where
99.Bq root_device
100is the value of the
101.Dq kern.root_device
102sysctl.
103.Pp
104The second field,
105.Pq Fa fs_file ,
106describes the mount point for the file system.
107For swap and dump partitions, this field should be specified as
108.Dq none .
109.Pp
110The third field,
111.Pq Fa fs_vfstype ,
112describes the type of the file system.
113The system currently supports these file systems:
114.Bl -tag -width filecore -offset indent
115.It Em adosfs
116an
117.Tn AmigaDOS
118file system.
119.It Em cd9660
120an
121.Tn ISO
1229660 CD-ROM file system.
123.It Em ext2fs
124an implementation of the Linux
125.Dq Second Extended File-system .
126.It Em fdesc
127an implementation of
128.Pa /dev/fd .
129.It Em ffs
130a local
131.Ux
132file system.
133.It Em filecore
134a file system for
135.Tn RISC\ OS .
136.It Em kernfs
137various and sundry kernel statistics.
138.It Em lfs
139a log-structured file-system.
140.It Em mfs
141a local memory-based
142.Ux
143file system.
144.It Em msdos
145an
146.Tn MS-DOS
147.Dq FAT file system .
148.It Em nfs
149a Sun Microsystems compatible
150.Dq Network File System .
151.It Em ntfs
152a file system used by
153.Tn Windows NT .
154Still experimental.
155.It Em null
156a loop-back file system, allowing parts of the system to be viewed
157elsewhere.
158.It Em overlay
159a demonstration of layered file systems.
160.It Em portal
161a general file system interface, currently supports TCP and FS mounts.
162.It Em procfs
163a local file system of process information.
164.It Em ptyfs
165a pseudo-terminal device file system.
166.It Em smbfs
167a shared resource from an SMB/CIFS file server.
168.It Em swap
169a disk partition to be used for swapping and paging.
170.It Em tmpfs
171an efficient memory file system.
172.It Em umap
173a user and group re-mapping file system.
174.It Em union
175a translucent file system.
176.El
177.Pp
178The fourth field,
179.Pq Fa fs_mntops ,
180describes the mount options associated with the file system.
181It is formatted as a comma separated list of options.
182It contains at least the type of mount (see
183.Fa fs_type
184below) plus any additional options
185appropriate to the file system type.
186.Pp
187The option
188.Dq auto
189can be used in the
190.Dq noauto
191form to cause
192a file system not to be mounted automatically (with
193.Dq mount -a
194,
195or system boot time).
196.Pp
197If the options
198.Dq userquota
199and/or
200.Dq groupquota
201are specified,
202the file system is automatically processed by the
203.Xr quotacheck 8
204command, and legacy user and/or group disk quotas are enabled with
205.Xr quotaon 8 .
206By default,
207file system quotas are maintained in files named
208.Pa quota.user
209and
210.Pa quota.group
211which are located at the root of the associated file system.
212These defaults may be overridden by putting an equal sign
213and an alternative absolute pathname following the quota option.
214Thus, if the user quota file for
215.Pa /tmp
216is stored in
217.Pa /var/quotas/tmp.user ,
218this location can be specified as:
219.Bd -literal -offset indent
220userquota=/var/quotas/tmp.user
221.Ed
222.Pp
223It is recommended to turn on the new, in-file system quota with
224.Xr tunefs 8
225or at
226.Xr newfs 8
227time, and to not use the
228.Dq userquota
229or
230.Dq groupquota
231options.
232Migration of limits to the new in-file system quota can be handled
233via
234.Xr quotadump 8
235and
236.Xr quotarestore 8 .
237.Pp
238The option
239.Dq rump
240is used to mount the file system using a
241.Xr rump 3
242userspace server instead of the kernel server.
243.Pp
244The type of the mount is extracted from the
245.Fa fs_mntops
246field and stored separately in the
247.Fa fs_type
248field (it is not deleted from the
249.Fa fs_mntops
250field).
251If
252.Fa fs_type
253is
254.Dq rw
255or
256.Dq ro
257then the file system whose name is given in the
258.Fa fs_file
259field is normally mounted read-write or read-only on the
260specified special file.
261If
262.Fa fs_type
263is
264.Dq sw
265or
266.Dq dp
267then the special file is made available as a piece of swap
268or dump
269space by the
270.Xr swapctl 8
271command towards the beginning of the system reboot procedure.
272See
273.Xr swapctl 8
274for more information on configuring swap and dump devices.
275The fields other than
276.Fa fs_spec
277and
278.Fa fs_type
279are unused.
280If
281.Fa fs_type
282is specified as
283.Dq xx
284the entry is ignored.
285This is useful to show disk partitions which are currently unused.
286.Pp
287The fifth field,
288.Pq Fa fs_freq ,
289is used for these file systems by the
290.Xr dump 8
291command to determine which file systems need to be dumped.
292If the fifth field is not present, a value of zero is returned and
293.Xr dump 8
294will assume that the file system does not need to be dumped.
295.Pp
296The sixth field,
297.Pq Fa fs_passno ,
298is used by the
299.Xr fsck 8
300program to determine the order in which file system checks are done
301at reboot time.
302The root file system should be specified with a
303.Fa fs_passno
304of 1, and other file systems should have a
305.Fa fs_passno
306of 2.
307Filesystems within a drive will be checked sequentially,
308but file systems on different drives will be checked at the
309same time to use parallelism available in the hardware.
310If the sixth field is not present or zero,
311a value of zero is returned and
312.Xr fsck 8
313will assume that the file system does not need to be checked.
314.Bd -literal
315#define	FSTAB_RW	"rw"	/* read-write device */
316#define	FSTAB_RQ	"rq"	/* read/write with quotas */
317#define	FSTAB_RO	"ro"	/* read-only device */
318#define	FSTAB_SW	"sw"	/* swap device */
319#define	FSTAB_DP	"dp"	/* dump device */
320#define	FSTAB_XX	"xx"	/* ignore totally */
321
322struct fstab {
323	char	*fs_spec;	/* block special device name */
324	char	*fs_file;	/* file system path prefix */
325	char	*fs_vfstype;	/* type of file system */
326	char	*fs_mntops;	/* comma separated mount options */
327	char	*fs_type;	/* rw, ro, sw, or xx */
328	int	fs_freq;	/* dump frequency, in days */
329	int	fs_passno;	/* pass number on parallel fsck */
330};
331.Ed
332.Pp
333The proper way to read records from
334.Pa fstab
335is to use the routines
336.Xr getfsent 3 ,
337.Xr getfsspec 3 ,
338and
339.Xr getfsfile 3 .
340.Sh FILES
341.Bl -tag -width /etc/fstab
342.It Pa /etc/fstab
343The location of
344.Nm
345configuration file.
346.It Pa /usr/share/examples/fstab/
347Some useful configuration examples.
348.El
349.Sh EXAMPLES
350To use
351.Dq NAME
352on a non-GPT disk, use:
353.Bd -literal
354NAME=sb2k5Root/a        /       ffs     rw,log           1 1
355NAME=sb2k5Root/b        none    swap    sw,dp            0 0
356.Ed
357.Pp
358For a
359.Xr gpt 8
360disk, use:
361.Bd -literal
362NAME=firstpartition     /       ffs     rw,log           1 1
363NAME=secondpartition    none    swap    sw,dp            0 0
364.Ed
365.Sh SEE ALSO
366.Xr getfsent 3 ,
367.Xr getfsspecname 3 ,
368.Xr mount 8 ,
369.Xr swapctl 8
370.Sh HISTORY
371The
372.Nm
373file format appeared in
374.Bx 4.0 .
375