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/mtabOutput:

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/mountsOutput:

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 0Whereas,
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!




