Understanding /etc/mtab File Parameters in Linux System
In this article, we will explore the /etc/mtab file on a Linux system and understand the various parameters and directives included therein.
What is /etc/mtab File in Linux
The /etc/mtab file is a file that contains a list of currently mounted filesystems. Any mounted filesystem will appear here. In case you have a disk or volume that is not mounted, it will not show up in this file.
The /etc/mtab file is similar to that of the /etc/fstab file but differs slightly. Also, the latter is applied on boot time whilst the /etc/mtab file displays what is currently mounted.
The file is common in UNIX-like systems and is used by the mount and umount commands to mount and unmount volumes.
You can view the /etc/mtab file using the cat command as shown.
$ cat /etc/mtab
Or access it using your favorite text editor. In this example, we have opened the file using the vim text editor.
$ vim /etc/mtab
You can display the same information by viewing the /proc/mounts file as shown.
$ cat /proc/mounts
Understand /etc/mtab File
The /etc/mtab file comprises 6 columns which are separated by white space. The fourth option comprises a list of comma-separated mount options.
Let’s take an example of the following entry.
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
- The first column represents the mount device name – In this case sysfs.
- The second column represents the mount point or where the device is mounted. Here, /sys is the mount point for the sysfs device.
- The third column shows the file system of the device. In this case, sysfs.
- The fourth column displays the mount options, which in most cases are separated by commas. These options indicate the directives for mounting the partition. Here, the mount options are rw,nosuid,nodev,noexec,relatime.
- The fifth and sixth columns are the dump and fsck options respectively.
The dump command uses the dump option to back up a filesystem. This value is redundant and does not hold any meaning in the /etc/mtab file. The option is always 0 and is only included as a formality to make the mtab file congruent with the /etc/fstab file.
The fsck command leverages the last option to probe the filesystem for errors. And just like the dump option, the value is always 0 and holds no meaning. It’s present only for formality’s sake.
Conclusion
In this guide, we have looked at the /etc/mtab file and its purpose. We have further seen the various columns and options present in every line or entry.