This document describes why and how Chrome OS devices shut down or reboot.
“Shut down” is a verb. “Shutdown” is a noun.
Shutdown and reboot are initiated on Chrome OS devices through
RequestRestart D-Bus method calls to
powerd. These methods are typically called by Chrome in response to requests from the user, but they can also be invoked by other processes in some cases (e.g. by
update_engine to reboot to apply a system update, or by shell scripts in the lab to reboot devices that don't have working network connections).
Both D-Bus methods accept two arguments:
power_manager::RequestRestartReasonvalue from the powerd constants file in
powerd logs both arguments to the current log file within
/var/log/power_manager before handling the request; look for messages like these near the end of the file:
[0429/234951:INFO:daemon.cc(1175)] Got RequestShutdown message from :1.62 with reason user-request (UI request from ash)
[0425/211426:INFO:daemon.cc(1046)] Got RequestRestart message from :1.33 with reason system-update (update_engine applying update)
powerd may also decide to shut the system down without input from other processes in some cases, including:
In all cases,
powerd will also log a terse message just before it shuts down or reboots:
[0429/234952:INFO:daemon.cc(1606)] Shutting down, reason: user-request
[0425/211426:INFO:daemon.cc(1263)] Restarting, reason: system-update
initctl emit --no-wait runlevel RUNLEVEL=<runlevel> SHUTDOWN_REASON=<reason>
to instruct Upstart to either shut down (runlevel 0) or reboot (runlevel 6) the system. The
SHUTDOWN_REASON argument contains a short dash-separated string describing the reason for the request.
The Upstart halt job or reboot job is triggered by the runlevel change. This triggers a cascade of other jobs within Upstart's
/etc/init directory. The pre-shutdown job logs a message to
/var/log/messages to make it easier to see when and why the system shut down or rebooted while examining logs:
2018-04-24T21:30:08.513032-07:00 NOTICE pre-shutdown: Shutting down for reboot: not-via-powerd
In the above case,
not-via-powerdindicates that this clean reboot was initiated by the
rebootcommand being run directly rather through powerd. Requests should always go through
powerdwhen possible, both for consistency and for correctness (e.g.
powerdknows to defer shutting down if a firmware update is in progress).
After other jobs have completed, the
reboot job executes the chromeos_shutdown script.
chromeos_shutdown handles various tasks:
SHUTDOWN_REASONargument with value
low-battery, the display_low_battery_alert script is executed to use frecon to display a brief animation before shutting down.
reboot job executes the
reboot command with
--force to instruct the kernel to immediately halt or reboot the system.