4 Command-Line Tricks to Quickly Find Your NFS Mount Point

Published: 2025-11-22
Author: DP
Views: 8
Category: Linux
Content
## The Problem In daily development and system administration tasks, we often need to access files stored on an NFS (Network File System). Sometimes, we only have an NFS URI, such as `nfs://192.168.1.2/volume3/FCP/lib00Work/lm802/`, and need to find its corresponding local mount directory on a Linux system. This article introduces four effective command-line methods to solve this problem. --- ## The Solutions The core idea is to find which local directory has mounted the remote NFS share `192.168.1.2:/volume3/FCP`. Here are four common methods, ranging from simple to advanced, so you can pick the one that best suits your needs. ### Method 1: Using the `mount` Command The `mount` command lists all file systems currently mounted on the system. By piping its output to `grep`, you can easily filter for the target information. ```bash mount | grep "192.168.1.2" ``` For a more precise match, you can include part of the share path: ```bash mount | grep "192.168.1.2:/volume3/FCP" ``` ### Method 2: Checking the `/proc/mounts` File The `/proc/mounts` file is a real-time list of current mount points maintained by the kernel, providing the most raw and accurate information. Querying it is very similar to using the `mount` command. ```bash cat /proc/mounts | grep "192.168.1.2" ``` This method is often more reliable in scripting scenarios than parsing the output of the `mount` command. ### Method 3: Using the `df` Command The `df` (disk free) command is primarily used to display disk space usage for file systems, but its output also includes mount information. Adding the `-h` flag makes the output more human-readable. ```bash df -h | grep "192.168.1.2" ``` The advantage of this method is that you can check the disk usage of the share while finding its mount point. ### Method 4: Using the `findmnt` Command (Recommended) `findmnt` is a more powerful and modern tool specifically designed for finding and displaying file system information. At `wiki.lib00.com`, we highly recommend this method for its structured output and flexible query options. You can search directly by the source device: ```bash # -S, --source <device or label> findmnt -S 192.168.1.2:/volume3/FCP ``` Alternatively, if you are unsure of the full source path, you can still use `grep` for a broader search: ```bash findmnt | grep "192.168.1.2" ``` --- ## Interpreting the Output and Finding the Full Path Regardless of the method you use, you will get an output similar to this: ```text 192.168.1.2:/volume3/FCP on /mnt/nfs_share type nfs4 (rw,relatime,...) ``` The key pieces of information here are: - **Remote Source:** `192.168.1.2:/volume3/FCP` - **Local Mount Point (Target):** `/mnt/nfs_share` Now, let's return to the original problem. The path we were looking for was `nfs://192.168.1.2/volume3/FCP/lib00Work/lm802/`. - `192.168.1.2:/volume3/FCP` corresponds to the local directory `/mnt/nfs_share`. - `lib00Work/lm802/` is a subdirectory within that share. Therefore, the full local path is a combination of the two: ``` /mnt/nfs_share/lib00Work/lm802/ ``` --- ## Summary This article, by author DP@lib00, has demonstrated four methods for finding NFS mount points from the Linux command line. For quick daily checks, `mount | grep` or `df | grep` are sufficient. However, for scripting or when more precise control is needed, `findmnt` is undoubtedly the best choice. Mastering these techniques will make you more efficient when working with network file systems.