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.