Linux mount nfs from windows

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

Fedora, CentOS, Fedora Client Packages

Ubuntu, Debian, Mint, Kali Server Packages

After the installation is complete the nfs-server service will be also created automatically.

Fedora, CentOS, Fedora Server Packages

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.

Check NfS Service Status

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.

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 .

Читайте также:  Change mode in linux

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.

List NFS Mounts

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.

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.

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.

How to Mount an NFS Share Using a Windows 10 Machine

By Tony Mackay В· 08 Dec 2016

Mounting an NFS (Network File System) share using a Unix-like operating system is pretty straight forward. But how do you mount an NFS share of a UNIX system from a Windows 10 machine? Keep reading to find out how.

NFS Only Works in Windows 10 Enterprise

Update 2012-04-20 – These instructions should now work on Windows 10 Pro (Version 10.0.14393 and above) as mentioned by EyeDocGeek in the comments.

This tutorial only applies to the enterprise version of Windows 10 because it is the only version which includes the Services for NFS feature. If you don’t have the enterprise version of Windows, then you might be better off exposing your share using Samba which should work on all versions of Windows.

With that said let’s install the Services for NFS feature and mount an NFS share.

Install the NFS Client (Services for NFS)

The first thing we need to do is install the NFS Client which can be done by following the steps below:

Step 1: Open Programs and Features.

Step 2: Click Turn Windows features on or off.

Step 3: Scroll down and check the option Services for NFS, then click OK.

Step 4: Once installed, click Close and exit back to the desktop.

Enable Write Permissions for the Anonymous User

With the default options you will only have read permissions when mounting a UNIX share using the anonymous user. We can give the anonymous user write permissions by changing the UID and GID that it uses to mount the share.

The image below shows the a share mounted using the default settings.

To change the UID and GID we need to make a simple change to the Windows registry by performing the following steps:

  1. Open regedit by typing it in the search box end pressing Enter.
  2. Browse to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default.
  3. Create a new New DWORD (32-bit) Value inside the Default folder named AnonymousUid and assign the UID found on the UNIX directory as shared by the NFS system.
  4. Create a new New DWORD (32-bit”) Value inside the Default folder named AnonymousGid and assign the GID found on the UNIX directory as shared by the NFS system.
  5. Restart the NFS client or reboot the machine to apply the changes.
Читайте также:  Энди эмулятор андроид для windows 10

The output of the mount command should now look like this:

Notice the 0 value applied to the UID and GID. This means the share is mounted using the root user.

How to Mount an NFS Share

Assuming your NAS device is on the same network as your Windows machine and the IP address of the device is 10.1.1.211, the following command will mount a share on the NFS system at /mnt/vms.

The share is now mounted and we can access the data by navigating to the Z: drive.

That’s it, we can now write to the NAS device. Although, I did notice that trying to open the share for the first time takes a long time.

Tony is the founder and editor of GraspingTech, a blog which provides tutorials for Cloud Architects, DevOps Engineers and System Administrators. He has written over one hundred tech tutorials which have been read by more than a million people.

Connect with Tony on LinkedIn or contact him by email.

RootUsers

Guides, tutorials, reviews and news for System Administrators.

How To Mount An NFS Share In Windows Server 2016

Here we’re going to show you how to mount an NFS file share in Windows Server 2016 both temporarily and persistently so that it will automatically mount after a reboot.

There are a couple of different ways this can be done, including mapping a network drive or adding a network location, which we’ll discuss here.

Our NFS Server: In this example we already have an NFS server setup on a CentOS 7 Linux system which is available at 192.168.1.14 and we have exported the /root/nfs directory with NFS. See our guide on creating an NFS server in Linux here if you need information on how to do this.

Install NFS Client

Before we can mount any NFS shares on our Windows server, we must first install the NFS client feature. This can be done through the graphical user interface (GUI) using server manager, however that takes a lot longer so we’ll use some PowerShell.

First we’ll use the Get-WindowsFeature cmdlet to search for available features that contain the string ‘NFS*’ in the Name field.

As we can see NFS-Client is available for install but not currently installed.

Next we use the Install-WindowsFeature cmdlet to install the NFS-Client feature, as shown below.

Once complete we should see that the installation has completed successfully, no reboot is required for this feature, we can begin using it straight away.

Mount NFS Temporarily

We can use the mount command in command prompt to quickly mount our NFS share and confirm that it’s working. Note that the mount command used here is in command prompt rather than PowerShell, using it in PowerShell will fail as it is a different command.

At this point we can browse to “This PC” and we should see the NFS share mounted under Network Locations.

Читайте также:  Windows server 2019 core лицензирование

There is an issue with this however, this mount is not persistent meaning that if we perform a restart of the Windows server it will not be there afterwards. Luckily there are a few ways we can permanently map to the NFS file share.

Mount NFS Persistently

Most of the time we will want our NFS mount to survive a system reboot and mount automatically after boot so that we don’t have to manually mount it every time.

There are a couple of different ways that we can achieve this task:

Map Network Drive

I personally prefer this method, as we can see the space remaining much more easily.

    First open up “This PC” and select Computer from the menu at the top. From here click on Map network drive, as shown below.


The Map Network Drive window will open, select the drive letter that you want to assign to the NFS share, followed by the IP address or hostname of the NFS server as well as the path to the exported NFS directory. Click the Finish button when complete.

You may see a pop up window showing that the connection is being attempted. Once complete the shared NFS folder will open up.
When you view “This PC” you will see the mapped network drive under Network location. This method is better than adding the network location as we’ll discuss next as it clearly shows how much disk space on the NFS share is in use and how much is still available.

Add A Network Location

This will basically create a shortcut to the mounted NFS directory for you to access at any time, it will also be available after restart just like the map network drive method above.

    First open up “This PC” and right click in the white space area and select “Add a network location”.


On the welcome screen click Next to proceed.


Select that you want to choose a custom network location, followed by the Next button.


Enter in two back slashes, followed by the IP address or hostname of your NFS server, followed by the path that is being exported by the NFS server. Click Next once you’ve filled this in.


You can now select a custom name for the network location, click Next once you’ve set one.


To complete the process, simply click the Finish button on the completion screen.


We can optionally open the NFS mount now, or we can browse to “This PC” and see the folder shortcut listed under the “Network locations” setting as shown below.

As mentioned note that this does not show the disk space in use like the network drive mapping option.

Summary

We have shown you how to install the NFS client feature in Windows Server 2016, and then mount an NFS share from a Linux server both temporarily through command prompt with the mount command, and persistently so that the NFS share is mounted automatically after the server has been restarted.

By doing this we can easily access files from a Unix or Linux based operating system over NFS from Windows.

Оцените статью