The /etc/mtab file is a critical system file in Linux that maintains a real-time record of all currently mounted filesystems. Unlike its counterpart /etc/fstab which contains static mount configurations, /etc/mtab is dynamically updated by the mount command.
# Sample /etc/mtab entry structure
device_path mount_point filesystem_type options dump_freq pass_num
Each line in /etc/mtab contains exactly six fields, separated by whitespace:
1. Device/Source
This column specifies the physical device or virtual filesystem being mounted. Examples include:
- Physical devices: /dev/sda1, /dev/mapper/vg-root
- Virtual filesystems: proc, sysfs, tmpfs
- Network shares: server:/export
2. Mount Point
The directory where the filesystem is attached to the directory hierarchy:
/ # Root filesystem
/boot # Boot partition
/proc # Process information
3. Filesystem Type
The format/structure of the filesystem:
- ext4, xfs, btrfs - Common disk filesystems
- proc, sysfs, devpts - Special purpose filesystems
- nfs, cifs - Network filesystems
4. Mount Options
Comma-separated list of mount flags controlling behavior:
rw # Read-write
ro # Read-only
noexec # Disable execution
nosuid # Disable SUID bits
defaults # Standard options (rw,suid,dev,exec,auto,nouser,async)
5. Dump Frequency
Historically used by the dump backup utility (0 means ignore):
0 # Most modern systems use 0
1 # Filesystems needing backup
6. Filesystem Check Order
Controls fsck order during boot:
- 0 - Don't check
- 1 - Check first (root filesystem)
- 2+ - Check in numerical order
Let's examine some real-world entries with explanations:
# Physical disk partition
/dev/nvme0n1p2 / ext4 rw,relatime 0 1
# ^ Device ^ Mount ^ FS ^ Options ^ Dump ^ Check
# Temporary memory-based filesystem
tmpfs /run tmpfs rw,nosuid,nodev,size=10%,mode=755 0 0
# ^ Virtual ^ Mount ^ Type ^ Special options for security/size
# Network filesystem
nas:/mnt/backup /mnt/backup nfs rw,hard,intr 0 0
# ^ Server ^ Local ^ Protocol ^ Network options
For developers needing to parse /etc/mtab programmatically:
# Python example
def parse_mtab():
mounts = []
with open('/etc/mtab') as f:
for line in f:
if line.startswith('#'):
continue
parts = line.strip().split()
if len(parts) >= 6:
mounts.append({
'device': parts[0],
'mountpoint': parts[1],
'fstype': parts[2],
'options': parts[3].split(','),
'dump': int(parts[4]),
'pass': int(parts[5])
})
return mounts
While /etc/mtab serves a similar purpose to /proc/mounts, key differences exist:
- /proc/mounts shows actual kernel view of mounts
- /etc/mtab may include additional user-space options
- /proc/mounts is always up-to-date, while /etc/mtab requires write access
The /etc/mtab
file is a dynamic system file that maintains a real-time record of currently mounted filesystems on a Linux system. Each line represents a mounted filesystem, formatted with six distinct fields separated by whitespace:
device mount_point filesystem_type options dump_freq pass_num
Let's analyze each column using your provided example:
/dev/mapper/VolGroup00-LogVol00 / ext3 rw 0 0
- Device/Source: The block device or virtual filesystem source (
/dev/mapper/VolGroup00-LogVol00
) - Mount Point: Where the filesystem is mounted in the directory tree (
/
) - Filesystem Type: The format of the filesystem (
ext3
) - Mount Options: Comma-separated mount flags (
rw
for read-write) - Dump Frequency: Obsolete backup flag (typically
0
) - Pass Number: fsck check order (
0
means no checking)
Here's how to programmatically parse mtab in Python:
import re
def parse_mtab():
with open('/etc/mtab', 'r') as f:
for line in f:
if line.startswith('#'):
continue
fields = re.split(r'\s+', line.strip())
if len(fields) == 6:
yield {
'device': fields[0],
'mount_point': fields[1],
'fs_type': fields[2],
'options': fields[3].split(','),
'dump': int(fields[4]),
'pass_num': int(fields[5])
}
for mount in parse_mtab():
print(f"{mount['device']} mounted at {mount['mount_point']}")
Note that on newer systems:
/etc/mtab
may be symlinked to/proc/mounts
- The format remains identical to maintain compatibility
- Some pseudo-filesystems (like proc) show special device names
Common issues and solutions:
# Check for mount conflicts
grep "/mnt/point" /etc/mtab
# Verify mount options
awk '$2 == "/mount/point" {print $4}' /etc/mtab
# Find all read-only mounts
grep "\bro\b" /etc/mtab