Monday, January 9, 2017

Linux -- How to mount a Windows Share on Linux using NFS (not CIFS - not SMB)

This blog post will be about mounting Windows shares on Linux Operating Systems.
Actually, I have used this method explained in this post, recently for mounting a Windows Share to a virtualized ODA machine (mounting directly to the Linux ODA Base nodes).
Those who follow me know that I m trying to share unique articles and try to give you the info that can't be easily found on the internet or Oracle Support...
This is also true for this article, although its name sounds quite familiar. I mean, Windows Admins may use it frequently but when it comes to Linux, we are more concantrate on the success of mouting the Windows shares, rather the method that we are using to mount them.
Actually, the main reason that made me writing this post is the hang situation that we have faced when using Windows shares.. (I m talking mounting Windows shares using CIFS , as we have faced sudden and unexpected hang situations using it.)
Another reason is, for mounting the Windows shares on Linux environments, we are using CIFS mostly, so that's why I m writing this post to give you another method for mounting Windows Shares on Linux.

Before going forward, I want to give you the quick definitions of CIFS and NFS.

CIFS (Common Internet File System) is a form of SMB, developed by Microsoft.
Note that: Samba is an implementation of SMB written for UNIX. So Samba allows Unix clients to access CIFS shares. Samba and Smb are two different thing in this manner.
CIFS is used by Windows operating systems for file sharing.
It is based on a Client Server model and it is using TCP/IP.
With CIFS, servers share the storage and clients use or map the storage share.
The most common SMB/CIFS server for Linux is Samba.

NFS is the "Network File System" . NFS was originally developed by Sun and it is often used with Unix operating systems.
NFS has various versions like Nfsv2, v3 and v4. All these versions can use TCP/IP.
Note that, v2 and v3 can use UDP as well.(less protocol overhead than TCP)
With NFS, servers export the storage and clients mount the storage.
The most common Linux NFS server is "nfsd".

Windows Shares supports both CIFS and NFS.
Wel... After this quick info, let's take a look at  what we need to do for sharing our Windows directories using NFS and mounting them on Linux Operating systems.

Fist, we install services for NFS components in our Windows Server.

Click Start, point to Administrative Tools, and then click Server Manager.
In the left pane, click Manage Roles.
Click Add Roles. The Add Roles Wizard appears.
Click Next. The Select Server Roles options appear.
Select the File Server check box and click Next.
The File Server screen appears. Click Next to view the Role Services options.
Select the Services for Network File System (NFS) check box and click Next.
Confirm your selection and click Install.
When the installation completes, the installation results will appear. Click Close.


After we install the services, we share our folder as NFS Service.
Note that, if we just mount the folder (without completing the NFS enablement of our share), we get the error represented in example below:

mount.nfs: mounting 10.34.10.184:/backupca failed, reason given by server: No such file or directory

We open the Share and Storage Management  and click on the Provision Share;


Then we select the folder that we want to share;


We choose NFS for the share protocol, type the name of our share and click Next;


In the NFS authentication window, we just accept the default selections and click Next.


In the NFS Permissions window, we click edit and change permissions to Read-Write. We also check the Allow root access ( not recommended ) checkbox and click Next. (note that, these configuration is just for our specific example, you may do other configurations according to your needs)


As our last work in Windows side, we click Create button in the Review Settings and Create Shared window.



Well.. At this point, our work in Windows side is finished. So, we go to our Linux client and mount the NFS share from Linux using the standard mount commands as shown in the example below;

Mounting NFS share on Linux

We just run command below and mount our Windows Nfs share.

mount -v -t nfs servername:/nfssharename /mountpoint

Example:

mount -v -t nfs 10.34.10.184:/backupca /mnt/


Easy isn't it? 
What about the difference between NFS and CIFS? Which one is better? Which one to use? Which one to use when? 
It is important to mention that, these comparisons should not only be done from the performance perspective but also from the Fault tolerancy and consistency perspectives.
While the main difference seems to be -> "NFS is stateless (except NFSv4) and CIFS is stateful (not stateless)", these questions are all for another topic.. 
But I hope, I have explained what I wanted to explain to you with this post.
If you are interested with the answers of the question above; I suggest you to read the following article;
https://www.kernel.org/doc/ols/2007/ols2007v1-pages-131-140.pdfA New Network File System is Born: Comparison of SMB2, CIFS, and NFS

No comments :

Post a Comment

If you will ask a question, please don't comment here..

For your questions, please create an issue into my forum.

Forum Link: http://ermanarslan.blogspot.com.tr/p/forum.html

Register and create an issue in the related category.
I will support you from there.