I've recently had to deal with a pesky, intermittent NFS client/server hung mount point issue. When the problem occurs on the client I cannot unmount, along with some other odd behavior. The only immediate resolution I have to date is to reboot the client box.
But shutdown -r now
does not work at all. I've since discovered reboot -f
, which does reboot the system. Why? I've read the man pages but nothing seems to answer my question.
Why Does shutdown -r now
behave differently than reboot -f
?
(I'm continuing to resolve the NFS issue, but that is not my question here.)
From the shutdown man page:
init
starts and stops jobs as the system changes runlevels. When entering runlevel 6 due to a reboot, the system runs all the scripts in /etc/rc6.d. Since your system is not responding toshutdown
, it's likely a script in/etc/rc6.d
(possiblyK05nfs-common
given your NFS issues) is stuck, not allowing the shutdown sequence to finish. In fact, the last thing init runs when changing to runlevel 6 isreboot -d -f -i
.reboot -f
skips all the scripts and reboots the system directly.shutdown
instructsinit
to begin the shutdown procedure, which involves letting logged in users know that the system is shutting down, killing all the processes gracefully, unmounting and syncing drives, and so on. You're getting hung up here because processes stuck waiting for IO tend to be very hard to kill, and your stuck NFS mount can't be unmounted.reboot -f
, on the other hand, immediately reboots the server without doing any of that. (reboot
is the programinit
calls to shut down the server. Without the-f
flag, it will check to see ifinit
thinks it is currently rebooting, and if not, it will callshutdown
instead to start the process).Because 'reboot -f' does not go into runlevel 0 - it tells the OS to reinitialise the CPU directly. Man page on my nearest Linux box says:
The shutdown man page explains more.
If you use the
intr
option on your NFS mounts, thenshutdown -r now
should be able to kill processes waiting on NFS IO to complete. This may result in file corruption, but likely no more thanshutdown -f
creates.