Skip to main content

Mounting NFS

Cách kết nối một folder từ máy có nfs server tới máy linux hiện. 

Dữ liệu của máy trên server nfs sẽ được ưu tiên mount vào. Có nghĩa là bạn mount vào folder mà có files thì coi chừng mất sạch mấy files đó. 

Cài NFS common cho Client

sudo apt update

sudo apt install nfs-common

 

df -h

cd /mnt

sudo mkdir anything

sudo mount 192.168.1.111:/other/2025/things/ /mnt/anything/

sudo chmod 777 /mnt/anything/

sudo nano /etc/fstab

Thêm vào

192.168.1.111:/other/2025/things/ /mnt/anything nfs defaults 0 0

df -h

umount 192.168.1.111:/other/2025/things/

Cài NFS cho server

sudo apt update

sudo apt install nfs-kernel-server

sudo chown nobody:nogroup /mnt/my-nfs-folder/

sudo chmod 777 /mnt/my-nfs-folder/

sudo nano /etc/exports

# insert
/mnt/my-nfs-folder/ 192.168.0.0/24(rw,sync,no_subtree_check)



sudo exportfs -a

sudo systemctl restart nfs-kernel-server