cancel
Showing results for 
Search instead for 
Did you mean: 

shutdown, init, and SAM

SOLVED
Go to solution
EEESEC
Frequent Advisor

shutdown, init, and SAM

Can anyone shed some light on the the shutdown command and "single user mode"? I've been researching for a while and am still not clear on it.

http://docs.hp.com/en/B3921-600631/shutdown.1M.html
http://docs.hp.com/en/B3921-60631/init.1M.html

The man page for shutdown states that with no options it will take you to "single-user mode". When describing the shutdown process it says that, for a "stand alone system" it will be brought down to run level 0. Then "If the system was not a cluster client and the system was being brought down to single-user state, a signal is sent to the init process to change states (see init(1M))."

Question 1: Am I to interpret that to mean that an "init -s" (or whatever the actual signal is) will be executed from run level 0?

Question 2: Assuming the answer to question one is yes, I thought that the only way to truly get into single user mode was to interrupt the boot process (what I've always done). Yes/No? Is it really possibly, for example, get to single user mode from SAM via the "shutdown to single user state" option?

Finally, my Asghar Ghori HP admin book states that "The shutdown command calls the init command behind the scenes.... You may use the init command instead. The only two features not available with init... [is] it will not broadcast a message or wait a specified period of time." Is this actually true or an oversimplification? The man pages seem to describe them quite differently.

I'm on 11iv2 and a PA-RISC based system (rp5450) if it matters given the general nature of my questions.

I'd appreciate any insight some of you more experienced admins could throw my way, including suggestions for further reading on these topics.

Thanks!
14 REPLIES
Steven E. Protter
Exalted Contributor

Re: shutdown, init, and SAM

Shalom,

Single user mode is a start up command.

Start the system, get on console

Interupt on the 10 second prompt.

bo
Y to the interact question

hpux -is
At a boot prompt.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
EEESEC
Frequent Advisor

Re: shutdown, init, and SAM

Thanks for the response. I'm very familiar with booting into single user. I need more in the line of some disambiguation on "single user" and the init and shutdown commands.

If single user mode is a "start up" command as you say, then what does /usr/sbin/shutdown executed from say, run level 4, actually do? If I do a who -r afterwards, it tells me I'm in run level s....
Suraj K Sankari
Honored Contributor

Re: shutdown, init, and SAM

Hi,

With shutdown command you can't take your system into single user or any specific run label.
but through init command you can do the same
means from any runlabel you can switch to any.

Suraj
EEESEC
Frequent Advisor

Re: shutdown, init, and SAM

If that is true then why does the man page say you can.

"The shutdown command is part of the HP-UX system operation procedures. Its primary function is to terminate all currently running processes in an orderly and cautious manner. shutdown can be used to put the system in SINGLE-USER MODE for administrative purposes such as backup or file system consistency checks (see fsck(1M)), to halt or reboot the system, or to make the partition ready for reconfiguration. "

If you do a "/sbin/shutdown" and then do a "who -r" after, what run level do you get reported?

Thanks for the response.
Patrick Wallek
Honored Contributor

Re: shutdown, init, and SAM

The 'shutdown' command, when no parameters are specified WILL take the system down to single-user mode.

However, it may not necessarily unmount all of the file systems or stop all services. So if you need to do something that require /var, /tmp or one of the OS related file systems to be unmounted, just doing a shutdown is not the best solution.

If you read the init man page for the 's|S' options you will see the following warning: "Transitioning into run level S from a higher run level does not terminate other system activity and does not result in a "single-user state"; this operation should not be done."

So while you "could" theoretically do an 'init s' or 'init S' you should not.

I suppose you could use SAM to shut down to single-user mode, but I think you will run into the same issues as above since it will probably just do a 'shutdown' or 'init S'.

Rebooting the server and coming UP into single-user mode is the SAFEST way to get there. Coming up into single-user mode absolutely ensures that NO extraneous processes are running and NO file systems are mounted.

I don't think I've every just done a 'shutdown' or 'init S' to go to single-user mode. It's not worth the potential pain.
EEESEC
Frequent Advisor

Re: shutdown, init, and SAM

I've run "init -s|S" before at a higher run level just to see what happens and, as you've noted per the man, it doesn't seem to do anything except force "who -r" to report you are in single user. Kind of strange.

Going back to a few of my original questions, would you interpret the "Shutdown Procedure" section of shutdown's man to mean that when run with no params it will take the system down to 0, and from there, init to s|S?

Would there be any difference in running:

#shutdown

as opposed to

#init 0
#init s

Good response above. Want to try and get this nailed down since this will effect how some admin processes are done in production.




Patrick Wallek
Honored Contributor

Re: shutdown, init, and SAM

>>Going back to a few of my original
>>questions, would you interpret the
>>"Shutdown Procedure" section of shutdown's
>>man to mean that when run with no params
>>it will take the system down to 0, and
>>from there, init to s|S

I see the area of the man page you are looking at. However, doing a 'shutdown' with no arguments will NOT take the system down to run-level 0 and then back up to 's|S'. Run-level 0 shut's down HP-UX. If you were to run 'init 0' from the command prompt, HP-UX would shut down. Doing an 'init 0' is the equivalent of doing a 'shutdown -h'.


>>Would there be any difference in running:

>>#shutdown

>>as opposed to

>>#init 0
>>#init s

ABSOLUTELY. Once an 'init 0' is done, you would have to restart the system as it would be down. There would be no way to do an 'init s' after doing 'init 0'.
Patrick Wallek
Honored Contributor
Solution

Re: shutdown, init, and SAM

Well, I've just been doing some experiments.

I don't normally do a 'shutdown' on systems, so I tried it. According to the messages displayed it appears that the /sbin/rc?.d/K* scripts were executed, and the system taken to a some semblance of run-level 0, and then brought to run-level 's'. When it go to 'single-user' mode via this method ALL of my VG00 file systems (/, /stand, /opt, /tmp, /usr and /home) were still mounted and there were 36 processes running.

I have just rebooted the system, interacted with the IPL, and brought it into single-user mode via 'hpux is'. At this point I have /stand mounted and cannot tell how many processes are running because the 'ps' command isn't available.

After mounting all filesystems, I have 34 processes running.

If you want to go to a true single-user mode I would reboot the system and come up into single-user mode via 'hpux -is'.

I would not use 'shutdown' to get to single-user mode.
Patrick Wallek
Honored Contributor

Re: shutdown, init, and SAM

One last look at things after doing a 'shutdown'. /, /var, /usr, /opt and /home were still mounted (contrary to what I said above). Interestingly /stand was unmounted.

The file systems above showed to have processes running against them when 'fuser -cu' was run against each one. One of the running processes was my shell process.

If something needed to be done against one of those file systems, it would probably be difficult because killing the running processes would shut the system down.

Killing your shell process wouldn't be much of an option.

When I did an 'exit' from this mode, I was asked what run level I wanted the system to go to. So, no shell means no system access.

If you have doubts, and a test system you can easily reboot, do some experiments of your own to see exactly what I'm talking about.

EEESEC
Frequent Advisor

Re: shutdown, init, and SAM

Yep, very similar results myself. Do you also get the messages during the shutdown something to the effect of:

"Taking the system down to run level 0...

Transitioning to run level S...
Waiting 30 seconds... "

Would you say this is blatantly misleading or just outright wrong?

For me, executing "shutdown" doesn't unmout a single file system. Both my VGs are up. Similar to you I have around 40 process still running. I wouldn't even call that run level 1....

How does this jive with the shutdown manual? Seems to me like it's doing an init 1, mount -a, init S.

I'm going to compare this pseudo single user mode to the above first chance I get.

10 pts for taking the time to actually try this on your system.

Thanks for all the help!
EEESEC
Frequent Advisor

Re: shutdown, init, and SAM

Edit above -

I mean do an init 1 then init S and compare. Shouldn't need a mount -a since they should never haven been unmounted if just going to 1.
Bill Hassell
Honored Contributor

Re: shutdown, init, and SAM

The man page for shutdown has been inaccurate for years. Back in the pre-10.0 version days, you could get to a true single user mode (the same as an interactive boot using hpux -is). But using init will not get to single user mode. init simply manages the processes that it owns and runs the rc scripts when changing states. Since there is no /sbin/rcs.d (following rule that rc1.d is for init 1, etc) then unmounting the filesystems and starting a single user root shell just doesn't happen. Use init to change run levels from 1 to 5 but otherwise, a full reboot is needed and interaction for the hpux command is required.


Bill Hassell, sysadmin
EEESEC
Frequent Advisor

Re: shutdown, init, and SAM

Thanks for the final word.
EEESEC
Frequent Advisor

Re: shutdown, init, and SAM

thread closed