Ubuntu 18.04重启后NFS Kernel Server active(exited)状态故障求助
Hey, let's figure out why your NFS service is acting up after the server reboot. That active (exited) status from systemctl status nfs-kernel-server tells us the startup script ran without errors, but there's no persistent daemon keeping the service running in the background. That's why it looks like it's stopped even though systemd marks it as "active". Let's walk through diagnosing and fixing this step by step.
先做基础排查
Start with these checks to pinpoint the root cause:
- Verify dependent RPC services: NFS relies on
rpcbindandrpc-mountdto function properly. Check their status with:
If either showssystemctl status rpcbind systemctl status rpc-mountdinactiveorfailed, that's likely the culprit. - Check exports configuration for errors: A broken
/etc/exportsfile can prevent NFS from loading correctly. Run these commands to validate and reload the config:
If there's a syntax error (like missing commas, invalid permissions flags, or typos),exportfs -v exportfs -rexportfswill throw an error message pointing you to the issue. - Check NFS port listening: Use
ssto see if NFS-related processes are actually listening on ports:
You should see entries forss -tulpn | grep nfsrpc.nfsdif it's running properly. - Dig into detailed logs: Use journalctl to get more context about what's happening during service startup:
Look for any warning or error messages that might have been missed in the status output.journalctl -u nfs-server.service --since "10 minutes ago"
针对性修复方案
Based on the above checks, here are fixes for the most common issues:
1. RPC Mountd service is inactive or failed
If rpc-mountd isn't running, start it up and ensure it launches on boot:
systemctl start rpc-mountd systemctl enable rpc-mountd systemctl restart nfs-kernel-server
Then recheck the NFS service status—you should see active (running) now.
2. Invalid exports configuration
Fix any syntax errors in /etc/exports (like incorrect permission flags, missing brackets, or invalid client addresses). For example, a valid entry looks like:
/var/nfs/share *(rw,sync,no_subtree_check,no_root_squash)
After fixing, reload the config and restart the service:
exportfs -r systemctl restart nfs-kernel-server
3. rpc.nfsd didn't initialize properly
Sometimes the rpc.nfsd daemon fails to register itself during startup. Manually start it with a thread count (8 is a common default) then restart the service:
rpc.nfsd 8 systemctl restart nfs-kernel-server
4. Service dependency ordering issue
If systemd is starting NFS before its dependent services are ready, you can adjust the service file to enforce correct ordering:
- Open the NFS service file for editing:
nano /lib/systemd/system/nfs-server.service - Ensure the
Afterline includes bothrpcbind.targetandrpc-mountd.service:After=network.target rpcbind.target rpc-mountd.service - Reload systemd and restart the service:
systemctl daemon-reload systemctl restart nfs-kernel-server
验证修复
Once you've applied a fix, confirm everything is working:
- Run
systemctl status nfs-kernel-server—the Active line should showactive (running). - List the exported shares locally with:
You should see all your configured NFS shares listed.showmount -e localhost - Test from a client machine by mounting the share and verifying you can read/write to it.
内容的提问来源于stack exchange,提问作者user9492428

