Introduction:-
NFS stands for Network File System. NFS protocol used for sharing files between computer network. NFS allowes to mount files on remote computer as well as on local computer. For NFS server the server machine and client machine both are must be Linux OS, NFS does not support Windows machine because Windows is not NFS compatible. The NFS server shares one or more directories to client system.
Requirements:-
- Package = nfs
- Service = nfs
- Port No. = 2049
- Configuration File = /etc/exports
Per quest:-
- Configure Server IP = 192.168.1.1
- Configure Client IP = 192.168.1.2
- Confiugre Server Hostname = server.rootuser.in
- Configure Client Hostname = client.rootuser.in
- Firewall must be disabled.
1] Install required package
[root@server ~]# yum install nfs* -y
2] Create one new directory to share it using NFS server
[root@server ~]# mkdir /data
[root@server~]# cd /data
[root@server data]# touch anup1 anup2 anup3 anup4 anup5
[root@server data]# cd
3] Grant full permissions to data directory.
[root@server ~]# chmod 777 /data
4] Open main configuration file i.e. /etc/exports and share /data directory to 192.168.1.0 network
[root@server~]# vim /etc/exports
/data 192.168.1.0/255.255.255.0(rw,sync) #Here rw means r for read & w for write
#You can allow data directory to specific IP als.
/data 192.168.1.50/255.255.255.0(rw,sync)
#You can insert entry for data directory by following way
/data *(rw,sync)
/data *(ro,sync)
/data client.rootuser.in(rw,sync) #Share directory using Hostname
:wq
5] Now start NFS service
[root@server ~]# service nfs start
[root@server ~]# chkconfig nfs on
6] Update exports file entries
[root@server ~]# exportfs -r
NFS Client Side:-
1] Check communication with NFS Server
[root@client ~]# ping 192.168.1.1
2] Check NFS server exports list
[root@client ~]# showmount -e 192.168.1.1
3] Create mount point to mount shared directory
[root@client ~]# mkdir /testnfs
4] Now mount shared directory.
[root@client ~]# mount -t nfs 192.168.1.1:/data /testnfs
[root@client ~]# cd /testnfs
[root@client testnfs]# ls
[root@client testnfs]# cat > testfile
This is test file from client.
^d
[root@client testnfs]# cd
[ Note = In this way you can use shared directory. But this directory will be available till system is up, it will not availabe after system reboot. To keep it available after reboot use following way: ]
[root@client ~]# vim /etc/fstab (Go to end of the file and make following entry)
192.168.1.1:/data /testnfs nfs defaults 0 0
:wq
[root@client ~]# mount -a
[ Reboot computer using reboot command and check /testnfs directory]
No comments:
Post a Comment