# emergency shell on reboot/shutdown



## cbrace (Feb 11, 2019)

Hi all,

I am running v11.2 on an old HP Microserver that serves as a simple filesharing server on my LAN. Works just fine. Just one thing: when I issue a shutdown or reboot command, the system drops into an emergency shell after the normal daemon shutdown and file system unmount process has (more or less) completed. I have no clue why this is happening. If I type "reboot" the system reboots as normal, but obviously this is not convenient to do every time.

On reboot, the system restarts fine, no interventions required.

Any thoughts on why this is happening?


----------



## olli@ (Feb 11, 2019)

By default, shutdown(8) drops to a single-user shell after the shutdown is done (i. e. after stopping daemons etc.). If you want to reboot, you must supply the `-r` option. If that doesn't work for some reason, you can also try `-ro`.

If your problem is different, please provide a complete transcript of what you type and what messages are printed (e. g. a screenshot).


----------



## SirDice (Feb 11, 2019)

cbrace said:


> Works just fine. Just one thing: when I issue a shutdown or reboot command, the system drops into an emergency shell after the normal daemon shutdown and file system unmount process has (more or less) completed.


This can happen if a daemon refuses to shutdown in a timely manner. There's typically a reason printed why it's dropping to single user mode though.


----------



## olli@ (Feb 11, 2019)

SirDice said:


> This can happen if a daemon refuses to shutdown in a timely manner. There's typically a reason printed why it's dropping to single user mode though.


Are you sure the system goes to single-user if that happens? I think that's not quite correct.

If /etc/rc.shutdown exceeds the timeout setting (90 seconds by default), then it is forcibly terminated, and then the system reboots anyway. Otherwise it would be unreliable and risky to reboot a remote system.

Also see the section on `rcshutdown_timeout` in the rc.conf(5) manual page.


----------



## SirDice (Feb 11, 2019)

olli@ said:


> Are you sure the system goes to single-user if that happens? I think that's not quite correct.


I've had that happen a couple of times. It was probably because the daemon kept a filesystem locked that the system was trying to unmount at that point. And the daemon refused to get killed because the filesystem was pulled out from underneath it. So I ended up with a nice race condition. There's a bunch things that could go wrong. Cause and effect is a bit tricky to figure out as there are multiple things happening almost simultaneously.

I agree that this shouldn't happen. But that's not the same as "it will never happen".


----------

