1. MagicESP
  2. Ubuntu Server 22.04
  3. Ubuntu Server NFS Mount a Remote Disk

Ubuntu Server NFS Mount a Remote Disk

Synonyms:
  1. NFS

Prerequisite

Mount NFS folder {{ remote_path.value }} of server {{ remote_ip.value }}

config remote server

Login to {{ username.value }} account of server {{ remote_ip.value }}

sudo apt -y install nfs-kernel-server
sudo {{ texteditor.value }} /etc/exports
{{ remote_path.value }}   {{ local_ip.value }}(rw,sync,no_root_squash,no_subtree_check)
sudo /etc/init.d/nfs-kernel-server restart

Enable Incoming Traffic of TCP Port 2049.

config local server

Login to {{ username.value }} account of server {{ local_ip.value }}.

sudo apt -y install nfs-common
sudo {{ texteditor.value }} /etc/fstab

add this line

{{ remote_ip.value }}:{{ remote_path.value }}  {{ local_path.value }} nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800  0  0

or using this one line command

echo '{{ remote_ip.value }}:{{ remote_path.value }}  {{ local_path.value }} nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800  0  0' | sudo tee -a /etc/fstab

mount now and check

sudo mkdir -p {{ local_path.value }}
sudo mount -a
df -h -x devtmpfs -x tmpfs