How to mount NFS shared disk in Linux
In Linux, you can use mount
the command to mount an NFS (Network File System) shared disk. The following are the general steps for mounting an NFS shared disk:
-
Make sure you have the NFS client installed: First, you need to make sure you have the NFS client tool installed on your Linux system. Most Linux distributions have these tools installed by default, but if your system does not have them installed, you can install them using the following command:
For APT-based systems such as Ubuntu and Debian:
sudo apt-get update sudo apt-get install nfs-common
For YUM-based systems such as CentOS and Fedora:
sudo yum install nfs-utils
-
Create a local mount directory: In Linux, you need to create a local directory for mounting the remote NFS share. You can choose any suitable directory as the mount point, such as
/mnt/nfs
:sudo mkdir -p /mnt/nfs
-
Mount NFS shared disk: Use
mount
the command to mount the NFS share. Assume that the IP address of the remote NFS server isserver_ip
, the shared directory is/path/to/shared/folder
, and the local mount directory is/mnt/nfs
, then the mount command is as follows:sudo mount -t nfs server_ip:/path/to/shared/folder /mnt/nfs
If the NFS server uses NFS version 4, you can mount it using the following command:
sudo mount -t nfs -o vers=4 server_ip:/path/to/shared/folder /mnt/nfs
-
Verify the mount: After executing the mount command, you can use
df -h
the command to view the mounted file system and confirm whether the NFS share has been successfully mounted to/mnt/nfs
the directory. -
Automount (optional): If you want the system to automatically mount the NFS share at startup, you can edit
/etc/fstab
the file and add a mount record. Example:server_ip:/path/to/shared/folder /mnt/nfs nfs defaults 0 0
Note: When editing
/etc/fstab
files, make sure to back up the files and operate with caution to prevent errors that may cause system startup problems.
The above steps should help you successfully mount an NFS shared disk in Linux. Make sure you use the correct IP address, shared directory, and local mount point when mounting. If you encounter problems, you can check the system log or mount output to troubleshoot errors.