When your Linux system relies on separate storage volumes, verifying a mount point’s status ensures your data is actually accessible. Knowing how to check mount point in linux is a fundamental skill for any system administrator or power user. This guide walks you through every reliable method, from simple commands to advanced troubleshooting.
How To Check Mount Point In Linux
Mount points are the directories where filesystems are attached to your Linux tree. If a volume isn’t mounted, you can’t read or write to it. Checking mount points helps you confirm that external drives, network shares, or partitions are properly connected and ready for use.
There are several ways to check mount points. The most common methods use built-in command-line tools. Each tool gives you slightly different information, so knowing a few of them is useful.
Using The Mount Command
The mount command is the most direct way to see all mounted filesystems. Run it without any arguments to list everything currently mounted.
mount
This shows output like:
/dev/sda1 on / type ext4 (rw,relatime)
/dev/sdb1 on /mnt/data type ext4 (rw,relatime)
The format is: device on mount_point type filesystem (options). Look for the mount point you care about in the second column. If you see it, the filesystem is mounted. If not, it might be missing or unmounted.
You can also filter the output. For example, to check only ext4 filesystems:
mount -t ext4
This narrows the list to filesystems of that type. It’s helpful when you have many virtual or temporary mounts cluttering the output.
Checking With Df Command
The df command reports disk space usage. It also shows mount points. Run it with the -h flag for human-readable sizes.
df -h
Output looks like:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 20G 28G 42% /
/dev/sdb1 100G 60G 36G 63% /mnt/data
The last column is the mount point. If your target directory appears here, it’s mounted. If not, it’s either unmounted or doesn’t exist. The df command is great for quickly verifying that a mount point is active and has space.
To check a specific mount point, use:
df -h /mnt/data
This returns info only for that filesystem. If it’s not mounted, you’ll get an error like “df: /mnt/data: No such file or directory.”
Using Findmnt Command
The findmnt command is designed specifically for finding mount points. It’s part of the util-linux package and is usually pre-installed. It gives a clean, tree-like output.
findmnt
This shows all mounts in a hierarchical format. To check a specific mount point:
findmnt /mnt/data
If the mount point exists, it prints details. If not, it returns nothing. You can also use the device name:
findmnt /dev/sdb1
The findmnt command is fast and precise. It’s my go-to for quick checks because it avoids the clutter of other commands.
Checking The /Proc/Mounts File
The kernel maintains a virtual file at /proc/mounts. This file lists all mounted filesystems in real time. You can read it with cat or grep.
cat /proc/mounts
This shows output similar to the mount command. To check a specific mount point:
grep /mnt/data /proc/mounts
If the mount point is present, you’ll see the line. If not, no output. This method is reliable because it reads directly from the kernel.
Using The Lsblk Command
The lsblk command lists block devices. It shows partitions and their mount points. Run it without options:
lsblk
Output looks like:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 50G 0 part /
sdb 8:16 0 100G 0 disk
└─sdb1 8:17 0 100G 0 part /mnt/data
The MOUNTPOINT column shows where each partition is mounted. If a partition has no mount point, that column is empty. This is useful for seeing which devices are available but not mounted.
To show only mounted filesystems:
lsblk -l | grep -v "^$"
But the simplest is just to look at the output. The lsblk command is great for hardware-level checks.
Checking With Systemd Mount Units
If your system uses systemd, you can check mount points with systemctl. Mount points are treated as units.
systemctl list-units --type=mount
This shows all active mount units. To check a specific one:
systemctl status mnt-data.mount
Note that systemd replaces slashes with dashes. So /mnt/data becomes mnt-data.mount. This method is more advanced but useful for debugging.
Verifying Mount Point Existence
Before checking if a filesystem is mounted, verify the mount point directory exists. Use:
ls -ld /mnt/data
If the directory doesn’t exist, you need to create it first:
sudo mkdir -p /mnt/data
Then mount the filesystem. Without the directory, mounting will fail.
Common Mount Point Issues
Sometimes a mount point appears in mount but you can’t access it. This can happen due to permissions or filesystem errors. Check the mount options:
mount | grep /mnt/data
Look for options like ro (read-only) or noexec. If it’s read-only, you can’t write. If it’s noexec, you can’t run binaries.
Another issue is a stale mount. This happens when a network filesystem disconnects. The mount point still shows as mounted, but operations hang. Use:
df -h /mnt/data
If it hangs, the mount is stale. You can force unmount with:
sudo umount -l /mnt/data
The -l flag does a lazy unmount, which detaches the filesystem immediately.
Checking Mount Points In Scripts
For automation, you can check mount points in shell scripts. Use grep on /proc/mounts:
if grep -qs /mnt/data /proc/mounts; then
echo "Mounted"
else
echo "Not mounted"
fi
The -q flag suppresses output. This is efficient for cron jobs or monitoring scripts.
You can also use findmnt with exit codes:
if findmnt /mnt/data &> /dev/null; then
echo "Mounted"
else
echo "Not mounted"
fi
Both methods work well. Choose based on your preference.
Using The Stat Command
The stat command shows file or filesystem status. For a mount point:
stat /mnt/data
Look for the “Filesystem” line. It shows the device ID. If the mount point is valid, you’ll see a device. If not, it might show the root filesystem instead.
This is less direct but can help in debugging.
Checking With Mountpoint Command
Some systems have a mountpoint command. It checks if a directory is a mount point.
mountpoint /mnt/data
It returns exit code 0 if it’s a mount point, 1 otherwise. This is simple and script-friendly.
If the command isn’t available, install it with your package manager.
Using The Blkid Command
The blkid command shows block device attributes. It doesn’t show mount points directly, but you can combine it with other tools.
blkid /dev/sdb1
This shows the UUID and filesystem type. Then you can check if that device is mounted.
For a complete picture, use lsblk which shows both.
Checking Network Mount Points
For NFS or CIFS mounts, the methods above still work. But you can also check with showmount for NFS:
showmount -e server_ip
This lists exported shares. Then verify they are mounted locally.
For CIFS, use smbclient or check /etc/fstab.
Using The Fuser Command
The fuser command shows which processes are using a mount point. This is useful before unmounting.
fuser -v /mnt/data
It lists PIDs and users. If no processes are using it, you can safely unmount.
Checking With Lsof
The lsof command lists open files. To see files on a mount point:
lsof /mnt/data
This shows all open files. If the mount point is empty, no files are open.
Using The Nfsstat Command
For NFS mounts, nfsstat shows statistics. It doesn’t show mount points directly but helps diagnose issues.
nfsstat -m
This shows mounted NFS filesystems.
Checking Mount Points In /Etc/Fstab
The /etc/fstab file defines filesystems to mount at boot. To see what should be mounted:
cat /etc/fstab
Compare this with actual mounts. If a filesystem is in fstab but not mounted, it might have failed to mount.
To mount all filesystems from fstab:
sudo mount -a
This mounts any missing entries.
Using The Dmesg Command
The dmesg command shows kernel messages. After mounting, check for errors:
dmesg | tail -20
Look for messages about the device or mount point. This helps with hardware issues.
Checking With Udevadm
The udevadm command manages device events. To check a device:
udevadm info /dev/sdb1
This shows device details. It doesn’t show mount points but helps identify the device.
Using The Inotifywait Command
For real-time monitoring, use inotifywait. It watches for changes on a mount point.
inotifywait -m /mnt/data
This is advanced and not for casual checks.
Common Mistakes
One mistake is confusing the mount point with the device. The mount point is a directory, not a device file. Always check the directory.
Another mistake is forgetting to create the mount point directory. Without it, mounting fails.
Also, don’t rely solely on one command. Different commands show different details. Use multiple methods for confirmation.
Automating Mount Checks
For regular checks, create a cron job. Use a script that checks /proc/mounts and sends alerts if a mount is missing.
#!/bin/bash
if ! grep -qs /mnt/data /proc/mounts; then
echo "Mount point /mnt/data is missing" | mail -s "Mount Alert" admin@example.com
fi
Run this every minute or hour as needed.
Using Nagios Or Prometheus
For enterprise monitoring, use tools like Nagios or Prometheus. They have plugins to check mount points. For example, the check_disk plugin in Nagios.
This gives you alerts and historical data.
Conclusion
Knowing how to check mount point in linux is essential for system reliability. Use the mount, df, findmnt, and lsblk commands for quick checks. For scripting, rely on /proc/mounts or findmnt. Always verify the directory exists and check for errors with dmesg. With these tools, you can ensure your data is always accessible.
Frequently Asked Questions
How Do I Check If A Mount Point Is Mounted In Linux?
Use the mount command without arguments, or findmnt /mount/point. If the mount point appears in the output, it’s mounted. You can also check /proc/mounts with grep.
What Is The Difference Between Mount And Findmnt?
The mount command shows all mounted filesystems in a flat list. findmnt shows a tree structure and is faster for specific queries. Both are reliable, but findmnt is more modern.
Can I Check Mount Points Without Root Access?
Yes, most commands like mount, df, and findmnt work as a regular user. Only mounting or unmounting requires root. Checking status is always accessible.
Why Does My Mount Point Show As Mounted But I Can’t Access It?
This can happen due to permissions, read-only options, or a stale network mount. Check the mount options with mount | grep /mount/point. Also verify the directory permissions with ls -ld.
How Do I Check Mount Points In A Script?
Use grep -qs /mount/point /proc/mounts or findmnt /mount/point &> /dev/null. Both return exit codes that you can use in conditional statements.