Setup nfs server on Amazon Ec23 min read

Prabhin Prabharkaran Administrator
DevOps Engineer

He is a Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!

follow me

The Network File System (NFS) is a client/server application that lets a computer user view and optionally store and update files on a remote computer as though they were on the user’s own computer. The NFS protocol is one of several distributed file system standards for network-attached storage (NAS).

Setup NFS Server

In my case, I have a new EBS volume which is mounted to nfs server on location /backup. I need this volume to be mounted on some of the other servers.

NFS Server: 172.17.30.22
NFS client: 172.17.30.21

Step 1: Install NFS-server packages

yum install nfs-utils

 

Step 2: Create the shared folder and change the permissions

 

mkdir /backup
chmod -R 755 /backup
chown nfsnobody:nfsnobody /backup

Step 3: Create the configuration file which has share details.

vi /etc/exports


/backup    172.17.30.22(rw,sync,no_root_squash,no_all_squash)

In the above case the NFS share will be accessible by 172.17.30.22, if you need your entire network to access the share then change it as given below.

 

/backup    172.17.30.0/24(rw,sync,no_root_squash,no_all_squash)

You can add multiple shares in the same configuration file below is an example

/backup    172.17.30.0/24(rw,sync,no_root_squash,no_all_squash)
/data    172.17.30.0/24(rw,sync,no_root_squash,no_all_squash)

Step 4: Restart the nfs-server service to make the configuration effective.

 

service nfs-server restart

 

Now you have completed the NFS-server share configuration

Setup NFS client

 

Step 5: Install the NFS client package

yum install nfs-utils

 

Step 6: Create a folder where you want to mount the NFS share, In my case I’m going to create a folder called /data

mkdir -p /data

Step 7: Mount the nfs share

mount -t nfs 172.17.30.22:/backup /data

Now execute df -h command to see the disk size with all the mount points

Filesystem            Size  Used Avail Use% Mounted on
devtmpfs              3.7G     0  3.7G   0% /dev
tmpfs                 3.7G     0  3.7G   0% /dev/shm
tmpfs                 3.7G  520K  3.7G   1% /run
tmpfs                 3.7G     0  3.7G   0% /sys/fs/cgroup
/dev/vda1             493G  286G  187G  61% /
172.17.30.22:/backup  493G  383G   85G  83% /backup
tmpfs                 756M     0  756M   0% /run/user/0

 

Step 8: Configure fstab

It is required to configure fstab otherwise once the system rebooted the mounted volume will get unmount. Then you need to mount it again manually. If fstab is configured whenever the system reboots the mount volume will be get mounted back automatically

vi /etc/fstab

 

172.17.30.22:/backup /data nfs defaults 0 0

save and apply. you can test the fstab is working by restart the client machine.

 

 

Happy learning

 

© 2020, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points

Related posts

Leave a Reply