Sync folder with NFS between Linux machine
1 min readMay 27, 2023
There are some use case where you need to access file over the network. One way is to mount it down to the machine.
First of all you need NFS software on both machine
sudo dnf install nfs-utils
This NFS service will communicate over TCP port 2049
If there is a firewall, you need to allow this port.
NFS Server and Client
Then execute it and run server on machine 1
# Machine 1 Server
sudo exportfs -r
sudo systemctl start nfs-server
sudo systemctl status nfs-server
And on the machine 2 you just mount the path
# Machine 2 Client
sudo mount 13.123.123.222:/home/ec2-user/share /mnt
The default mount location is /mnt
but you can specify any path you want.
Enable fs-cache
The make the request faster you can enable cache with flag like below
sudo mount 13.123.123.222:/home/ec2-user/share /mnt -o fsc
Unmount the path
# Machine 2
sudo umount /mnt