Linux and Windows implement mounting NFS

Article directory

  • 1. Windows mount NFS
  • 2. Mount NFS on linux
    • Error reporting and resolution
      • There are two main areas to check: 1. Whether the client is installed; 2. Whether the protocol is defined -o nfsvers=3/4
  • 3. How to use NFS after successful connection
  • 4. Unmount the NFS share
  • 5. How to add clients to the NFS server on Windows Server that are allowed to access NFS shared storage again

1. Windows mount NFS

The following are the standard steps to mount an NFS share on Windows:

  1. Enable NFS client:
    In Windows Features, make sure “Services for NFS” or “NFS Client” (the name may differ depending on the Windows version) is installed.

  2. Mount NFS share:
    Use the mount command to mount the share. Here is a simplified command structure:

    mount [NFS server]:/[path] [local drive letter]:
    

    Therefore, based on the above structure, the following examples are given:

    mount 192.168.50.111:/WINSERVER2022-NFS F:
    

This command attempts to mount a remote NFS share locally. Note that in Windows, mount.exe is not used to mount NFS shares. In order to mount NFS on Windows, you usually need to make sure you have an NFS client installed.

  1. If there are additional parameters or special needs (such as specific mount options), make sure to add them correctly.

Finally, please make sure that your firewall and network settings allow NFS communication, and that the NFS server is configured correctly and has permissions set. If a problem occurs, remember to check the NFS server and client logs to help diagnose the problem.

2. linux mount NFS

mount -t nfs -o nfsvers=3 192.168.50.9:/WINSERVER2022_NFS /data/backup

Error reporting

mount: wrong fs type, bad option, bad superblock on 192.168.50.111:/WINSERVER2022-NFS,
 missing codepage or helper program, or other error (for several filesystems (e.g. nfs, cifs) you
 might need a /sbin/mount.<type> helper program)In some cases useful info is found in syslog -
  try dmesg | tail or so.

There are two main areas to check: 1. Whether the client is installed; 2. Whether the protocol is defined -o nfsvers=3/4

 This error message indicates that the system cannot mount the NFS share. There may be multiple reasons for this problem. Here are some possible solutions:
  1. Check NFS server configuration:

    • Make sure the share path and permissions on the NFS server are configured correctly. You need to make sure you have permission to access the share and that the NFS server is set up correctly. Check the NFS server’s configuration file (usually /etc/exports) to ensure that the share path is configured correctly.
  2. Check if the NFS server is running:

    • Make sure the NFS server is running and the service has not crashed. You can check the status of the NFS server using the following command:
      systemctl status nfs-server
      
  3. Check NFS client packages:

    • Make sure you have the NFS client package installed on your Linux system. Typically, it’s called nfs-common or something similar. You can install it using a package manager, for example:
      sudo apt-get install nfs-common # For Debian/Ubuntu
      sudo yum install nfs-utils # For CentOS/RHEL
      
  4. Check file system type:

    • Make sure you are using the correct file system type -t nfs. NFS shares should use the NFS file system type. If the file system type used is correct, try unmounting the share and then remounting it.
  5. Check firewall settings:

    • Firewall settings may affect NFS mounts. Make sure the firewall allows NFS communication. You can temporarily disable the firewall for testing purposes and reconfigure it once the problem is identified.
  6. View system log:

    • Use dmesg | tail or cat /var/log/syslog to view the system log to get more details about the error. This may provide more clues about the problem.
  7. Confirm that the NFS server and client versions are compatible:

    • Make sure that the NFS protocol versions used by the NFS server and client are compatible. You can try specifying the NFS version in the mount command, such as -o vers=3 or -o vers=4, to force the use of a specific NFS version.

Depending on your specific situation, one or more of these steps may resolve your NFS mount issues. When troubleshooting a problem, make sure to double-check each step to find the root cause.

3. How to use NFS after successful connection

Once you successfully connect to the NFS share, you can use it just like accessing local files. Here are some basic ways to use NFS shares:

  1. Browse NFS shares:

    • Open the local drive you mounted (F: in your example).
    • You should be able to see the files and folders on the NFS server as if they were local.
  2. Copy and move files:

    • You can use Windows Explorer (File Explorer) to copy, cut, and paste files or folders just like on a local drive.
  3. Edit file:

    • You can use a local text editor or application to edit files on the NFS share. As long as you have the appropriate permissions, you can edit.
  4. Run the application:

    • If there are executable files on the NFS share, you can run them, provided you have execute permissions.
  5. Backup and recovery:

    • You can use an NFS share to back up files and copy files to an NFS share for secure storage. Later, you can restore files from the NFS share.

Remember, the success of NFS operations depends on whether you have the appropriate permissions, the configuration of the NFS server, and the stability of the network connection. If you encounter any problems using NFS shares, you can check the NFS server and client logs for more information.

4. Uninstall NFS share

Unmount the NFS share: When you no longer need to access the NFS share, you can use the umount command to unmount it:
mount first check what mount paths there are

sudo umount /mnt/nfs_share

For windows use:

net use D: /delete

Please replace the drive letter (D:) in the mount command with the actual mount drive letter. You can execute the net use command to obtain the mounting drive letter.
Execute the net use * /delete command to manually uninstall all mounted file systems in the Windows system.
Execute the net use * /delete /y command to automatically uninstall all mounted file systems in the Windows system.

Optional: Cancel the automatic mounting file system configuration.
If you have configured an automatic mounting script for an SMB or NFS file system and need to restart the server, you also need to delete or modify the automatic mounting script and cancel automatic mounting of the file system at startup.

  • SMB file system automatic script: auto_mount.bat
  • NFS file system automatic script: nas_auto.bat

Execute the net use command to view the uninstallation results.
If the SMB file system information you mounted is not found in the command output, it means that the file system directory has been successfully unmounted.

5. How to add a client to the NFS server on windowsserver that is allowed to access NFS shared storage

To add clients again that are allowed to access NFS shared storage on Windows Server, you need to modify the access control list (ACL) of the NFS share. Here are the general steps to do this on Windows Server:

  1. Open sharing and storage management:

    • On Windows Server, open Server Manager.
  2. Navigate to sharing and storage management:

    • In Server Manager, select File and Storage Services.
  3. Select NFS share:

    • Under File and Storage Services, select Shares.
  4. Find and edit NFS shares:

    • Find the NFS share you want to modify access permissions for, right-click the share and select “Properties”.
  5. Edit shared properties:

    • In the share properties window, select the NFS Share Permissions tab.
  6. Edit access control lists:

    • In the “NFS Share Permissions” tab, you can view and edit the ACL of the NFS share. This is where you control which clients can access the share.
  7. Add or modify ACL entries:

    • In the ACL list, you can add or modify entries for clients that allow or deny access. To add a new client, click the Add button and enter the client’s IP address or hostname. Next, choose to allow or deny access for this client.
  8. Save changes:

    • After you finish adding or modifying ACL entries, be sure to save your changes.
  9. Apply changes:

    • After saving, close the properties window. You may need to restart the NFS share service or perform other operations to apply the changes.

Please note that the specific interface and options may vary depending on your Windows Server version and configuration. Be sure to review the Windows Server documentation carefully to learn how to manage ACLs for NFS shares in your specific environment. Also, make sure to be careful when adding or modifying ACLs to prevent unwanted access or security issues.