The fstab (/etc/fstab) (or file systems table) file is a system configuration file commonly found on Unix systems. The fstab file typically lists all available disks and disk partitions, and indicates how they are to be initialized or otherwise integrated into the overall system's file system. fstab is still used for basic system configuration, notably of a system's main hard drive and startup file system, but for other uses has been superseded in recent years by automatic mounting.
The fstab file is most commonly used by the mount
command, which reads the fstab file to determine which options should be used when mounting the specified device. It is the duty of the system administrator to properly create and maintain this file.
The file has other names on some versions of Unix; for instance, it is /etc/vfstab
on Solaris.
Contents |
Traditionally, the fstab was only read by programs, and not automatically written (it is instead manually written by the sysadmin). However, some administration tools can automatically build and edit fstab, or act as graphical editors for it, such as the Kfstab graphical configuration utility available for KDE.
Modern Linux systems use udev as an automounter to handle hot swapping devices instead of rewriting the fstab file on the fly, and thus fstab is less important than in the past. Programs such as pmount allow non-root users to mount and unmount filesystems without a corresponding fstab entry; traditional Unix has always allowed privileged users to mount or unmount without an fstab entry.
The following is an example of an fstab file on a typical Linux system:
# device name mount point fs-type options dump-freq pass-num LABEL=/ / ext3 defaults 1 1 /dev/hda6 swap swap defaults 0 0 none /dev/pts devpts gid=5,mode=620 0 0 none /proc proc defaults 0 0 none /dev/shm tmpfs defaults 0 0 # Removable media /dev/cdrom /mount/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0 /dev/fd0 /mount/floppy auto noauto,owner,kudzu 0 0 # NTFS Windows XP partition /dev/hda1 /mnt/WinXP ntfs-3g quiet,defaults,locale=en_US.utf8,umask=0,noexec 0 0 # Partition shared by Windows and Linux /dev/hda7 /mnt/shared vfat umask=000 0 0 # mounting tmpfs tmpfs /mnt/tmpfschk tmpfs size=100m 0 0 # mounting cifs //pingu/ashare /store/pingu cifs credentials=/root/smbpass.txt 0 0 # mounting NFS pingu:/store /store nfs rw 0 0
The columns are as follows:
A value of zero in either of the last 2 columns disables the corresponding feature. For the whitespace character in paths the character code "\040" is used.
As the filesystems in /etc/fstab will eventually be mounted using mount(8) it is not surprising that the options field simply contains a comma-separated list of options which will be passed directly to mount when it tries to mount the filesystem.
The options common to all filesystems are:
atime / noatime / relatime / strictatime (Linux-specific)
auto / noauto
dev / nodev
exec / noexec
ro
rw
sync / async
suid / nosuid
user / users / nouser
user
permits any user to mount the filesystem. This automatically implies noexec, nosuid, nodev unless overridden. If nouser
is specified, only root can mount the filesystem. If users
is specified, every user in group users will be able to unmount the volume.owner
(This is Linux-specific)defaults
rw,suid,dev,exec,auto,nouser,async
(no acl support). Modern Red Hat based systems set acl support as default on the root file system but not on user created Ext3 file systems. Some file systems such as XFS enable acls by default. Default file system mount attributes can be over ridden in /etc/fstab.There are many options for the specific filesystems supported by mount. Listed below are some of the more commonly used. The full list may be found in the documentation for mount. Note that these are for Linux; traditional UNIX-like systems have generally provided similar functionality but with slightly different syntax.
check={none, normal, strict}
debug
sb=n
check={r[elaxed], n[ormal], s[trict]}
conv={b[inary], t[ext], a[uto]}
uid=n, gid=n
umask=nnn, dmask=nnn, fmask=nnn
norock
More detailed information about the fstab file can be found in the man page about Linux fstab; for other systems see below.
mount -a
This command will mount all (not-yet-mounted) filesystems mentioned in fstab and is used in system script startup during booting. Note that this command will ignore all those entries containing "noauto
" in the options section.