Mount the remote server hard disk through NFS on Debian system

Step 1: Configure the remote server

On the remote server that owns the hard disk contents, perform the following configuration:

  1. Install NFS server software:

    sudo apt-get update
    sudo apt-get install nfs-kernel-server
    
  2. Edit the NFS server configuration file /etc/exportsand add the directories to be shared and their permission settings. For example, to share /dataa directory:

    /data 192.168.1.0/24(rw,sync,no_root_squash)
    

    Here 192.168.1.0/24is the client IP range that is allowed to access, rwindicating read and write permissions, syncindicating synchronous writing, and no_root_squashallowing access as the root user.

  3. Start the NFS service and set it to start at boot:

    sudo systemctl start nfs-server
    sudo systemctl enable nfs-server
    

Step 2: Mount the remote hard drive on Debian

Perform the following operations on the Debian host that needs to mount the remote hard disk:

  1. Install NFS client software:

    sudo apt-get update
    sudo apt-get install nfs-common
    
  2. Create a local mount point, for example /mnt/remote_disk:

    sudo mkdir /mnt/remote_disk
    
  3. Use mountthe command to mount the remote hard disk. Assume that the IP address of the remote server is 192.168.1.100and the shared directory is /data:

    sudo mount -t nfs 192.168.1.100:/data /mnt/remote_disk
    
  4. Verify that the mount is successful:

    df -h   # 查看挂载点是否显示
    

Step 3: Automount Settings

In order to automatically mount the remote hard disk when the system starts, make the following settings:

  1. Edit /etc/fstabthe file and add a line to automatically mount the remote hard drive:

    192.168.1.100:/data /mnt/remote_disk nfs defaults 0 0
    
  2. Reload /etc/fstabthe file using the following command, making sure there are no errors:

    sudo mount -a
    

Now, you have successfully mounted the remote server's hard disk via NFS on the Debian system. You can /mnt/remote_diskaccess the contents of the remote hard drive in the directory. Remember to modify the IP address, directory and permission settings according to your actual situation.

おすすめ

転載: blog.csdn.net/qq_39997939/article/details/132557721