How to mount NFS shared disk in Linux

How to mount NFS shared disk in Linux

In Linux, you can use mountthe command to mount an NFS (Network File System) shared disk. The following are the general steps for mounting an NFS shared disk:

  1. 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
    
  2. 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
    
  3. Mount NFS shared disk: Use mountthe command to mount the NFS share. Assume that the IP address of the remote NFS server is server_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
    
  4. Verify the mount: After executing the mount command, you can use df -hthe command to view the mounted file system and confirm whether the NFS share has been successfully mounted to /mnt/nfsthe directory.

  5. Automount (optional): If you want the system to automatically mount the NFS share at startup, you can edit /etc/fstabthe file and add a mount record. Example:

    server_ip:/path/to/shared/folder /mnt/nfs nfs defaults 0 0
    

    Note: When editing /etc/fstabfiles, 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.

Guess you like

Origin blog.csdn.net/pcb0y/article/details/131916326