Skip to content

Instantly share code, notes, and snippets.

@craftslab
Last active September 11, 2025 00:25
Show Gist options
  • Select an option

  • Save craftslab/ee8993e8b8d4484a74b0d0d396c21cc6 to your computer and use it in GitHub Desktop.

Select an option

Save craftslab/ee8993e8b8d4484a74b0d0d396c21cc6 to your computer and use it in GitHub Desktop.
nfs config

nfs config

Prerequisites

  • CentOS 8 under WSL2
  • Disable Docker Desktop

Set wsl

cat > /etc/wsl.conf << 'EOF'
[boot]
systemd=true
[user]
default=yourname
[wsl2]
networkingMode=mirrored
autoProxy=true
EOF

Server

# Install packages
sudo dnf update -y
sudo dnf install nfs-utils -y

# Create share
sudo mkdir -p /srv/nfs/shared
sudo chown nobody:nobody /srv/nfs/shared
sudo chmod 755 /srv/nfs/shared

# Configure exports
echo '/srv/nfs/shared *(rw,sync,no_subtree_check,no_root_squash,no_all_squash,insecure)' | sudo tee -a /etc/exports
sudo exportfs -arv

# Start services
sudo systemctl enable rpcbind
sudo systemctl start rpcbind

sudo systemctl enable nfs-server
sudo systemctl start nfs-server

# Check status
sudo systemctl status rpcbind
sudo systemctl status nfs-server
sudo systemctl status rpc-statd
sudo systemctl status nfs-mountd
sudo systemctl status nfs-idmapd
sudo ss -tuln | grep -E ':(111|2049|20048)'
sudo showmount -e localhost
sudo nfsstat -s

# Stop services (optional)
sudo systemctl stop nfs-server rpcbind
sudo systemctl stop rpcbind.socket

Configure static ports (optional)

# sudo nano /etc/sysconfig/nfs
# sudo systemctl restart nfs-server rpcbind
RQUOTAD_PORT=875
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
STATD_PORT=662
STATD_OUTGOING_PORT=2020

Configure version (optional)

# sudo nano /etc/nfs.conf
# sudo systemctl restart nfs-server
[nfsd]
vers4=y
vers3=n
vers2=n

Client

# Install utilities
sudo dnf install nfs-utils -y

# Create mount
sudo mkdir -p /mnt/nfs-share
sudo chmod 775 /mnt/nfs-share

# Test connection
showmount -e NFS_SERVER_IP

# Mount share (vers=4.1 for Ubuntu 24.04)
sudo mount -v -t nfs -o vers=4.0,tcp,noresvport,actimeo=0,nocto,lookupcache=none NFS_SERVER_IP:/srv/nfs/shared /mnt/nfs-share
[general]
[exportfs]
[gssd]
use-gss-proxy=1
[lockd]
port=32803
udp-port=32769
[mountd]
port=20048
[nfsdcld]
[nfsdcltrack]
[nfsd]
vers2=n
vers3=y
vers4=y
vers4.0=y
vers4.1=y
vers4.2=y
[statd]
port=662
outgoing-port=663
[sm-notify]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment