[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Making SysV boot scripts reboot faster



Peter Cordes wrote:
> I always find it dumb that rebooting a GNU system involves
> doing so much stuff, when the machine is going to be rebooted anyway.

You are right that the current situation does not optimize the speed
of system shutdowns.  I have also thought of broaching this subject
in debian-devel, but I never thought it was pressing enough.

There are two ways to speed up the process.  Either refrain from 
calling some initscripts, or call the initscripts with a different set
of arguments, allowing them to work faster when preparing for system
shutdown.

The second solution is more flexible.


> The only reason /etc/init.d scripts do so much work in "stop" mode
> is that they don't know whether it's a shutdown, or if you just
> want to stop the service

Right, so the init script needs to be able to distinguish a system
shutdown from a service stop.


> I suggest that when shutting down, the rc scripts should call
> /etc/init.d/foo reboot, and if that returns an error, try the
> normal stop.

A more backward-compatible approach would be to call the initscript
with a second argument in addition to "stop".  E.g.,

   foo stop system
or
   foo stop fast

Then the initscript could perform different shutdown actions
depending on this second argument.  The following could be
done to quite a few initscripts:

  stop)
+    [ "$2" = "system" ] && exit 0

The same thing could be accomplished using a special environment
variable instead of an argument.

A problem with implementing this is that if the shutdown fails
then the system is left in an undefined state -- services weren't
"properly" shut down and might not be restartable.  However,
people might accept this in return for a faster shutdown.


> It would be even better if there was a way to completely avoid
> running some init scripts on shutdown.

This doesn't accord with the System V init way of doing things.
rc?.d directories are supposed to be fully populated; the 
behavior of the system is not defined if one of the directories
is missing a symlink for a particular service.


> So I guess I've got two ideas here: having a reboot argument

... or a second argument after "stop" ...


> and having a way for init scripts to indicate that update-rc.d
> shouldn't make kill links for them.

It is already possible to update-rc.d symlinks without putting
symlinks in runlevels 0 and 6 (assuming that this is what you
meant).


> An init script could indicate that it didn't need to be run
> on reboot at all by its name. 

No.  Don't add any more ugly kludges to the init system.


John Hasler wrote:
> Have you looked at rcconf?

I have looked at rcconf(8):

   Rcconf checks 'defaults' links in /etc/rc?.d/ directories for choice as
   unset, whether the package has the start file with the same number in
   /etc/rc?.d/(?:=2345) directories (rc?.d/S??name), and stop file with
   the same number in /etc/rc?.d/(?:=2345) directories(rc?.d/K??name). And
   Rcconf also checks in /etc/init.d/ directory for choice as set.

Everyone got that?

-- 
Thomas Hood <jdthood@yahoo.co.uk>



Reply to: