shutdown vs. reboot

shutdown vs. reboot

Post by Joe D » Sat, 14 Jan 2006 01:42:23



Hi all; help me settle a dispute:

I've always used /usr/sbin/shutdown -g0 -i6 -y to reboot Solaris
servers to 'gracefully' shutdown all running processes, sync the file
systems, and effect a reboot. I got into the habit as advised by an
admin when I first started. Review of the man page supported that
advice (in addition to the other options, run levels, etc.). However, a
colleague recently made the point that in the case where I don't need
to give any grace period to the users but wish to reboot the server, I
could simply issue the reboot command.

I checked the man page, and although it does not SAY that it effects a
graceful shutdown first (ie; runs through all the init stages and shuts
down running processes), it DOES state that the -q option can be passed
to "Reboot quickly and ungracefully, without shutting down running
processes first." So this would lead me to think that it does indeed
effect a graceful shutdown.

Can anyone confirm one way or the other, and offer advice as to which
would be the better choice of the two? Out of habit, I would tend to
stick with the shutdown command, but was wondering if I had been
laboring under a false idea....

Thanks, as always...

Joe D.

 
 
 

shutdown vs. reboot

Post by Darren Dunha » Sat, 14 Jan 2006 02:24:50



> I checked the man page

On what OS?

Quote:> , and although it does not SAY that it effects a
> graceful shutdown first (ie; runs through all the init stages and shuts
> down running processes), it DOES state that the -q option can be passed
> to "Reboot quickly and ungracefully, without shutting down running
> processes first." So this would lead me to think that it does indeed
> effect a graceful shutdown.

Depends on what you mean by 'graceful'.  The reboot man page probably
predates init and shutdown scripts.  Its idea of graceful is probably
sending TERM signals to processes before sending some KILLs.  It does
not run any shutdown scripts.

Quote:> Can anyone confirm one way or the other, and offer advice as to which
> would be the better choice of the two? Out of habit, I would tend to
> stick with the shutdown command, but was wondering if I had been
> laboring under a false idea....

Reboot will try to kill processes, cleanly unmount filesystems and
reboot.

'init 6' will try to run the scripts in /etc/rc0.d, then do what
'reboot' does.

'shutdown -i 6 ...' will do an 'init 6', along with an optional warning
to logged in users and a grace period.

In Solaris 10 (I don't know what version it first appeared), the bottom
of the man page has a NOTES section:

$ man reboot
[...]
NOTES
     The  reboot  utility  does  not  execute  the   scripts   in
     /etc/rcnum.d  or execute shutdown actions in inittab(4).  To
     ensure  a  complete  shutdown  of   system   services,   use
     shutdown(1M) or init(1M) to reboot a Solaris system.

--

Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >

 
 
 

shutdown vs. reboot

Post by Joe D » Sat, 14 Jan 2006 03:01:55


Sorry about the omission; Solaris is the OS; all releases 2.6 and up.

Thanks for the point to the Solaris 10 man page; I didn't check there.

As usual, I'm finding this group an incredible resource; thanks again.

 
 
 

shutdown vs. reboot

Post by Darren Dunha » Sat, 14 Jan 2006 03:40:32



> Sorry about the omission; Solaris is the OS; all releases 2.6 and up.

I meant which one did you check docs on.  I was pretty sure that the bit
I posted was a recent addition.

I got a chance to poke.  I did not find the NOTES section on Solaris 8,
but I did on Solaris 9 and 10.  While the contents of that note are true
for all SunOS 5.x, it appears it didn't appear in the reboot man page
until sometime in the 9 release.

--

Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >

 
 
 

shutdown vs. reboot

Post by Daniel Roc » Sat, 14 Jan 2006 03:57:07



> I checked the man page, and although it does not SAY that it effects a
> graceful shutdown first (ie; runs through all the init stages and shuts
> down running processes), it DOES state that the -q option can be passed
> to "Reboot quickly and ungracefully, without shutting down running
> processes first." So this would lead me to think that it does indeed
> effect a graceful shutdown.

The manual page is very clear about that:

     The  reboot  utility  does  not  execute  the   scripts   in
     /etc/rcnum.d  or execute shutdown actions in inittab(4).  To
     ensure  a  complete  shutdown  of   system   services,   use
     shutdown(1M) or init(1M) to reboot a Solaris system.

Reading the source

        http://cvs.opensolaris.org/source/xref/on/usr/src/cmd/halt/halt.c

-q is only meaningful if combined with the -n flag:

"reboot" and "reboot -q" are the same.

"reboot -q -n" just doesn't write a wtmpx record (sync() is called during
uadmin - unless you do a "reboot -d -q -n")

It also seems the semantics of the reboot command is different from BSD:
BSD first sends the TERM signal to all processes, then waits a few seconds,
then sends all processes the KILL signal.

