Linux/nfs

From Omnia
Jump to navigation Jump to search

Restart NFS Client

Stuck nfs:

umount -f -l /nfs-mount

You forced lazy unmount, but now your dmesg is still filled with:

[4321018.374470] nfs: server my-nfs-store not responding, timed out
[4321031.750618] nfs: server my-nfs-store not responding, timed out

Method 1: Flush the Kernel RPC State

sudo systemctl restart nfs-client.target rpcbind

Method 2: Flush the System Inode & Dentry Caches

sudo sync
sudo echo 2 > /proc/sys/vm/drop_caches

Method 3: Temporarily Fake the Network Target (The "Trick" Fix)

# Assign that IP to your loopback interface (should be in the log)
sudo ip addr add <SERVER_IP>/32 dev lo
# wait 30 seconds, for it to get rejected, then..
sudo ip addr del <SERVER_IP>/32 dev lo

Method 4: Clear the Stuck Kernel Threads

sudo systemctl stop nfs-client.target
sudo nfsidmap -c
sudo systemctl start nfs-client.target

Long term fix:

Change /etc/fstab to:

MYNFSSERVER:/shared_dir  /mnt/your_mount_point  nfs  rw,soft,intr,bg,timeo=100,retrans=2  0  0
  • soft: Tells the client to return an I/O error to the application after a timeout, instead of hanging forever.
  • intr: Allows you to interrupt stuck processes (like using Ctrl + C).
  • bg: If the server is offline during a system reboot, Ubuntu will mount it in the background instead of stalling your entire boot process.
  • timeo=100: Sets the timeout to 10 seconds before retrying.

keywords