How to mount the NFS server environment in win7

Source: Internet
Author: User
Tags iptables nfsd

In RH254 summary (4) the establishment of the NFS server in linux introduces the establishment of the NFS server and the mounting of the Linux client. In practical applications, it is possible to mount and access files between windows and linux. In addition to the samba service, NFS can also be used. Currently, mainstream windows OS such as win7 and win2008 have NFS clients by default. You only need to enable them in the system. This document describes how to access the linux NFS server from a windows client.

 

1. Firewall and port (differences between centos6.x and centos7.x)

 

Before proceeding to the topic, complete the port and firewall configuration section in the previous article. In centos, a configuration file/etc/sysconfig/nfs is used to configure some parameter items in nfs. The most modified port is the port running several services. In centos6 and centos5, services such as lockd, rquotad, statd, and mountd run on non-fixed ports and must be specified separately. Common methods are as follows:

# Vim/etc/sysconfig/nfs


Add the following lines

RQUOTAD_PORT = 10001LOCKD_TCPPORT = 10002LOCKD_UDPPORT = 10002MOUNTD_PORT = 10003STATD_PORT = 10004


After the service is restarted, the corresponding configurations on the iptables firewall are as follows:

Iptables-a input-p tcp -- dport 111-j ACCEPT // rpcbind port, both tcp and udp use iptables-a input-p udp -- dport 111-j ACCEPTiptables-a input-p tcp -- dport 2049-j ACCEPT // nfs service port, both tcp and udp use iptables-a input-p udp -- dport 2049-j ACCEPTiptables-a input-p tcp -- dport 10001:10004-j ACCEPT // The ports of the services set above iptables- a input-p udp -- dport 1000:10004-j ACCEPT


In the new release version, the lockd service port is not fixed, and several other service port systems have been added as the preset firmware port. View the/etc/sysconfig/nfs and/etc/services files as follows:

View the/etc/sysconfig/nfs configuration file in centos7 and find the following parts:

# Note: For new values to take effect the nfs-config service # has to be restarted with the following command: # systemctl restart nfs-config # Optional arguments passed to in-kernel lockd # LOCKDARG = # TCP port rpc. lockd shoshould listen on. # LOCKD_TCPPORT = 32803 # UDP port rpc. lockd shoshould listen on. # LOCKD_UDPPORT = 32769


For details, we can compare the file changes in centos6. At the same time, you can find the following parts in/etc/services:

# Cat/etc/servicessunrpc 111/tcp portmapper rpcbind # RPC 4.0 portmapper TCPsunrpc 111/udp portmapper rpcbind # RPC 4.0 portmapper UDPidmaps 1884/tcp # Internet Distance Map Svcidmaps 1884/udp # Internet Distance map Svcnfs 2049/tcp nfsd shilp # Network File Systemnfs 2049/udp nfsd shilp # Network File Systemnfs 2049/sctp nfsd shilp # Network File Systemmountd 20048/tcp # NFS mount protocolmountd 20048/udp # NFS mount protocol


Compared with centos6, the mountd service port is configured as a fixed port. Therefore, the firewall configuration in centos7 is as follows:

 

Firewall-cmd -- permanent -- add-service = mountdfirewall-cmd -- permanent -- add-service = nfsfirewall-cmd -- permanent -- add-service = rpc-bind or firewall-cmd -- permanent -- add-service = nfs -- add-service = rpc-bind -- add-service = mountdfirewall-cmd -- reloadfirewall-cmd -- permanent -- remove-service = nfs -- remove-service = rpc- bind -- remove-service = mountd // delete the corresponding port


However, on centos7, you can also configure ports with different preset values in the/etc/sysconfig/nfs file and/etc/services, such as the top-mentioned continuous Port 10001-10004, you can configure the firewall as follows:

Firewall-cmd -- add-port = 10001-10004/udpfirewall-cmd -- add-port = 10001-10004/tcp


Note: Because the lockd service is not mandatory, I am not using the firewall here. If necessary, you can set it to a fixed port in/etc/sysconfig/nfs, with the exception in firewalld.

 

II. Mount NFS sharing in win7

 

1. Enable nfs mounting in win7

Take windows 7 as an example. Open the control panel and find the program and function. Select NFS client and management tools in windows. After the check box is selected, you need to restart and take effect.

 

 

The LINXU server must note that, in firewalld, the rpcbind, nfs, and mountd services must be configured with exceptions, the following error is reported when Windows 7 is mounted only when the first two commands are used. (in linux client mounting, only the first two services are available after testing. For the sake of standardization, it is recommended that three services be excluded ):

 

# C: \ Users \ Administrator> showmount-e 192.168.1.200RPC: remote system error RPC: Port er fault-RPC: timeout when mountd service is not included in firewalld. # C: \ Users \ Administrator> showmount-e 192.168.1.200 export list in 192.168.1.200:/nfs 192.168.1.0/24


2. Mounting method under win7

 

There are two Mount methods:

 

Mount 192.168.1.200:/nfs x:
Mount \ 192.168.1.200 \ nfs x:


After mounting, you can operate on the remote shared directory like a local disk.

 

3. Write permission issues

 

If you do not set the 777 permission for the shared directory/nfs on the LINUX server or set the owner to nfsnobody: nfsnobody, after Windows 7 is mounted, the write permission is not granted by default (although the rw permission is set on the server ). After checking the mount, the uid and gid mounted by default are-2, as shown below:

 

 

Solution: change the UID and GID to 0 when NFS is mounted on Windows 7. Open the registry: HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ ClientForNFS \ CurrentVersion \ Default. Add two items: AnonymousUid and AnonymousGid, set the value to 0. As shown in the following figure:

 

 

After modifying the registry, restart the computer, and re-mount the file system (you can use the mount command to check that the uid and gid are changed to 0). Then, you can perform read and write operations on the nfs file system under win7.

III. NFS service provided by windows

 

The NFS service is integrated into win2008, so NFS is no longer a Linux patent. This service is not available in the desktop version, but in the winxp era, Microsoft released an sfu package to allow xp to provide the NFS service. Because this package is a very old product, it is not verified in win7.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.