Fstab

Last updated

fstab (after file systems table) is a system file commonly found in the directory /etc on Unix and Unix-like computer systems. In Linux, it is part of the util-linux package. The fstab file typically lists all available disk partitions and other types of file systems and data sources that may not necessarily be disk-based, and indicates how they are to be initialized or otherwise integrated into the larger file system structure.

Contents

The fstab file is read by the mount command, which happens automatically at boot time to determine the overall file system structure, and thereafter when a user executes the mount command to modify that structure. It is the duty of the system administrator to properly create and maintain the fstab file.

While fstab is used for basic system configuration, for other uses, it has been superseded by automatic mounting mechanisms.

The file has other names on some versions of Unix; for example, it is found at /etc/vfstab on Solaris systems.

Modern use

The fstab file is read by programs that work with disk partitions and other file systems and is not automatically maintained. Instead it is written by the system administrator or sometimes by an operating system installation program. However, some administration tools can automatically build and edit fstab, or act as graphical editors for it.

Modern Linux systems use udev as an automounter to handle the hot swapping of devices (such as MP3 players or digital cameras) instead of relying on fstab. Programs such as pmount allow ordinary users to mount and unmount filesystems without a corresponding fstab entry; traditional Unix has always allowed privileged users (the root user and users in the wheel group) to mount or unmount devices without a corresponding fstab entry.

Example

The following is an example of an fstab file on a typical Linux system.

# device-spec     mount-point     fs-type      options                                          dump passLABEL=//ext4defaults11 /dev/sda6noneswapdefaults00 none/dev/ptsdevptsgid=5,mode=62000 none/procprocdefaults00 none/dev/shmtmpfsdefaults00# Removable media /dev/cdrom/mnt/cdromudf,iso9660noauto,owner,ro00# NTFS Windows 7 partition /dev/sda1/mnt/Windowsntfs-3gquiet,defaults,locale=en_US.utf8,umask=0,noexec00# Partition shared by Windows and Linux /dev/sda7/mnt/sharedvfatumask=00000# Mounting tmpfs tmpfs/mnt/tmpfschktmpfssize=100m00# Mounting cifs //cifs_name/store/store/pingucifscredentials=/root/smbpass.txt00# Mounting NFS nfs_name:/store/storenfsrw00

The order of records in fstab is important because fsck(8), mount(8), and umount(8) sequentially iterate through fstab and mount in the order defined. [1]

Blank lines and comment lines beginning with a "#" are ignored.

The space or tab-separated fields within each row must appear in a specific order:

  1. device-spec – The device name, label, UUID, or other means of specifying the partition or data source this entry refers to.
  2. mount-point – Where the contents of the device may be accessed after mounting; for swap partitions or files, this is set to none.
  3. fs-type – The type of file system to be mounted.
  4. options – Options describing various other aspects of the file system, such as whether it is automatically mounted at boot, which users may mount or access it, whether it may be written to or only read from, its size, and so forth; the special option defaults refers to a pre-determined set of options depending on the file system type.
  5. dump – A number indicating whether and how often the file system should be backed up by the dump program; a zero indicates the file system will never be automatically backed up.
  6. pass – A number indicating the order in which the fsck program will check the devices for errors at boot time:
  • 0 - do not check
  • 1 - check immediately during boot
  • 2 - check after boot

Missing values in the last two fields are interpreted as zeros. If necessary, space characters in the first, second, and fourth fields are indicated by U+0040@COMMERCIAL AT.

Options common to all filesystems

auto / noauto
With the auto option, the device will be mounted automatically at bootup or when the mount -a command is issued. auto is the default option. For the device not to be mounted automatically, the noauto option is used in /etc/fstab. With noauto, the device can be only mounted explicitly.
dev / nodev
Controls behavior of the interpretation of block special devices on the filesystem.
exec / noexec
exec lets binaries that are on the partition be executed, whereas noexec is the opposite. noexec might be useful for a partition that contains no binaries, like /var, or contains binaries the user may not want to execute on the system, or that cannot even be executed on the system, as might be the case of a Windows partition.
rw / ro
Mount the filesystem in either read write or read only mode. Explicitly defining a file system as rw can alleviate some problems in file systems that default to read only, as can be the case with floppies or NTFS partitions.
sync / async
How the input and output to the filesystem should be done. sync means it is done synchronously. Looking at the example fstab, this is the option used with the floppy. This means that when, for example, a file is copied to the floppy, the changes are physically written to the floppy at the same time copy command is issued.
suid / nosuid
Controls the behavior of the operation of suid, and sgid bits.
user / users / nouser
user permits any user to mount the filesystem. This automatically implies noexec, nosuid, nodev unless explicitly 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.
defaults
Use default settings. Default settings are defined per file system at the file system level. For ext3 file systems these can be set with the tune2fs command. The normal default for ext3 file systems is equivalent to rw,suid,dev,exec,auto,nouser,async. Modern Red Hat based systems set ACL support as default on the root file system but not on user-created ext3 filesystems. Some file systems such as XFS enable ACLs by default. Default file system mount attributes can be overridden in /etc/fstab.
owner (Linux-specific)
Permit the owner of device to mount.
nofail
Do not stop system boot if disk mount failed.
atime / noatime / relatime / strictatime (Linux-specific)
The Unix stat structure records when files are last accessed (atime), modified (mtime), and changed (ctime). One result is that atime is written every time a file is read, which has been heavily criticized for causing performance degradation and increased wear. However, atime is used by some applications and desired by some users, and thus is configurable as atime (update on access), noatime (do not update), or (in Linux) relatime (update atime if older than mtime). Through Linux 2.6.29, atime was the default; as of 2.6.30, relatime is the default. [2]

