- Nfs mount windows share to linux
- Share files with NFS Ubuntu server and Windows 10 client
- Table of Contents
- 1. Installation and configuration in Ubuntu or Debian as a server
- 1. Drive options
- 2. Client installation and configuration in Windows 10
- 1. Mounting the network drive
- 2. Write permissions for the anonymous user
- How To Mount NFS Share In Linux and Windows?
- Install NFS Server
- Ubuntu, Debian, Mint, Kali Client Packages
- Fedora, CentOS, Fedora Client Packages
- Ubuntu, Debian, Mint, Kali Server Packages
- Fedora, CentOS, Fedora Server Packages
- Check NFS Service Status
- Start NFS Service
- Create NFS Share
- Enable Exports
- Mount NFS Share For Linux
- List NFS Mounts
- Unmount NFS Share For Linux
- Mount NFS Share For Windows
Nfs mount windows share to linux
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:
We open the Share and Storage Management and click on the Provision Share;
Share files with NFS Ubuntu server and Windows 10 client
In this short guide I will talk about how to mount a shared drive that is in an Ubuntu or Debian installation that will be the server with the NFS (Network File System) drive, on a network drive accessible from Windows 10 who will play the role of client.
Table of Contents
1. Installation and configuration in Ubuntu or Debian as a server
In the case of Debian, remove sudo in each command (it can even be executed the same).
Install the package «nfs-kernel-server»:
sudo apt install nfs-kernel-server
1. Drive options
Then we edit the file /etc/exports with nano or with the editor of our preference:
The file contains comments such as the following:
# /etc/exports: the access control list for filesystems which may be exported # to NFS clients. See exports(5).
We add a line at the end with the following:
/home/user/folder 192.168.0.10(rw,sync,all_squash,anonuid=1000,anongid=1000)
In the example above:
/home/user/folder it is the folder that will be shared by the network.
192.168.0.10 it is the IP of the client or clients that access the network resource. Only a static IP is shown, but we can use 192.168.0.1/24 to match between 192.168.0.1 and 192.168.0.254.
Mount options are in parentheses.
- rw: allow reading and writing.
- sync: is optional in case we want a little more file integrity and avoid data loss, sacrificing a bit of performance.
- all_squash: downgrades the permissions of the files created from the client to the nobody user. For example, if in Windows 10 I am logged in as Administrator and created a new file, it will belong to user nobody.
- anonuid: is the ID of the nobody user, or whatever user we want.
- anongid: is The group ID of the user nobody.
In this case I set anonuid and anongid to 1000 , which is the user who owns the folder, /home/user/folder to preserve execute and write permissions.
With the changes made we save the file CTRL + O , then Enter , and then we close with CTRL + X , this only if we use the nano editor from the terminal.
We restart the NFS server:
sudo service nfs-kernel-server restart
With this, the configuration on the server will be ready, any error that appears when restarting is necessary to check the configuration and obviously the description of the error.
2. Client installation and configuration in Windows 10
Windows comes with a default client, but it needs to be installed, the only detail is that I don’t remember if it is available in the Windows 10 Home version.
The easiest way to install it is to use the search bar and type Control Panel, because Windows 10 has several modern panels that hide the older options. Open Programs › Programs and Features and in the left panel we open Turn Windows features on or off.
Mark the box Service for NFS with his two descendants Client for NFS and Administrative Tools. We click on OK and after some time the client will be installed.
1. Mounting the network drive
To mount the unit, we open the cmd (do not use PowerShell). We use the command:
mount -o anon \\192.168.0.20\home\user\folder k:
The IP 192.168.0.20 is the server, followed by the shared folder and one drive letter that will be used. It is important to use the real full path of the resource as if we were personally on the server with the folder /home/user/folder, otherwise it won’t work. I have tried hiding the part of the path when mounting the drive, but it is a complicated process and not worth the extra effort.
The message, The command completed successfully. will indicate that everything is working properly.
2. Write permissions for the anonymous user
Normally and by default, Windows does not allow writing to this type of drives with the anonymous user. To enable writing, we have to open the Windows registry Regedit, and we headed towards: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default .
There we will create a DWORD (32-bit) Value with the name AnonymousUid with the value of 0 with Base Decimal. Then create a DWORD (32-bit) Value with the name AnonymousGid with the value 0 with Base Decimal.
We have to restart the computer or the service Client for NFS, we can find it in the task manager in the Services tab.
If we follow all the previous steps, and we already have the unit mounted, we open the CMD and execute the command mount , the mount will appear and in properties it will show UID=0 y GID=0 . If any other number appears, check the entire procedure above.
Notes: The procedure is practically the same in both Ubuntu and Debian, or any other variation like Kubuntu. No need to use Ubuntu Server. The NFS version to be used is 3 with Ubuntu 18.04 — 64-bits and Windows 10.
How To Mount NFS Share In Linux and Windows?
Network File System or NFS is a network-based filesystem protocol which is mainly used to share files and folders over the network. NFS is a UNIX based technology but can be used by most of the operating systems like Linux, Ubuntu, Debian, Kali, Mint, Fedora, CentOS, RedHat and Windows operating systems Windows 7, Windows 8, Windows 10, Windows Server 2008, Windows Server 2012, Windows Server 2016.
Install NFS Server
NFS packages mainly divided into two parts. First is the server side packages which will install related kernel modules and server tools.
Ubuntu, Debian, Mint, Kali Client Packages
$ sudo apt-get install nfs-common
Fedora, CentOS, Fedora Client Packages
$ sudo yum install nfs-utils
Ubuntu, Debian, Mint, Kali Server Packages
$ sudo apt-get install nfs-kernel-server
After the installation is complete the nfs-server service will be also created automatically.
Fedora, CentOS, Fedora Server Packages
$ sudo yum install nfs-utils
Check NFS Service Status
As the NFS shares will be served over nfs-server we need to the if it is working. We will use systemctl status command with the nfs-server service name.
$ sudo systemctl status nfs-server
We can see that the service is active and working properly.
Start NFS Service
If the service is not started or stopped in any way we need to start the nfs-server service. We will use systemctl start command with the nfs-server service name like below.
$ sudo systemctl start nfs-server
Create NFS Share
NFS main configuration is stored in the /etc/exports file. Each share is created line by line. For example, if we want to share /mnt with the IP address 192.168.10.10 we will use the following configuration.
But generally, we share the files and folders with everyone who has access to the NFS server. We can use the following configuration to share everyone.
Enable Exports
After creating the share configuration we need to refresh the NFS table where the shares are stored. We can simply use exportfs command with the -a option which will add current configuration to the NFS table.
Mount NFS Share For Linux
We can use mount command in order to mount NFS share. We will specify the filesystem type as nfs to the mount command with the -t option like below. The server IP address is 192.168.142.144 and share is /mnt . We will mount to the /home/ismail/poftut1 .
$ sudo mount -t nfs 192.168.142.144:/mnt /home/ismail/poftut1/
List NFS Mounts
After mounting the NFS share we can check it by listing the NFS mount. We will use mount command and filter NFS shares with the grep command like below.
Unmount NFS Share For Linux
We can unmount already mounted NFS shares with the umount command. We will just specify the mount path to the umount command with the sudo command like below.
$ sudo umount /home/ismail/poftut1
Mount NFS Share For Windows
First, we will enable NFS modules or features on Windows operating systems. Open Start > Control Panel > Programs. Select Turn Windows Features on or off. Select Services for NFS. Click OK.
We can mount NFS shares in Windows operating systems too. We will use mount command. We will also provide nolock option and other parameters like remote NFS server IP address and local drive which is Z in this case.
> mount -o nolock 192.168.142.144:/mnt z:
Alternatively, we can use net use command which can also mount NFS shares. We will provide the partition name which is z and remote NFS server.
> net use z: \\192.168.142.144\mnt