Understanding the /etc/mtab File in Linux

Linux TLDR
Last Updated:
Reading time: 3 minutes

In this article, you will learn what the β€œ/etc/mtab” file is in Linux, the difference between the β€œ/etc/mtab” and β€œ/etc/fstab” files, their relationship to the β€œmount” and β€œumount” commands, and the different parameters and directives in the β€œ/etc/mtab” file.

What is the /etc/mtab file in Linux?

The β€œ/etc/mtab” file is a system-managed file that keeps records of currently mounted devices. If you attach a device to your system without mounting it, it won’t appear in the record until you mount it using the β€œmount” command.

The β€œ/etc/mtab” file is similar to that of the β€œ/etc/fstab” file, but with slight differences. A user manages the β€œ/etc/fstab” file, which contains information about the list of filesystems to mount at boot time. Thus, to have your disk or volume mounted upon system boot, you must include the correct command in β€œ/etc/fstabβ€œ.

The mount and umount commands handle the management of records in the β€œ/etc/mtab” file and the configuration of devices for system boot in the β€œ/etc/fstab” file.

You can view the contents of β€œ/etc/mtab” using the β€œcat” or β€œbat” command, as shown.

$ cat /etc/mtab

Output:

viewing the content of mtab file

The content structure of the β€œ/etc/mtab” file is similar to that of the β€œ/etc/fstab” file. However, it’s not used by a kernel that maintains its own list, namely β€œ/proc/mounts” and β€œ/proc/self/mountsβ€œ. In certain Linux systems, the β€œ/etc/mtab” file is a symlink to the β€œ/proc/mountsβ€œ.

So, to display the information, you can view the β€œ/proc/mounts” or β€œ/proc/self/mounts” file, as shown.

$ cat /proc/mounts

#OR

$ cat /proc/self/mounts

Output:

viewing the content of mounts file

You now understand the role and difference of each file. Next, let’s go through each column in the β€œ/etc/mtab” file to understand their significance.

Understand the /etc/mtab file

The β€œ/etc/mtab” file consists of six columns separated by whitespace, with the fourth column comprising a list of comma-separated mount options.

For example, a typical entry in this file looks like the one below.

sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0

Whereas,

1. The first column represents the mount device name (in our case, β€œsysfsβ€œ). These are high-level block devices that map to physical devices.

2. The second column represents the location where a device is mounted, also referred to as the mount point. In this case, β€œ/sys” serves as the mount point for the β€œsysfs” device.

3. The third column displays the filesystem of the device, which may be managed either by the system or the user. For instance, the β€œdevtmpfs” filesystem, responsible for temporary data erased and recreated across system reboots, is system-managed, while regular filesystems like NTFS, FAT, EXT4, etc., are user-managed.

4. The fourth column contains the mount options, defining directives for partition mounting, which can be assigned more than one, separated by commas. Here, the mount options are β€œrw,nosuid,nodev,noexec,relatimeβ€œ.

5. The fifth column represents the dump options. The dump command uses the dump option to back up the filesystem but holds no significance in β€œ/etc/mtabβ€œ, serving solely to synchronize the β€œ/etc/mtab” file with the β€œ/etc/fstab” file. The value β€œ0” indicates to ignore this option.

6. The sixth column represents the fsck options. The fsck command uses the final option to verify the filesystem for errors. However, like the dump option, it serves no purpose and remains in place for consistency with β€œ/etc/fstabβ€œ. Therefore, the value β€œ0” indicates to ignore this option.

Final Word

Today, you learned about the β€œ/etc/mtab” file and its purpose. If you have any questions or queries related to the topic, feel free to ask them in the comment section.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.