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

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)

FAQs

How to Check the Mount Points in Linux? - Scaler Topics? ›

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 detailed information on the mount point at /mnt/data if it exists. If not, it will return nothing.

How to check Linux mount points? ›

To check a specific mount point, you can use the -T option followed by the path to the mount point. This command will display detailed information about the mount point at /mnt/data, including the file system type, the device it is mounted on, and the options used when it was mounted.

How to check mount space in Linux? ›

The df command stands for "disk-free," and shows available and used disk space on the Linux system. df -T shows the disk usage along with each block's filesystem type (e.g., xfs, ext2, ext3, btrfs, etc.) You can get this information in a graphical view using the Disks (gnome-disk-utility) in the GNOME desktop.

How to see all mounted drives in Linux? ›

How to List Mounted Drives Linux
  1. mount Command. The mount command is a versatile tool that allows you to list currently mounted disks on your Ubuntu system. ...
  2. df Command. ...
  3. GNOME Disks Application. ...
  4. lsblk Command. ...
  5. 5. /etc/fstab File.

How to check NFS mount point status in Linux? ›

There are a few simple commands on Linux to check the status of your NFS mounts:
  1. Use mount and filter with grep to see only NFS mounts.
  2. Check df -T output for shares mounted with NFS.
  3. View local mount records in /etc/mtab.
  4. Verify server exports and connectivity to identify issues.
Jan 19, 2024

How do I list partitions and mount points in Linux? ›

On Linux, the mount -l command (or simply mount ) is often used to list all mounted partitions on a system. Conversely, fdisk -l is commonly used to list all partitions from any device that contains a partition table, with hard disks being the most common examples.

What is the mountpoint command? ›

The mountpoint command in Linux is used to determine if a directory or file is a mount point. A mount point is a directory where a filesystem is mounted, allowing access to the files within the filesystem through that directory. In the command above, -d or -q are optional flags.

How do I check mount permissions in Linux? ›

The -w Test Operator

In some cases, we might need to check the permissions of a file system for the current user ($USER). For that purpose, we can use the –w test operator in the shell. Notably, the mount point for a pen drive has read-write permission for the $USER.

How do you check if a device is mounted on Linux? ›

Using the mount Command

One way we can determine if a directory is mounted is by running the mount command and filtering the output. The above line will exit with 0 (success) if /mnt/backup is a mount point. Otherwise, it'll return -1 (error).

How do I check spaces in Linux? ›

How to Check File Space Usage in Linux Using the du Command
  1. -h. Shows sizes in a human-readable format.
  2. -s. Summarizes the total for each argument.
  3. -a. Includes files as well as directories.
Jun 10, 2024

How to check mounted filesystem type in Linux? ›

How to Determine a Mounted File System's Type
  1. Use the devnm command to display the raw device name of the mounted file system. $ devnm /filesystem. /filesystem. ...
  2. Become superuser.
  3. Use the fstyp command to display the file system type. # fstyp dev/rdsk/ device-name. /dev/rdsk/ device-name.

What is mounting in Linux? ›

In Linux, the mount command is used to attach (or mount) a file system (a storage device eg. USB flash drive or hard disk) to a specified directory(eg. /usr/local) in the file system hierarchy. This makes the files and directories of the mounted device accessible to the user and the system.

Where does Linux mount drives? ›

You can use a mountpoint in both /media and /mnt as well as in some other directory. The classic directory for permanent mount points is /mnt , for example sudo mkdir /mnt/exthdd and use that as a mountpoint. /mnt is for internal disks. /media for external.

How do I check mount points in Linux? ›

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

How do I check my mount point space allocation? ›

You can also use the lsblk command to display the allocated disk space and mount points on the server. For example, the df -h /opt command displays the size of the /opt directory, how much space is used, and how space of that is available (free), and the location where the /opt directory is mounted.

What is the Showmount command? ›

The showmount command displays a list of all clients that have remotely mounted a file system from a specified machine in the Host parameter. This information is maintained by the mountd daemon on the Host parameter. This information is saved in the /etc/rmtab file in case the server crashes.

What is the command to check mount point permissions in Linux? ›

Use the lsfs command to display information about mount points, permissions, file system size and so on. Important: For file systems to be NFS exported, be sure to verify that logical volume names for these file systems are consistent throughout the cluster.

How to find stale mount point in Linux? ›

Stale mount points are detected by using the ls –d command. If the command takes more than 60 seconds to return output, then it is a stale mount point.

How to check permanent mount in Linux? ›

How to List Currently Mounted File Systems on Linux
  1. You can list the currently mounted file systems from a Linux command line with a simple mount command. ...
  2. You can list the static file system information by displaying /etc/fstab . ...
  3. You can also list and search for file systems using the findmnt command.
Sep 15, 2022

How to list the disks in Linux? ›

The easiest way to list disks on Linux is to use the “lsblk” command with no options. The “type” column will mention the “disk” as well as optional partitions and LVM available on it. Optionally, you can use the “-f” option for “filesystems“.

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.