Centos Install NFS Server

1 minute read

How to setup NFS Server on CentOS 7

NFS Network File System is a distributed file system protocol originally developed by Sun Microsystems in 1984,[1] allowing a user on a client computer to access files over a computer network much like local storage is accessed. NFS, like many other protocols, builds on the Open Network Computing Remote Procedure Call (ONC RPC) system. The NFS is an open standard defined in Request for Comments (RFC), allowing anyone to implement the protocol.

NFS server and client installation on CentOS 7 http://cn.linux.vbird.org/linux_server/0330nfs.php

SERVER:192.168.12.5
CLIENT:192.168.12.7

Installing NFS Server

    yum install nfs-utils

Once the packages are installed,enable and start NFS services.

    systemctl enable rpcbind
    systemctl enable nfs-server

    systemctl start rpcbind
    systemctl start nfs-server
    systemctl start rpc-statd
    systemctl start nfs-idmapd

Creating NFS Share:

Note: You can also share your existing directory with NFS.

    [root@server ~]# mkdir /nfsfileshare

Allow client servers to read and write on the created directory

    [root@server ~]# chmod -R 777 /nfsfileshare

We have to modify file to make an entry of directory that you want to share

    root@server ~]# vi /etc/exports

    /nfsfileshare 192.168.12.7(rw,sync,no_root_squash)

Configuring Firewall:

    firewall-cmd --permanent --zone public --add-service rpc-bind
    firewall-cmd --permanent --zone public --add-service nfs
    firewall-cmd --reload

Configuring NFS client:

We need to install NFS packages on NFS client-server in order mount remote filesystem, install NFS packages using below command.

    [root@client ~]# yum -y install nfs-utils 

Once the packages are installed, enable and start NFS services.

systemctl enable rpcbind systemctl start rpcbind

Mounting NFS shares on clients:

Before mounting the NFS share, we need to check the available shares on the NFS server. To do that, run the following command on the client-server.

    [root@client ~]# showmount -e 192.168.12.5

    Export list for 192.168.12.5:
    /nfsfileshare 192.168.12.7
    [root@client ~]# mkdir /mnt/nfsfileshare
    Use below command to mount a shared directory /nfsfileshare from NFS server 192.168.12.5 in /mnt/nfsfileshare on client-server.

    [root@client ~]# mount 192.168.12.5:/nfsfileshare /mnt/nfsfileshare


    mount -t nfs -o nosuid,noexec,nodev,rw 192.168.12.5:/nfsfileshare /mnt/nfsfileshare

Categories: ,

Updated:

Leave a Comment