How to Check the Mount Points in Linux? - Scaler Topics (2024)

Overview

A mount point is a directory in a Linux file system on which an additional filesystem is connected or "mounted." It offers you access to the contents of the mounted file system and integrates it into the overall directory structure. In Linux, mounting is the process of attaching a partition, hard disk, or file system to the currently active system. To mount a file system or directoryin Linux, the mount point must be a directory. Similarly, if you want to mount a file, the mount point must be a file.

Using Mount Command to Check Mount Points

The mount command in Linux can be used to determine that a directory is mounted on the system.The basic syntax for the mount command in Linux is as follows:

Let us understand each option in the above syntax:

  • -l or --list: This option provides alist of all mounted filesystems in a concise format. With this option, you can see details about mounted filesystems, such as the device or partition that is being mounted, the mount point directory, the filesystem type, and any mount options specified.
  • h or --help: This option displays the help message, which includes a summary of the command's usage as well as a brief descriptionof the possible options.
  • -V or --version: This option displays the version information of the mount command.

When we run the mount command without any options, all currently mounted file systems are shown.

Output:

How to Check the Mount Points in Linux? - Scaler Topics (1)

When we run the mount command with the -l option, the output is the same as when we run the mount command without any options.

Output

How to Check the Mount Points in Linux? - Scaler Topics (2)

When we run the mount command with the -t option, it displays all of the file systems of a given type that are currently mounted on the system.

Output

How to Check the Mount Points in Linux? - Scaler Topics (3)

When we run the mount command with the -v option, it displays a list of mounted filesystems along with their device or partition, mount point directory, filesystem type, and mount options. The verbose output can be useful for troubleshooting.

Output

How to Check the Mount Points in Linux? - Scaler Topics (4)

Checking Mount Points Using Mountpoint Command

The mountpoint command in Linux can also be used to determine whether a directory is a system mount point.The basic syntax for the mountpoint command in Linux is as follows:

Here is an explanation of the available options for mountpoint:

  • -q or --quiet: This option does not print anything.
  • -d or --fs-devno: This option prints the major/minor numbers of the device that is mounted on the given directory.
  • -x or --devno: This option prints major/minor numbers of the given blockdevice on standard output.

When we run the mountpoint command with the -q option, it displays the exit status, which is 0 if the path is a mount point and one if it is not.

When we run the mountpoint command with the -d option, it shows the information in a verbose format, which can be useful in troubleshooting.

When we run the mountpoint command with the -x option, it checks if the path is a mountpoint but does not print any messages.

mountpoint -x /mnt/data

Using Findmnt Command to Check Mount Points

The findmnt command in Linux can be used as well to determine whether a directory is a system mount point.The basic syntax for the findmnt command in Linux is as follows:

If you want to check detailed information about a specific mount point, you can use the -T option followed by the path to the mount point. This command displays information about the file system type, the device on which it is mounted, and the options used during the mount process.

The command mountpoint -T /mnt/data displays information on the mount point at /mnt/data. This includes the file system used (such as ext4, NTFS, or FAT), the device or partition with which it is associated (such as /dev/sda1 or /dev/nvme0n1p2), and the parameters used during the mounting process (such as read-only, noexec, or realtime).

Output

See Also
Mount-points

How to Check the Mount Points in Linux? - Scaler Topics (5)

The findmnt command -l option can be used to display a list of all the mounted file systems.

Output

How to Check the Mount Points in Linux? - Scaler Topics (6)

We can also use the findmnt command with different options to filter the output by file system type, device, options, and so on.

The findmnt -t ext4 -o TARGET command will display a list of all mount points associated with the ext4 filesystems.

OutputHow to Check the Mount Points in Linux? - Scaler Topics (7)

If you want to check if a directory is a mount point, use findmnt with the --mountpoint option. The findmnt --mountpoint /mnt/data command shows detailedinformation on the mount point at /mnt/data if it exists. If not, it will return nothing.

Reading the file/mounts/procs to Check Mount Points in Linux System

Reading the contents of the /proc/mounts file is another way to determine whether a directory is a mount point on a Linux system. This file acts as a virtual file, holding information on all of the file systems currently mounted on the system, such as device name, mount point, and file system type.

The command cat /proc/mounts displays the contents of this file, which is used to determine whether a directory on a Linux system is a mount point.

Output

How to Check the Mount Points in Linux? - Scaler Topics (8)

The command grep "/mnt/data" /proc/mounts is used to search for a specific mount point in the /proc/mounts file. When we run this command, it displays a line containing metadata regarding the file system mounted on /mnt/data, if it exists. Otherwise, it will return nothing.

We can also use awk '{print $2}' /proc/mounts command to print the second column of the file which is the mount point.

Output

How to Check the Mount Points in Linux? - Scaler Topics (9)

FAQs

Q. How can I get a list of all mount points in Linux?

A. In Linux, you can use the mount, mount -l, and cat /proc/mountscommands to list all mount points.

Q. Is it possible to check if a directory is a mount point without displaying any output?

A. Yes, you can use the mountpoint command with the -q or --quiet option. The mountpoint -q /mnt/data command produces no output but setsthe exit status depending on whether /mnt/data is a mount point or not.

Q. Can We filter the mount points based on the file system type?

A. Yes, We can use the findmnt command with -t option to filter the mount points. For example, using findmnt -t ext4 will show only the mount points with the ext4 file system.

Q. Can we check the mount points on a remote Linux system?

A. Yes, you can use SSH or other remote access techniques to connect to the remoteLinux system and use the mount-related commands(mount, mountpoint, findmnt, and so on) to check the mount points on that system.

Conclusion

  • A mount point is a directory in a Linux file system on which an additional filesystem is connected or "mounted."
  • The mount command in Linux can be used to determine that a directory is mounted on the system.
  • When we run the mount command with the -l option, the output is the same as when we run the mount command without any options.
  • When we use the mountpoint command with the -q or --quiet option, this command produces no output but sets the exit status depending on whether /mnt/data is a mount point or not.
  • We can use the findmnt command with different options (-t option,,-S option) to filter the output by file system type and device or partition.
How to Check the Mount Points in Linux? - Scaler Topics (2024)
Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated:

Views: 6349

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.