1.\" $NetBSD: fstab.5,v 1.47 2020/04/19 19:20:32 gutteridge 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 April 19, 2020 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 last 82.Dq / 83in the special file name. 84(Note that for some file systems, e.g., 85.Em kernfs , 86.Em procfs , 87and 88.Em tmpfs , 89this field has no applicable use, and any string may be supplied as a 90placeholder. 91It is present simply for consistency of argument number and order.) 92.Pp 93If the first field is of the form 94.Dq NAME=<value> 95then all the 96.Xr dk 4 97wedge partitions are searched for one that has a wedge name equal to 98.Ar <value> 99and the device corresponding to it is selected. 100.Pp 101If the first field starts with the prefix 102.Dq ROOT. 103the prefix is replaced with 104.Dq /dev/[root_device] , 105where 106.Bq root_device 107is the value of the 108.Dq kern.root_device 109sysctl. 110.Pp 111The second field, 112.Pq Fa fs_file , 113describes the mount point for the file system. 114For swap and dump partitions, this field should be specified as 115.Dq none . 116.Pp 117The third field, 118.Pq Fa fs_vfstype , 119describes the type of the file system. 120The system currently supports these file systems: 121.Bl -tag -width filecore -offset indent 122.It Em adosfs 123an 124.Tn AmigaDOS 125file system. 126.It Em cd9660 127an 128.Tn ISO 1299660 CD-ROM file system. 130.It Em ext2fs 131an implementation of the Linux 132.Dq Second Extended File-system . 133.It Em fdesc 134an implementation of 135.Pa /dev/fd . 136.It Em ffs 137a local 138.Ux 139file system. 140.It Em filecore 141a file system for 142.Tn RISC\ OS . 143.It Em kernfs 144various and sundry kernel statistics. 145.It Em lfs 146a log-structured file-system. 147.It Em mfs 148a local memory-based 149.Ux 150file system. 151.It Em msdos 152an 153.Tn MS-DOS 154.Dq FAT file system . 155.It Em nfs 156a Sun Microsystems compatible 157.Dq Network File System . 158.It Em ntfs 159a file system used by 160.Tn Windows NT . 161Still experimental. 162.It Em null 163a loop-back file system, allowing parts of the system to be viewed 164elsewhere. 165.It Em overlay 166a demonstration of layered file systems. 167.It Em portal 168a general file system interface, currently supports TCP and FS mounts. 169.It Em procfs 170a local file system of process information. 171.It Em ptyfs 172a pseudo-terminal device file system. 173.It Em swap 174a disk partition to be used for swapping and paging. 175.It Em tmpfs 176an efficient memory file system. 177.It Em umap 178a user and group re-mapping file system. 179.It Em union 180a translucent file system. 181.It Em zfs 182a ZFS file system. 183.El 184.Pp 185The fourth field, 186.Pq Fa fs_mntops , 187describes the mount options associated with the file system. 188It is formatted as a comma separated list of options. 189It contains at least the type of mount (see 190.Fa fs_type 191below) plus any additional options 192appropriate to the file system type. 193.Pp 194The option 195.Dq auto 196can be used in the 197.Dq noauto 198form to cause 199a file system not to be mounted automatically (with 200.Dq mount -a 201, 202or system boot time). 203.Pp 204If the options 205.Dq userquota 206and/or 207.Dq groupquota 208are specified, 209the file system is automatically processed by the 210.Xr quotacheck 8 211command, and legacy user and/or group disk quotas are enabled with 212.Xr quotaon 8 . 213By default, 214file system quotas are maintained in files named 215.Pa quota.user 216and 217.Pa quota.group 218which are located at the root of the associated file system. 219These defaults may be overridden by putting an equal sign 220and an alternative absolute pathname following the quota option. 221Thus, if the user quota file for 222.Pa /tmp 223is stored in 224.Pa /var/quotas/tmp.user , 225this location can be specified as: 226.Bd -literal -offset indent 227userquota=/var/quotas/tmp.user 228.Ed 229.Pp 230It is recommended to turn on the new, in-file system quota with 231.Xr tunefs 8 232or at 233.Xr newfs 8 234time, and to not use the 235.Dq userquota 236or 237.Dq groupquota 238options. 239Migration of limits to the new in-file system quota can be handled 240via 241.Xr quotadump 8 242and 243.Xr quotarestore 8 . 244.Pp 245The option 246.Dq rump 247is used to mount the file system using a 248.Xr rump 3 249userspace server instead of the kernel server. 250.Pp 251The type of the mount is extracted from the 252.Fa fs_mntops 253field and stored separately in the 254.Fa fs_type 255field (it is not deleted from the 256.Fa fs_mntops 257field). 258If 259.Fa fs_type 260is 261.Dq rw 262or 263.Dq ro 264then the file system whose name is given in the 265.Fa fs_file 266field is normally mounted read-write or read-only on the 267specified special file. 268If 269.Fa fs_type 270is 271.Dq sw 272or 273.Dq dp 274then the special file is made available as a piece of swap 275or dump 276space by the 277.Xr swapctl 8 278command towards the beginning of the system reboot procedure. 279See 280.Xr swapctl 8 281for more information on configuring swap and dump devices. 282The fields other than 283.Fa fs_spec 284and 285.Fa fs_type 286are unused. 287If 288.Fa fs_type 289is specified as 290.Dq xx 291the entry is ignored. 292This is useful to show disk partitions which are currently unused. 293.Pp 294The fifth field, 295.Pq Fa fs_freq , 296is used for these file systems by the 297.Xr dump 8 298command to determine which file systems need to be dumped. 299If the fifth field is not present, a value of zero is returned and 300.Xr dump 8 301will assume that the file system does not need to be dumped. 302.Pp 303The sixth field, 304.Pq Fa fs_passno , 305is used by the 306.Xr fsck 8 307program to determine the order in which file system checks are done 308at reboot time. 309The root file system should be specified with a 310.Fa fs_passno 311of 1, and other file systems should have a 312.Fa fs_passno 313of 2. 314Filesystems within a drive will be checked sequentially, 315but file systems on different drives will be checked at the 316same time to use parallelism available in the hardware. 317If the sixth field is not present or zero, 318a value of zero is returned and 319.Xr fsck 8 320will assume that the file system does not need to be checked. 321.Bd -literal 322#define FSTAB_RW "rw" /* read-write device */ 323#define FSTAB_RQ "rq" /* read/write with quotas */ 324#define FSTAB_RO "ro" /* read-only device */ 325#define FSTAB_SW "sw" /* swap device */ 326#define FSTAB_DP "dp" /* dump device */ 327#define FSTAB_XX "xx" /* ignore totally */ 328 329struct fstab { 330 char *fs_spec; /* block special device name */ 331 char *fs_file; /* file system path prefix */ 332 char *fs_vfstype; /* type of file system */ 333 char *fs_mntops; /* comma separated mount options */ 334 char *fs_type; /* rw, ro, sw, or xx */ 335 int fs_freq; /* dump frequency, in days */ 336 int fs_passno; /* pass number on parallel fsck */ 337}; 338.Ed 339.Pp 340The proper way to read records from 341.Pa fstab 342is to use the routines 343.Xr getfsent 3 , 344.Xr getfsspec 3 , 345and 346.Xr getfsfile 3 . 347.Sh FILES 348.Bl -tag -width /etc/fstab 349.It Pa /etc/fstab 350The location of 351.Nm 352configuration file. 353.It Pa /usr/share/examples/fstab/ 354Some useful configuration examples. 355.El 356.Sh EXAMPLES 357To use 358.Dq NAME 359on a non-GPT disk, use: 360.Bd -literal 361NAME=sb2k5Root/a / ffs rw,log 1 1 362NAME=sb2k5Root/b none swap sw,dp 0 0 363.Ed 364.Pp 365For a 366.Xr gpt 8 367disk, use: 368.Bd -literal 369NAME=firstpartition / ffs rw,log 1 1 370NAME=secondpartition none swap sw,dp 0 0 371.Ed 372.Sh SEE ALSO 373.Xr getfsent 3 , 374.Xr getfsspecname 3 , 375.Xr mount 8 , 376.Xr swapctl 8 377.Sh HISTORY 378The 379.Nm 380file format appeared in 381.Bx 4.0 . 382