1. Home
  2. Initialize And Finalize Scripts
  3. How can I reboot from an initialize/finalize script?

How can I reboot from an initialize/finalize script?

On a regular node, the initialize and finalize scripts run in the pre-provisioning, pre-init, early user space, initial root file system environment. That means that in that state there are no run levels. Which means the usual kill [-HUP/-TERM] 1/reboot [-f]/shutdown -h now/poweroff and so on won’t work.

So, after having run an initializing script to do some pre-provisioning changes that require a reboot, how do you reboot?

Use sysrq ( http://kernel.org/doc/Documentation/sysrq.txt ) towards the end of the script:

echo "1" > /proc/sys/kernel/sysrq
echo "s" > /proc/sysrq-trigger
echo "s" > /proc/sysrq-trigger
echo "u" > /proc/sysrq-trigger
echo "b" > /proc/sysrq-trigger

Updated on May 18, 2020

Related Articles

Leave a Comment