In Solaris all processes are stopped (SIGSTOP) instead - so they have no
chance of doing any housekeeping.

--
Daniel

 
 
 

shutdown vs. reboot

Post by Rich Pierso » Sat, 14 Jan 2006 12:01:45





>> Sorry about the omission; Solaris is the OS; all releases 2.6 and up.

> I meant which one did you check docs on.  I was pretty sure that the
bit
> I posted was a recent addition.

> I got a chance to poke.  I did not find the NOTES section on Solaris 8,
> but I did on Solaris 9 and 10.  While the contents of that note are
true
> for all SunOS 5.x, it appears it didn't appear in the reboot man page
> until sometime in the 9 release.

Shutdown -i6 -g0 -y does a graceful reboot, syncs, shuts the processes
down and brings everything back up.
Reboot is more like pulling the plug and I have seen that totally hose a
system in hp, aix and solaris, on a simple sparc it's probably no big
deal, add some raid and mirrors, oracle or sybase, iplanet/sun one,
different story.
With that said and as long as I have been doing this I found out an
interesting fact the other day, the new suns do this like 280R's on up.
Hit the power button once and it initiates a graceful init 5 or shutdown
and power off.
Had one of my customers hire a 'he knows linux so he's good to go on
solaris' guy, I was reconfiguring a v880 with 64 74gig drives both
internal and on dumb external arrays, all mirrored and raided meta
devices. I asked him to reboot. Darned if he didn't type 'reboot'and hit
enter before I could stop him. I billed for an extra 8 hours fsck'ng the
file systems and rebuilding the arrays. Afterwards I pulled out my ptouch
and put the commands across the top of the monitor.
 
 
 

shutdown vs. reboot

Post by Joe D » Sat, 14 Jan 2006 23:09:44


Thanks, Darren and Daniel; I did indeed find the note on one of our
Solaris 10 servers, but not on our 5.8 servers. Odd that they would put
this important bit of info at the tail end of the man page, rather than
right up top where everyone will see it immediately.

Regardless, I am gratified to know that I have indeed been doing things
the safe way; plus I win a bet!  :)

p.s.; thanks to Daniel for the power-off tip about the 280R on up; I
didn't know that. I'll have to try it the next time I'm in the
datacenter (on a TEST machine!  :^)......)

 
 
 

shutdown vs. reboot

Post by DBPW » Sun, 15 Jan 2006 00:53:49


'shutdown -i 6 ...' will do an 'init 6', along with an optional warning
to logged in users and a grace period.

If your using a grace period of 0 seconds (-g0), is'nt that exactly the
same as "init 6"?
Which is shorter and easier to type.

 
 
 

shutdown vs. reboot

Post by christopher.paol.. » Sun, 15 Jan 2006 01:43:05


In this case, /usr/sbin/reboot is preferable since reboot will perform
a sync(1M) operation on all disks before invoking init(1M).
 
 
 

shutdown vs. reboot

Post by Daniel Roc » Sun, 15 Jan 2006 03:08:51



> Shutdown -i6 -g0 -y does a graceful reboot, syncs, shuts the processes
> down and brings everything back up.

Even uadmin 2 0 (halt) uadmin 2 1 (reboot) uadmin 2 6 (power-off)
kills all processes, dismounts all filesystems and calls sync.

Quote:> Reboot is more like pulling the plug and I have seen that totally hose a
> system in hp, aix and solaris, on a simple sparc it's probably no big
> deal, add some raid and mirrors, oracle or sybase, iplanet/sun one,
> different story.

No, reboot is (simplified):

kill -STOP -1
sync
umount -f -a
uadmin 2 1              - which does (simplified):
                                kill -KILL -1
                                umount -a
                                sync
                                reboot

Pulling the plug would be just the last of the above lines.

So you can see: You can call uadmin directly instead of reboot. The only
difference is that no wtmpx entry will be written and the GRUB boot archive
won't be refreshed.

Quote:> Had one of my customers hire a 'he knows linux so he's good to go on
> solaris' guy, I was reconfiguring a v880 with 64 74gig drives both
> internal and on dumb external arrays, all mirrored and raided meta
> devices. I asked him to reboot. Darned if he didn't type 'reboot'and hit
> enter before I could stop him. I billed for an extra 8 hours fsck'ng the
> file systems and rebuilding the arrays. Afterwards I pulled out my ptouch
> and put the commands across the top of the monitor.

I never had a corrupt file system or Veritas Volume by calling uadmin
directly - something else must have been going wrong here.

--
Daniel

 
 
 

shutdown vs. reboot

Post by Daniel Roc » Sun, 15 Jan 2006 02:59:54



> In this case, /usr/sbin/reboot is preferable since reboot will perform
> a sync(1M) operation on all disks before invoking init(1M).

"reboot" doesn't invoke init.

