FSTAB(5)

NAME
fstab - static information about filesystems

SYNOPSIS
#include <mntent.h>

DESCRIPTION
The file /etc/fstab describes the filesystems and swapping partitions used by the local machine. The system administrator can modify it with a text editor. It is read by commands that mount, unmount, dump, restore, and check the consistency of filesystems; it is also read by the system when providing swap space. The file consists of a number of lines of the form: fsname dir type opts freq passno for example: /dev/zd0a / 4.2 rw,noquota 1 2 /dev/zd1b swap swap . . . The second line also demonstrates how to handle empty fields; because swap devices have neither options nor backups, the last three fields have a '.' placed in them instead.

The entries from this file are accessed using the routines in getmntent(3), which returns a structure of the following form: struct mntent {
    char    *mnt_fsname;    /* filesystem name */
    char    *mnt_dir;    /* filesystem path prefix */
    char    *mnt_type;    /* 4.2, nfs, swap, or ignore */
    char    *mnt_opts;    /* rw, ro, noquota, quota, hard, soft, intr */
    int    mnt_freq;    /* dump frequency, in days */
    int    mnt_passno;    /* pass number on parallel fsck */
}; Fields are separated by white space; a # as the first non-white space character indicates a comment. If a field is null, you must place a period (.) there as a placeholder.

The mnt_dir fields is the full path name of the directory to be mounted on.

The mnt_type field determines how the mnt_fsname and mnt_opts fields are interpreted. Here is a list of the filesystem types currently supported, and the way each of them interprets these fields:

4.2
    mnt_fsname    Must be a block special device.

nfs
    mnt_fsname    the path on the server of the directory to be served.

swap
    mnt_fsname    must be a block special device swap partition.

If the mnt_type is specified as ignore then the entry is ignored. This is useful to show disk partitions not currently used.

The mnt_opts field contains a list of comma-separated option words. Some mnt_opts are valid for all filesystem types, while others apply to a specific type only:

    mnt_opts valid on all file systems (the default is rw,suid):

    rw  read/write.

    ro  read-only.

    suid
        set-uid execution allowed.

    nosuid
        set-uid execution not allowed.

    mnt_opts specific to 4.2 file systems (the default is noquota).

    quota
        usage limits enforced.

    noquota
        usage limits not enforced.

    mnt_opts specific to nfs (NFS) file systems. The defaults are: fg,retry=1,timeo=7,retrans=4,port=NFS_PORT,hard with defaults for rsize and wsize set by the kernel:

bg  if the first attempt fails, retry in the background.

fg  retry in foreground.

retry=n
    set number of failure retries to n.

rsize=n
    set read buffer size to n bytes.

wsize=n
    set write buffer size to n bytes.

timeo=n
    set NFS timeout to n tenths of a second.

retrans=n
    set number of NFS retransmissions to n.

port=n
    set server IP port number to n.

soft
    return error if server doesn't respond.

hard
    retry request until server responds.

intr
    allow keyboard interrupts on hard mounts.

The bg option causes mount to run in the background if the server's mountd(8) does not respond. Mount attempts each request retry times before giving up. Once the filesystem is mounted, each nfs request made in the kernel waits timeo tenths of a second for a response. If no response arrives, the time-out is multiplied by 2 and the request is retransmitted. When retrans retransmissions have been sent with no reply a soft mounted filesystem returns an error on the request and a hard mounted filesystem retries the request. The number of bytes in a read or write request can be set with the rsize and wsize options, respectively.

The mnt_freq field indicates how often each partition should be dumped by the dump(8) command (and triggers dump's w option, which determines what filesystems should be dumped). Most systems set the mnt_freq field to 1, indicating that filesystems are dumped each day.

The final field, mnt_passno, is used by the consistency checking program fsck(8) to allow overlapped checking of filesystems during a reboot. First, all filesystems with mnt_passno of 1 are checked simultaneously, then all filesystems with mnt_passno of 2, and so on. Typically, the mnt_passno of the root filesystem is set to 1, and one filesystem on each available disk drive is set to be checked in each subsequent pass, until all filesystem partitions are checked.

The /etc/fstab file is only read by programs and never written to by programs; the system administrator must maintain it manually. The order of records in /etc/fstab is important because fsck, mount, and umount process the file sequentially; filesystems must appear after filesystems within which they are mounted.

FILES
/etc/fstab

SEE ALSO
getmntent(3), fsck(8), mount(8)