What is fstab
The file fstab contains information about the various file systems and storage devices in your computer. It is this single file which determines how a disk (partition) is to be used or otherwise integrated into the overall system.
The full path to the file is /etc/fstab. It is just a plain text file which you can open with your favorite editor, though you can only edit it when you are root.
A closer look at the fstab file
Lets have a closer look to the build up of the file. A typical entry has the following fields (fields are separated by either a space or a tab):
<file system> <dir> <type> <options> <dump> <pass>
- The first field, <file systems> is pretty straightforward. This entry tells the mount command exactly what to mount, so one should substitute for this entry the device name, remote partition, or similar.
- The second field, <dir>, tells the mount command where it should mount the <file system>.
- The <type> field tells the mount command the file system type of the device or partition to be mounted. Many different file systems are supported. For a complete list of supported file systems, consult the mount man-page. Typical names to be used include among others ext2, ext3, reiserfs, xfs, jfs, smbfs, iso9660, vfat, ntfs, swap, and auto. 'auto' is NOT a file system, it lets the mount command guess what type of file system is used, particularly handy for removable devices, floppies, and cdroms.
- Moving on to the next field, which is the <options> field. I will only put the most common options here, not to confuse people ;). For a complete list see the mount manpage.
auto File system is mount automatically at boot, or when the command 'mount -a' is issued. noauto The file system can be mounted only explicitly. exec Again this is a default option. The 'exec' option lets you execute binaries that are on that partition. noexec Binaries are not allowed to be executed. NEVER use this option for your root file system! ro Mount file system read only rw Mount file system read-write sync All I/O should be done synchronously async All I/O should be done asynchronously user Permit any user to mount the filesystem. Implies noexec,nosuid,nodev unless overridden. nouser Only permit root to mount the filesystem. This is also a default setting. defaults Use default settings. Equivalent to rw,suid,dev,exec,auto,nouser,async. suid Permit the operation of suid, and sgid bits. They are mostly used to allow users on a computer system to execute binary executables with temporarily elevated privileges in order to perform a specific task. nosuid Blocks the operation of suid, and sgid bits.
- Over to the fifth field, <dump>. The <dump> entry is used by the dump utility to decide when to make a backup. When installed (dump is not installed by a standard installation of Arch Linux), dump checks the entry and uses the number to decide if a file system should be backed up. Possible entries are 0 and 1. If 0, dump will ignore the file system, if 1, dump will make a backup. Most users will not have dump installed, so they should put 0 for the <dump> entry.
- The last entry is <pass>. fsck looks at the number substituted for <pass> and determines in which order the file systems should be checked. Possible entries are 0, 1, and 2. File systems with a <pass> value 0 will not be checked by the fsck utility. The root file system should have the highest priority, 1, all other file systems you want to have checked should get a 2.
Example fstab file
Now lets take a look at some typical fstab file:
# <file system> <dir> <type> <options> <dump> <pass> none /dev/pts devpts defaults 0 0 none /dev/shm tmpfs defaults 0 0 /dev/cdrom /mnt/cd iso9660 ro,user,noauto,unhide 0 0 /dev/dvd /mnt/dvd udf ro,user,noauto,unhide 0 0 /dev/fd0 /mnt/fl auto user,noauto 0 0 /dev/hda1 swap swap defaults 0 0 /dev/hda4 / ext3 defaults 0 1 /dev/hda3 /home xfs rw,suid,exec,auto,nouser,async 0 2