[PATCH] init: handle kexec clean reboot

Denys Vlasenko vda.linux at googlemail.com
Wed May 22 16:42:30 UTC 2013


On Mon, May 20, 2013 at 8:56 AM, Harald Becker <ralda at gmx.de> wrote:
>>> Busybox init has a restart action. If
>>> this action is set to a script it is invoked after normal
>>> shutdown processing. The script may do whatever action may be
>>> required or optionally restart the init process.
>>
>>That seems a little bit clunky; we may not always want the
>>restart action to be a kexec (but just a normal reboot). In this
>>case, would we need to be dynamically reconfiguring the restart
>>action?
>
> We have already three types of shutdown: halt, reboot and
> poweroff. All three are handled by the same restart action and
> need what you call "dynamic reconfiguration". You may just pass
> required information via shared memory. In most cases I know, it
> is handled this way.

I think the entire "reboot/shutdown through init" idea
is not too clever invention in general.

The operation of shutting down the system
is not intrinsically tied to init.

Imagine that you was given a root shell prompt
at the Unix-like machine and instructed to shut it down
as cleanly as possible, without looking at ps output
and without assuming which type of init system is used
(it may as well use a custom, non-standard init process).

What would you do?

I'd do something like:

cd /
killall5 -TERM
sleep <SMALLNUM>
killall5 -KILL
sleep <SMALLNUM>
umount -a -r
sync
poweroff -f   # says directly to kernel: "physically power off the box please"

See? This requires no communication with init, or
knowledge about other running processes: Unix programs
*have to* shutdown on SIGTERM, with a very few exceptions.
Bad boys will be dealt with SIGKILL anyway.

You can perform kexec the same way.

--
vda


More information about the busybox mailing list