Creating an NFS Shared Directory on ECS
- Linux
- CentOS, SUSE, EulerOS, Fedora, or openSUSE
- Configure a YUM repository.
1. Create a file named euleros.repo in the /etc/yum.repos.d directory. Ensure that the file name must end with .repo.
2. Run the following command to enter euleros.repo and edit the configuration:
vi /etc/yum.repos.d/euleros.repoThe EulerOS 2.0 SP3 YUM configuration is as follows:
[base]name=EulerOS-2.0SP3 basebaseurl=http://repo.cloud.com/euler/2.3/os/x86_64/enabled=1gpgcheck=1gpgkey=http://repo.cloud.com/euler/2.3/os/RPM-GPG-KEY-EulerOSThe EulerOS 2.0 SP5 YUM configuration is as follows:
[base]name=EulerOS-2.0SP5 basebaseurl=http://repo.cloud.com/euler/2.5/os/x86_64/enabled=1gpgcheck=1gpgkey=http://repo.cloud.com/euler/2.5/os/RPM-GPG-KEY-EulerOSNoteParameter description
name: repository name
baseurl: URL of the repository
- HTTP-based network address: http://path/to/repo
- Local repository address: file:///path/to/local/repo
gpgcheck: indicates whether to enable the GNU privacy guard (GPG) to check the validity and security of RPM package resources. 0: The GPG check is disabled. 1: The GPG check is enabled. If this option is not specified, the GPG check is enabled by default.
3. Save the configurations.
4. Run the following command to clear the cache:
yum clean all - Run the following command to install nfs-utils:yum install nfs-utils
- Create a shared directory.
When you open /etc/exports and need to create shared directory /sharedata, add the following configuration:
/sharedata 192.168.0.0/24(rw,sync,no_root_squash)
Note- The preceding configuration is used to share the /sharedata directory with other servers in the 192.168.0.0/24 subnet.
- After the preceding command is run, run the exportfs -v command to view the shared directory and check whether the setting is successful.
- Run the following commands to start the NFS service:systemctl start rpcbindservice nfs start
- Create another shared directory.
For example, to create the /home/myself/download directory, add the following configuration to /etc/exports:
/home/myself/download 192.168.0.0/24(rw,sync,no_root_squash)
Restart the NFS service.
service nfs restartAlternatively, run the following command without restarting the NFS service:
exportfs -rv - (Optional) Enable automatic startup of the rpcbind service.
Run the following command:
systemctl enable rpcbind
- Configure a YUM repository.
- Ubuntu
- Run the following commands to install nfs-kernel-server:sudo apt-get updatesudo apt install nfs-kernel-server
- Create a shared directory.
When you open /etc/exports and need to create shared directory /sharedata, add the following configuration:
/sharedata 192.168.0.0/24(rw,sync,no_root_squash)
NoteThe preceding configuration is used to share the /sharedata directory with other servers in the 192.168.0.0/24 subnet.
- Start the NFS service.service nfs-kernel-server restartNote
After the preceding command is run, run the exportfs -v command to view the shared directory and check whether the setting is successful.
- Create another shared directory.
For example, to create the /home/myself/download directory, add the following configuration to /etc/exports:
/home/myself/download 192.168.0.0/24(rw,sync,no_root_squash)
Restart the NFS service.
service nfs restartAlternatively, run the following command without restarting the NFS service:
exportfs -rv
- Run the following commands to install nfs-kernel-server:
- CentOS, SUSE, EulerOS, Fedora, or openSUSE
- Windows
- Install the NFS server.
Paid software: haneWIN. Download the software at the haneWIN official website.
Free software: FreeNFS and WinNFSd. Download the software at the SourceForge website.
- Enable the NFS function.
- In the case of WinNFSd, see WinNFSd configuration.
- Download and decompress WinNFSd, and create the nfs folder in the decompressed directory.
- Set the sharing and read/write permissions on the nfs file.
- Right-click the nfs file and choose Properties.
- Click the Sharing tab, and then click Share....
- Add Everyone and click Share.
Figure 1 Adding Everyone
- Click the Security tab, select Everyone in the Group or user names list, and click Edit.
- In the displayed Security dialog box, select Everyone from the Group or user name list, select Read and Write from the Allow check boxes in the Permissions for Everyone list, and click OK.
- Disable all firewalls, including the Domain network, Private network, and Public network. Enable them after the entire configuration is complete.
- Log in to the virtual server of the router and enable ports 111, 2049, and 1058 of the external network. (Note: An external IP address is required.)
- Run the following command. For details, see https://github.com/winnfsd/winnfsd.WinNFSd.exe -addr {Your own local IP address 192.168.xxx.xxx} F:\nfs /nfs
- In the case of haneWIN, perform the following steps:
- Run the downloaded .exe file as the Windows system administrator.
- After the installation is complete, open the NFS Server file and choose Edit > Preferences.
- Retain the default settings on the NFS, Server, and PortMapper tab pages. Click the Exports tab, click Edit exports file to configure the shared directory, and click Save.Note
The shared directory format can be referenced as D:\share -public -name:nfs, which means to set the permission on the share folder to public and define an alias nfs.
- Click OK.
- Disable all firewalls, including the Domain network, Private network, and Public network. Enable them after the entire configuration is complete.Note
Run the following command in Linux to mount the directory and check whether the file sharing is successful:
mount -t nfs -o nolock 192.168.xxx.xxx:/nfs /mnt- 192.168.xxx.xxx is the IP address of the Windows operating system.
- nfs is the alias created when the shared directory is configured.
- /mnt is the local directory where the remote directory is mounted.
- In the case of WinNFSd, see WinNFSd configuration.