Setup NFS Server On openSUSE 13.1

by
Share this Article: Facebook0Google+0Twitter10LinkedIn2Reddit0StumbleUpon26

NFS, Network File System, is a server-client protocol used for sharing files between linux/unix to unix/linux systems. With NFS, users can access files on remote systems as if they were stored locally. This tutorial will describe how to setup NFS server on openSUSE 13.1.

Scenario

In this how-to I use two systems. Both systems are running with openSUSE 13.1. Here is the ip address details of my server and client systems.

NFS Server IP Address : 192.168.1.101/24

NFS Client IP Address  : 192.168.1.100/24

Install NFS in Server system

# zypper in nfs-kernel-server

Start NFS service

Enable and Start rpcbind and nfs services.

# systemctl enable rpcbind.service
# systemctl start rpcbind.service
# systemctl enable nfsserver.service
# systemctl start nfsserver.service

Install NFS in Client System

Enter the following command in client to install nfs-client package.

# zypper in nfs-client

Create NFS shares in server

Create a shared directory named ‘/var/unixmen_share’ in server and let the client users to read and write files in that directory.

# mkdir /var/unixmen_share
# chmod 755 /var/unixmen_share/

Export shared directory on NFS Server

Open /etc/exports file,

# nano /etc/exports

Add the nfs share in it.

# See the exports(5) manpage for a description of the syntax of this file.
# This file contains a list of all directories that are to be exported to
# other computers via NFS (Network File System).
# This file used by rpc.nfsd and rpc.mountd. See their manpages for details
# on how make changes in this file effective.

/var/unixmen_share/     192.168.1.0/24(rw,sync,no_root_squash,no_all_squash

Save and close the file.

where,

/var/unixmen_share  - shared directory
192.168.1.0/24        - IP address range of clients
rw                  - Read/Write permission to shared folder
sync                 - Synchronize shared directory
no_root_squash      - Enable root privilege
no_all_squash        - Enable user’s authority

Please be mindful that if you modify the /etc/exports file in future, you run the following command to enable the changes.

# exportfs -a

Now restart rpcbind and nfs services.

# systemctl restart rpcbind.service
# systemctl restart nfsserver.service

Mount NFS shares in client

Go to your client system and Create a mount point to mount the share directory ‘var/unixmen_local’ which we created earlier.

# mkdir /var/nfs_share

By default, openSUSE firewall doesn’t allow remote clients to connect to NFS server.

To allow NFS server to access from the outbound, goto YAST control center -> Security and Users -> Firewall.

openSUSE 12.3 [Running] - Oracle VM VirtualBox_001Navigate to Allowed Services tab. Select NFS Secure Service from Service to Allow drop down box and click add. Finally click Next to allow the nfs service through suse firewall.

openSUSE 12.3 [Running] - Oracle VM VirtualBox_007Now try to mount nfs share.

# mount -t nfs 192.168.1.101:/var/unixmen_share/ /var/nfs_share/

Now the NFS share will be mounted on client systems.

Verify NFS

Verify the server NFS share is mounted in client using following methods.

# df -h

Sample output:

Filesystem                         Size  Used Avail Use% Mounted on
/dev/sda1                          292G  229G   48G  83% /
none                               4.0K     0  4.0K   0% /sys/fs/cgroup
udev                               989M  4.0K  989M   1% /dev
tmpfs                              200M  852K  199M   1% /run
none                               5.0M     0  5.0M   0% /run/lock
none                               998M  244K  998M   1% /run/shm
none                               100M   16K  100M   1% /run/user
192.168.1.101:/var/unixmen_share/  7.6G  4.1G  3.1G  57% /var/nfs_share

Also you can check the NFS shares using mount command.

# mount

Sample output:

[...]
192.168.1.101:/var/unixmen_share/ on /var/nfs_share type nfs (rw,vers=4,addr=192.168.1.101,clientaddr=192.168.1.100)

Automount the NFS Shares

To mount the shares automatically instead of mounting them manually at every reboot, add the following lines shown in bold in the ‘/etc/fstab’ file of client system.

Edit file /etc/fstab,

# nano vi /etc/fstab

Add the following line in it.

[...]
192.168.1.101:/var/unixmen_share/ /var/nfs_share/ nfs rw,sync,hard,intr 0 0

Reboot the client system and check the share. You should see the shares are automatically mounted.

# mount

Sample output:

[...]
192.168.1.101:/var/unixmen_share/ on /var/nfs_share type nfs (rw,vers=4,addr=192.168.1.101,clientaddr=192.168.1.100)

Thats it. Now NFS server is ready to use. Good luck!

For questions please refer to our Q/A forum at : http://ask.unixmen.com/

Share this Article: Facebook0Google+0Twitter10LinkedIn2Reddit0StumbleUpon0