Assuming the nfs server's ip address is 10.20.30.40 and the client is 10.20.30.50.
NFS Server
Install nfs-kernel-server
$ sudo apt update; sudo apt install nfs-kernel-server -y
Start nfs service
$ sudo systemctl start nfs-server
Create the export directory
$ sudo mkdir /sharing
Change permission and ownership of export directory
$ sudo chown nobody.nogroup /sharing
$ sudo chmod 777 /sharing
Allow the export directory to be accessed by client. The options are rw for read write, sync for server to write any change to disk from applying and no_subtree_check to prevent subtree checking
$ echo "/sharing 10.20.30.50(rw,sync,no_subtree_check)" | sudo tee -a /etc/exports
Export the above setting to NFS table of exports
$ sudo exportfs -a
Check if the NFS table of exports has been updated
$ sudo exportfs
/sharing 10.20.30.50
NFS Client
Install nfs-common
$ sudo apt update; sudo apt install nfs-common
Mount the nfs export directory
$ sudo mount 10.20.30.40:/sharing /mnt
Check if client can write to the export directory and the file written, appeared in the server
$ mount | grep nfs
$ touch /mnt/newfile
$ rm /mnt/newfile
To make the mount point permanent, append it to /etc/fstab
$ echo "10.20.30.40:/sharing /mnt nfs4 defaults 0 0" | sudo tee -a /etc/fstab
Test mount from /etc/fstab
$ sudo umount /mnt; sudo mount -a
Start nfs service
$ sudo systemctl start nfs-server
Create the export directory
$ sudo mkdir /sharing
Change permission and ownership of export directory
$ sudo chown nobody.nogroup /sharing
$ sudo chmod 777 /sharing
Allow the export directory to be accessed by client. The options are rw for read write, sync for server to write any change to disk from applying and no_subtree_check to prevent subtree checking
$ echo "/sharing 10.20.30.50(rw,sync,no_subtree_check)" | sudo tee -a /etc/exports
Export the above setting to NFS table of exports
$ sudo exportfs -a
Check if the NFS table of exports has been updated
$ sudo exportfs
/sharing 10.20.30.50
NFS Client
Install nfs-common
$ sudo apt update; sudo apt install nfs-common
Mount the nfs export directory
$ sudo mount 10.20.30.40:/sharing /mnt
Check if client can write to the export directory and the file written, appeared in the server
$ mount | grep nfs
$ touch /mnt/newfile
$ rm /mnt/newfile
To make the mount point permanent, append it to /etc/fstab
$ echo "10.20.30.40:/sharing /mnt nfs4 defaults 0 0" | sudo tee -a /etc/fstab
Test mount from /etc/fstab
$ sudo umount /mnt; sudo mount -a
No comments:
Post a Comment