CentOS server – NFS client/server howto


NFS stands for Network File System and through NFS, a client can read and/or write a remote share on an NFS server (like on local hard disk)

The first step to set up NFS client/server is to [[email protected] ~] nfs-utils and nfs-utils-lib packages on both systems (server and client)

yum [[email protected] ~] nfs-utils nfs-utils-lib chkconfig --levels 235 nfs on  service nfs start

For example, the server IP is and the client

I’d like to use /test and /var/test directories from the client system. To make them accessible we must “export” them on the server.

From the client system, the NFS share is usually accessed as the user “nobody”. If the directory isn’t owned by nobody, the read/write access from NFS client should be made as root.
In this howto, the /test dir will be used as root while the /var/test will be used as “nobody”. If /var/test directory doesn’t exist, create the dir and change the ownership to the user/group 65534 (nonexistant user/group).

mkdir /var/test chown 65534:65534 /var/test

The next step (on the server side) is to modify /etc/exports

nano /etc/exports

and add the next lines

/test ,sync,no_root_squash,no_subtree_check) /var/test,sync,no_subtree_check)

The no_root_squash parameter means access dir as root (all files copied/created from client will be owned by root).

After you modify /etc/exports, run exportfs -a to make the changes effective.

exportfs -a

The next step (on the client side) is to create the directories where you want to mount the NFS shares

mkdir -p /mnt/test mkdir -p /mnt/var/test

Mount NFS shares with

mount /mnt/test mount /mnt/var/test

Verify the settings with:

df -h

The result should be something like

[[email protected] ~]# df -h Filesystem            Size  Used Avail Use% Mounted on ....    100G  25G   75G  25% /mnt/test                        100G  25G   75G  25% /mnt/var/test



The result should be something like

[[email protected] ~]# mount .... on /mnt/test type nfs (rw,addr= on /mnt/var/test type nfs (rw,addr=

To mount the NFS shares at boot time, add the next lines in /etc/fstab file  /mnt/test   nfs      rw,sync,hard,intr  0     0  /mnt/var/test   nfs      rw,sync,hard,intr  0     0

Don’t forget to check the settings after reboot


You might also like More from author