Skip to main content
  1. Posts/

How to Set Up NFS Sharing and Mount on Different Platforms—Windows/Linux/Unix

·430 words·3 mins· ·
Xianpeng Shen
Author
Xianpeng Shen
Table of Contents

For example, I have a shared repository for code that’s very large (over 20G). Each product build requires this repository’s code (copying third-party libraries from it). If everyone needs to git clone this third-party repository, the network overhead is very large, git clone takes a long time, and it occupies a lot of physical space.

This can be solved by using NFS sharing.

Additionally, I want this code repository to update automatically. This introduces Jenkins. It checks for code commits to this large repository and automatically executes git pull to update the latest code to the shared server.

What is NFS? NFS (Network File System) is a type of file system supported by FreeBSD that allows computers on a network to share resources. In NFS applications, local NFS clients can transparently read and write files located on a remote NFS server, just like accessing local files. On Windows, this is commonly known as a share.

Setting Up NFS
#

# For example, on Linux, the shared server's IP is 192.168.1.1
sudo vi /etc/exports

# The following is the configuration of my exports file
# Assume the internal network IP range is 192.168.1.1 ~ 192.168.1.250
# ro means read-only
# all_squash means regardless of the user using NFS, their identity will be limited to a specified ordinary user identity (nfsnobody)
/agent/workspace/opensrc 192.168.1.*(ro,all_squash)
/agent/workspace/opensrc dev-team-a*.com(ro,all_squash)
/agent/workspace/opensrc dev-team-b*.com(ro,all_squash)
/agent/workspace/opensrc dev-ci*(ro,all_squash)

NFS Operations
#

Starting the NFS Service
#

To start the NFS service, you need to start both the portmap and nfs services. portmap must be started before nfs.

service portmap start
service nfs start
# Check portmap status
service portmap status

Checking Service Status
#

service nfs status

Stopping the Service
#

service nfs stop

Exporting Configuration
#

After changing the /etc/exports configuration file, you don’t need to restart the NFS service; use exportfs directly.

sudo exportfs -rv

Mounting on Different Platforms
#

Windows
#

# Install the NFS Client (Services for NFS)
# Step 1: Open Programs and Features
# Step 2: Click Turn Windows features on or off
# Step 3: Find and check option Services for NFS
# Step 4: Once installed, click Close and exit back to the desktop. refer to https://graspingtech.com/mount-nfs-share-windows-10/
$ mount -o anon 192.168.1.1:/agent/workspace/opensrc Z:

Linux/Unix
#

# Linux
sudo mount -t nfs 192.168.1.1:/agent/workspace/opensrc /agent/workspace/opensrc

# AIX
sudo nfso -o nfs_use_reserved_ports=1     # should only first time mount need to run this command
sudo mount -F nfs 192.168.1.1:/agent/workspace/opensrc /agent/workspace/opensrc

# HP-UX
sudo mount -F nfs 192.168.1.1:/agent/workspace/opensrc /agent/workspace/opensrc

# Solaris-SPARC
# If you can't execute mount directly from the command line
sudo /usr/sbin/mount -F nfs 192.168.1.1:/agent/workspace/opensrc /agent/workspace/opensrc

Related

Jenkins Multibranch Pipeline
·405 words·2 mins
Discusses the use of Jenkins Multibranch Pipeline to manage multiple branches in a project, enabling parallel builds for pull requests and efficient code review processes.
Jenkins Linux agent configuration
·298 words·2 mins
Provides a step-by-step guide on how to configure a Jenkins Linux agent, including setting up the Java runtime, creating the node, and troubleshooting common issues.
Jenkins Windows agent configuration
·544 words·3 mins
Provides a step-by-step guide on how to configure a Jenkins Windows agent, including setting up the Java runtime, creating the node, and troubleshooting common issues.
Resolving the "Could not read from remote repository" Issue
·597 words·3 mins
Resolving the “Could not read from remote repository” error encountered when cloning code using Git, analyzing the causes, and providing solutions.
Git Commit Squash
·226 words·2 mins
How to squash multiple Git commits into a single commit, both locally and remotely, using interactive rebase and merge strategies in Bitbucket.
A Code Coverage Tool - Squish Coco use examples
·699 words·4 mins
introduction to Squish Coco, a code coverage tool, with examples of how to set it up and use it in Visual Studio for C++ projects.