Linux: what is fstab and how do I use it?

Wheels machine

When learning Linux system administration one of the basic concept is the fstab file. Many people say you don’t have to touch it, many other say that you should only if things don’t work, but what is its purpose?

The fstab file

The fstab file located in / etc / fstab  is the file that contains the association between filesystems and mountpoints usually used (but not limited to) at boot time. Now let’s look at an example:

  1. The block device (or special path) is specified in the first field. It can be a block device (/dev/sd*), a Universal Unique ID (as in this case), a Label (prefix: LABEL=) or even a network path like remote:/shared .
  2. The mountpoint is the path on which the device/path will be mounted. Think of it like appending the directory content of a device in another directory. In this example the path /home is empty before the second significant line but becomes populated after it.
  3. The filesystem type is the third fields and needs to be adapted depending on the filesystem contained in the device/path specified in the fist field.
  4. Options passed to the mount command are specified in the fourth field.
  5. Dump is the fifth field. Dump is an old program used to backup filesystems, nowadays it isn’t installed by default on most distributions. This field can be 0 (do not dump) or 1 (execute dump).
  6. Fsck is the sixth field. This field specifies whether the filesystem should be checked (if possible) during boot time. The allowed values are 0, 1, 2. 0 means no fsck will be executed at boot time, 1 and 2 will perform the fsck. Value 1 should be reserved to root directory only.

As you can see it is not so complicated, but beware, an error in the fstab file may render the system unbootable, so always double check when making changes.

Image courtesy of mark | marksei

The following two tabs change content below.
The IT guy with a little boredom look in his eyes, fond of computers since forever he now works as a freelancer in the IT and shares his experiences through this blog.

You may also like...