Filesystem-specific options

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 or forms.

ext2

check=[none, normal, strict]
Sets the fsck checking level.
debug
Print debugging info on each remount.
sb=n
n is the block which should be used as the super-block for the filesystem.

FAT-only

check=[r(elaxed), n(ormal), s(trict)]
Policy for allowed filenames. See mount(8).
conv=[b(inary), t(ext), a(uto)]
Performs DOS <=> UNIX text file conversions automatically. See mount(8).

FAT, NTFS

windows_names
Linux filesystems have a larger set of allowed characters in filenames. windows_names restricts the set of allowed characters for the volume to only those acceptable by Windows; though FAT/NTFS are the most common use cases, this feature is not specifically restricted to those filesystem types.
uid=n, gid=n
Sets the user identifier (uid), and group identifier (gid) for all files on the filesystem.
umask=nnn, dmask=nnn, fmask=nnn
Controls masking of filesystem nodes.
  • umask - user file creation
  • dmask - directory creation
  • fmask - for files only

More detailed information about the fstab file can be found in the man page for Linux fstab; for other systems see below.

NFS

addr=ip
ip is a valid IP address.

See also

Related Research Articles

ext2, or second extended file system, is a file system for the Linux kernel. It was initially designed by French software developer Rémy Card as a replacement for the extended file system (ext). Having been designed according to the same principles as the Berkeley Fast File System from BSD, it was the first commercial-grade filesystem for Linux.

<span class="mw-page-title-main">Disk partitioning</span> Creation of separate accessible storage areas on a secondary computer storage device

Disk partitioning or disk slicing is the creation of one or more regions on secondary storage, so that each region can be managed separately. These regions are called partitions. It is typically the first step of preparing a newly installed disk, before any file system is created. The disk stores the information about the partitions' locations and sizes in an area known as the partition table that the operating system reads before any other part of the disk. Each partition then appears to the operating system as a distinct "logical" disk that uses part of the actual disk. System administrators use a program called a partition editor to create, resize, delete, and manipulate the partitions. Partitioning allows the use of different filesystems to be installed for different kinds of files. Separating user data from system data can prevent the system partition from becoming full and rendering the system unusable. Partitioning can also make backing up easier. A disadvantage is that it can be difficult to properly size partitions, resulting in having one partition with too much free space and another nearly totally allocated.

Linux has several filesystem drivers for the File Allocation Table (FAT) filesystem format. These are commonly known by the names used in the mount command to invoke particular drivers in the kernel: msdos, vfat, and umsdos.

fsck System tool for checking the consistency of a file system

The system utility fsck is a tool for checking the consistency of a file system in Unix and Unix-like operating systems, such as Linux, macOS, and FreeBSD. The equivalent programs on MS-DOS and Microsoft Windows are CHKDSK, SFC, and SCANDISK.

Disk formatting is the process of preparing a data storage device such as a hard disk drive, solid-state drive, floppy disk, memory card or USB flash drive for initial use. In some cases, the formatting operation may also create one or more new file systems. The first part of the formatting process that performs basic medium preparation is often referred to as "low-level formatting". Partitioning is the common term for the second part of the process, dividing the device into several sub-devices and, in some cases, writing information to the device allowing an operating system to be booted from it. The third part of the process, usually termed "high-level formatting" most often refers to the process of generating a new file system. In some operating systems all or parts of these three processes can be combined or repeated at different levels and the term "format" is understood to mean an operation in which a new disk medium is fully prepared to store files. Some formatting utilities allow distinguishing between a quick format, which does not erase all existing data and a long option that does erase all existing data.

