Step 1: Configure the remote server
On the remote server that owns the hard disk contents, perform the following configuration:
-
Install NFS server software:
sudo apt-get update sudo apt-get install nfs-kernel-server
-
Edit the NFS server configuration file
/etc/exports
and add the directories to be shared and their permission settings. For example, to share/data
a directory:/data 192.168.1.0/24(rw,sync,no_root_squash)
Here
192.168.1.0/24
is the client IP range that is allowed to access,rw
indicating read and write permissions,sync
indicating synchronous writing, andno_root_squash
allowing access as the root user. -
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:
-
Install NFS client software:
sudo apt-get update sudo apt-get install nfs-common
-
Create a local mount point, for example
/mnt/remote_disk
:sudo mkdir /mnt/remote_disk
-
Use
mount
the command to mount the remote hard disk. Assume that the IP address of the remote server is192.168.1.100
and the shared directory is/data
:sudo mount -t nfs 192.168.1.100:/data /mnt/remote_disk
-
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:
-
Edit
/etc/fstab
the file and add a line to automatically mount the remote hard drive:192.168.1.100:/data /mnt/remote_disk nfs defaults 0 0
-
Reload
/etc/fstab
the 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_disk
access 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.