What is Fstab in Linux?

What is Fstab in Linux?

The /etc/fstab file contains information about file systems.  It is used by several commands on Linux to define how file systems are mounted.  Every filesystem that Linux supports supports many different mount options depending on the file system.  For example, a filesystem called XFS, supports custom options like barriers/nobarriers, but ext4 supports options like discard if you are using solid state disks.

The /etc/fstab file is comprised for six fields or columns, device, mount point, file system type, mount options, dump options, fsck options.

Table 1
Device Mount Point File System Mount Options Dump Options File System
Check Options
/dev/sda1 /home ext3 rw 2
UUID=4dc0394e-605f-4e6e-8181-e65e3d2e4152 / ext4 rw,errors=remount-ro 1
UUID=d0c7cad3-5f85-4b9d-80b7-acf9c8496b72 none swap sw
proc /proc proc nodev,noexec,nosuid
/dev/VG00/lv01 /usr xfs barriers 3
LABEL=BACKUP /local btrfs defaults 4

Table 1 illustrates the fstab file in a table format. As you can see, you can as many entries in this file as you need. For complex layouts, you may have more or for simplier layouts, you may only have two or three entries, usually one for the / (root) filesystem, the proc file system and maybe swap, which is optional, but usually recommended.

Device

The device represents the hardware that you want to access.  The device, /dev/sda1 represents the first partion on the first disk of the system.  Refering to the device is one way to reference a device.  Another way, is to use the LABEL or UUID.  Both LABEL and UUID both have distinct advantantes in that the UUID or LABEL should be unique to the device and never change.  This means that if you re-order the drives, /dev/sda1 may become /dev/sdb1.  As you can see, this would be problematic as they system boots up and can not find the / (root) volume.  In newer distributions, you will  most likely see devices referenced by their UUID.

Read Also:  Photoshop Is Still The Best…

In addition there are other special devices, such as proc and cgroup.  The proc device is a special device that contains runtime information for your systems kernel.  If you run “cat /proc/cpuinfo” you will see information related to your current CPU.  The cgroup device is another special device used for Linux Containers (LXC) which is type of virtualization.

Mount Point

Mount point is the destination where you want the device to be accessible.  For example, the / (root) mount point, will always be at the top level, /.  However, you may have a seperate partition for /home, /var, or /usr, depending on your needs.

File System Type

As you work with Linux, you will notice that it supports many different types of operating systems.  Some he examples include ext2, ext3, ext4, xfs, jfs, btrfs and the list goes on.

Mount options

With such a large variety of file systems, they all have different options regarding how you mount them.  This column provides a location for providing mount options.  For example, if you are xfs, you may want to include barriers or nobarriers.  Another options is “defaults” which just says use the default options.

Dump Options

This column specifies whether the filesystem should be backed up using the dump command.  Most often this column is zero.

File System Check Options

The last column specifies the order that a filesystem check will be performed.  A value of zero indicates that the filesystem will never be checked.  The file systems, /proc, /cgroup, and /swap should never need to be checked, so a value of zero makes sense.

Leave a Reply

Your email address will not be published. Required fields are marked *