df (Unix) Standard Unix command

df is a standard Unix command used to display the amount of available disk space for file systems on which the invoking user has appropriate read access. df is typically implemented using the statfs or statvfs system calls.

stat (system call) Unix system call

stat is a Unix system call that returns file attributes about an inode. The semantics of stat vary between operating systems. As an example, Unix command ls uses this system call to retrieve information on files that includes:

<span class="mw-page-title-main">File system</span> Computer filing system

In computing, a file system or filesystem governs file organization and access. A local file system is a capability of an operating system that services the applications running on the same computer. A distributed file system is a protocol that provides file access between networked computers.

In computing, privilege is defined as the delegation of authority to perform security-relevant functions on a computer system. A privilege allows a user to perform an action with security consequences. Examples of various privileges include the ability to create a new user, install software, or change kernel functions.

In computer data storage, a volume or logical drive is a single accessible storage area with a single file system, typically resident on a single partition of a hard disk. Although a volume might be different from a physical disk drive, it can still be accessed with an operating system's logical interface. However, a volume differs from a partition.

mount (Unix) Unix command to mount a filesystem

In computing, mount is a command in various operating systems. Before a user can access a file on a Unix-like machine, the file system on the device which contains the file needs to be mounted with the mount command. Frequently mount is used for SD card, USB storage, DVD and other removable storage devices. The command is also available in the EFI shell.

<span class="mw-page-title-main">TestDisk</span> Data recovery utility

TestDisk is a free and open-source data recovery utility that helps users recover lost partitions or repair corrupted filesystems. TestDisk can collect detailed information about a corrupted drive, which can then be sent to a technician for further analysis. TestDisk supports DOS, Microsoft Windows, Linux, FreeBSD, NetBSD, OpenBSD, SunOS, and MacOS. TestDisk handles non-partitioned and partitioned media. In particular, it recognizes the GUID Partition Table (GPT), Apple partition map, PC/Intel BIOS partition tables, Sun Solaris slice and Xbox fixed partitioning scheme. TestDisk uses a command line user interface. TestDisk can recover deleted files with 97% accuracy.

Mounting is a process by which a computer's operating system makes files and directories on a storage device available for users to access via the computer's file system.

The following tables compare general and technical information for a number of file systems.

e2fsprogs is a set of utilities for maintaining the ext2, ext3 and ext4 file systems. Since those file systems are often the default for Linux distributions, it is commonly considered to be essential software.

ext4 is a journaling file system for Linux, developed as the successor to ext3.

<span class="mw-page-title-main">Wubi (software)</span> Ubuntu Linux installer for Windows

Wubi is a free software Ubuntu installer, that was the official Windows-based software, from 2008 until 2013, to install Ubuntu from within Windows, to a single file within an existing Windows partition.

The Linux booting process involves multiple stages and is in many ways similar to the BSD and other Unix-style boot processes, from which it derives. Although the Linux booting process depends very much on the computer architecture, those architectures share similar stages and software components, including system startup, bootloader execution, loading and startup of a Linux kernel image, and execution of various startup scripts and daemons. Those are grouped into 4 steps: system startup, bootloader stage, kernel stage, and init process. When a Linux system is powered up or reset, its processor will execute a specific firmware/program for system initialization, such as Power-on self-test, invoking the reset vector to start a program at a known address in flash/ROM, then load the bootloader into RAM for later execution. In personal computer (PC), not only limited to Linux-distro PC, this firmware/program is called BIOS, which is stored in the mainboard. In embedded Linux system, this firmware/program is called boot ROM. After being loaded into RAM, bootloader will execute to load the second-stage bootloader. The second-stage bootloader will load the kernel image into memory, decompress and initialize it then pass control to this kernel image. Second-stage bootloader also performs several operation on the system such as system hardware check, mounting the root device, loading the necessary kernel modules, etc. Finally, the first user-space process starts, and other high-level system initializations are performed.

In computer operating systems, mkfs is a command used to format a block storage device with a specific file system. The command is part of Unix and Unix-like operating systems. In Unix, a block storage device must be formatted with a file system before it can be mounted and accessed through the operating system's filesystem hierarchy.

In Unix-like operating systems, a device file, device node, or special file is an interface to a device driver that appears in a file system as if it were an ordinary file. There are also special files in DOS, OS/2, and Windows. These special files allow an application program to interact with a device by using its device driver via standard input/output system calls. Using standard system calls simplifies many programming tasks, and leads to consistent user-space I/O mechanisms regardless of device features and functions.

References

  1. man 5 fstab
  2. Linux 2 6 30 at Linux Kernel Newbies