Simple advice: *Never* use "reboot" or "halt". Always use "init 6" or
"init 0" instead. If you want to pass boot arguments, run "init 0" -
then enter at the ok prompt "boot <args>"

        reboot -- -r

doesn't work on x86 though.
On x86 architecture there is no way to pass boot arguments - other than
editing /boot/grub/menu.lst or /boot/solaris/bootenv.rc directly.

--
Daniel

 
 
 

shutdown vs. reboot

Post by Casper H.S. Di » Sun, 15 Jan 2006 04:03:53



>Simple advice: *Never* use "reboot" or "halt". Always use "init 6" or
>"init 0" instead. If you want to pass boot arguments, run "init 0" -
>then enter at the ok prompt "boot <args>"
>    reboot -- -r
>doesn't work on x86 though.

That actually does work on x86 and has for some time.

Quote:>On x86 architecture there is no way to pass boot arguments - other than
>editing /boot/grub/menu.lst or /boot/solaris/bootenv.rc directly.

Pre-grub they were deposited in bootargs.rc; with grub a temporary
menu item is made.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

shutdown vs. reboot

Post by Daniel Roc » Sun, 15 Jan 2006 05:21:49




>>On x86 architecture there is no way to pass boot arguments - other than
>>editing /boot/grub/menu.lst or /boot/solaris/bootenv.rc directly.

> Pre-grub they were deposited in bootargs.rc; with grub a temporary
> menu item is made.

With the halt/reboot commands? Where can I find that in the implementation?

I started with (OpenSolaris source):
- usr/src/cmd/halt/halt.c
  additional boot arguments are passed directly to uadmin (as mdep)
- usr/src/uts/common/syscall/uadmin.c
  . uadmin()
    mdep is passed unaltered to kadmin()
  . kadmin()
    calls i_convert_boot_device_name() - which is a dummy for x86
    then calls mdpreboot() or mdboot()
- usr/src/uts/i86pc/os/machdep.c
  . mdboot(), mdpreboot()
    mdep is completely ignored

--
Daniel

 
 
 

shutdown vs. reboot

Post by Casper H.S. Di » Sun, 15 Jan 2006 22:28:40





>>>On x86 architecture there is no way to pass boot arguments - other than
>>>editing /boot/grub/menu.lst or /boot/solaris/bootenv.rc directly.

>> Pre-grub they were deposited in bootargs.rc; with grub a temporary
>> menu item is made.
>With the halt/reboot commands? Where can I find that in the implementation?
>I started with (OpenSolaris source):
>- usr/src/cmd/halt/halt.c
>  additional boot arguments are passed directly to uadmin (as mdep)
>- usr/src/uts/common/syscall/uadmin.c
>  . uadmin()
>    mdep is passed unaltered to kadmin()
>  . kadmin()
>    calls i_convert_boot_device_name() - which is a dummy for x86
>    then calls mdpreboot() or mdboot()
>- usr/src/uts/i86pc/os/machdep.c
>  . mdboot(), mdpreboot()
>    mdep is completely ignored

In OpenSolaris (grub based boot) look "Solaris_reboot_transient" in:

http://cvs.opensolaris.org/source/xref/on/usr/src/cmd/boot/bootadm/bo...

In Solaris 10 and earlier (pre-newboot) it's done in libc in the
x86/amd64 specific uadmin(2) wrapper.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

shutdown vs. reboot

Post by William Schau » Wed, 18 Jan 2006 01:50:47




>> I checked the man page, and although it does not SAY that it effects a
>> graceful shutdown first (ie; runs through all the init stages and shuts
>> down running processes), it DOES state that the -q option can be passed
>> to "Reboot quickly and ungracefully, without shutting down running
>> processes first." So this would lead me to think that it does indeed
>> effect a graceful shutdown.

> The manual page is very clear about that:

>      The  reboot  utility  does  not  execute  the   scripts   in
>      /etc/rcnum.d  or execute shutdown actions in inittab(4).  To
>      ensure  a  complete  shutdown  of   system   services,   use
>      shutdown(1M) or init(1M) to reboot a Solaris system.

> Reading the source

>    http://cvs.opensolaris.org/source/xref/on/usr/src/cmd/halt/halt.c

> -q is only meaningful if combined with the -n flag:

> "reboot" and "reboot -q" are the same.

> "reboot -q -n" just doesn't write a wtmpx record (sync() is called during
> uadmin - unless you do a "reboot -d -q -n")

> It also seems the semantics of the reboot command is different from BSD:
> BSD first sends the TERM signal to all processes, then waits a few seconds,
> then sends all processes the KILL signal.

> In Solaris all processes are stopped (SIGSTOP) instead - so they have no
> chance of doing any housekeeping.

Are you sure all processes are sent SIGSTOP? That is not what i see, looks like
they are all sent SIGTERM before the uadmin syscall is eventually made.
the line im referring to is 727 in halt.