Authors Top

If you have a few years of experience in the Linux ecosystem, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

1. Overview

In this tutorial, we’ll look at the /etc/mtab file in Linux. First, we’ll discuss its basic overview and the similarities it shares with the /etc/fstab file. Then, we’ll discuss the different options columns inside the file.

Finally, we’ll see why the last two options for the dump and fsck commands are unused by the /etc/mtab file.

2. The /etc/mtab File

The /etc/mtab file contains the currently mounted filesystems. It’s used by the mount and umount commands to mount, list, and unmount the volumes.

The content structure of the mtab file is similar to the /etc/fstab file. However, the mtab file is not used by the kernel, which maintains its own list, i.e., /proc/mounts and /proc/self/mounts. In some systems, the mtab file is a symlink to /proc/mounts.

The /etc/mtab file has six columns. Here’s a typical /etc/mtab file:

proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sys /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
dev /dev devtmpfs rw,nosuid,relatime,size=1952812k,nr_inodes=488203,mode=755,inode64 0 0
run /run tmpfs rw,nosuid,nodev,relatime,mode=755,inode64 0 0
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
/dev/sda3 / ext4 rw,relatime 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev,inode64 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
cgroup2 /sys/fs/cgroup cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
bpf /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=12781 0 0
fusectl /sys/fs/fuse/connections fusectl rw,nosuid,nodev,noexec,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,nosuid,nodev,noexec,relatime 0 0
...

In the next section, we’ll go over each column and see what they signify.

3. Contents of the mtab File

As we know, the contents of the mtab file consist of six columns separated by a whitespace. For our example, we’ll cover the dev entry from the file:

dev /dev devtmpfs rw,nosuid,relatime,size=1952812k,nr_inodes=488203,mode=755,inode64 0 0

Let’s break it down.

3.1. Mount Device and Mount Point

The first column contains the dev mount device. Usually, these are high-level block devices that map onto physical devices. For instance, the dev mount device in the snippet maps to the /dev directory on the primary hard drive.

The second column consists of the location where a device is mounted, known as the mount point. In the snippet, the /dev directory is the mount point for the dev device.

3.2. File System

The third column signifies the type of the device filesystem. Some of the file systems in this column are highly specific for different use cases. For instance, the devtmpfs file system holds temporary data that’s erased and created across reboots by the OS.

Additionally, these file systems are usually managed by the operating system and system applications.

Apart from that, this column can also include a regular filesystem such as NTFS, FAT, EXT4, which we can use to store data on external drives.

3.3. Mount Options

The fourth column contains the mount options. Mount options indicate the parameters used to mount the partition. We can mount a device with more than one option separated by commas.

One of the options is defaults, which is a generic option that encapsulates rw, suid, dev, exec, auto, nouser, and async options.

3.4. The dump and fsck Options

The fifth and sixth columns are the dump and fsck options. The dump command uses the dump option to back up a filesystem. However, it doesn’t mean anything in /etc/mtab. Therefore, it’s only included to make the mtab file cohere with the /etc/fstab file. The option is always 0, which is a dummy value to ignore this option.

Similary, the fsck command uses the last option to check the filesystem for errors. However, like the dump option, it’s useless and is there for coherence with /etc/fstab.

4. Conclusion

In this article, we discussed the purpose of the /etc/mtab file and how it’s similar to the /etc/fstab file. Additionally, we also understood the meaning of each column inside the file.

Authors Bottom

If you have a few years of experience in the Linux ecosystem, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

Comments are closed on this article!