It isn’t exactly what you are asking for, but you might be interested in changing how shutdown proceeds rather than minimizing power during shutdown. Are you familiar with “Magic SysRq”? This was really intended for developers, but could also help during automatic “expedited” shutdown.
Normally what this would do is allow certain hot key combinations to exert various emergency system control tasks. An example is calling sync, and this would work even on systems which are locked up (beware that calling sync when not needed in solid state memory would shorten the life of that memory, but shutdown has to call sync anyway). If you were to monitor “
dmesg --follow”, and hit the key combination “
ALT+SYSRQ+s”, then you’d see a note about emergency sync (it does require sysrq to be enabled, but most of the time this is enabled by default).
Another magic sysrq is to kill all applications other than init, and another to set up the filesystem as read-only. A possibly useful combination would be to (A) call sync, (B) kill all non-essential programs (they wouldn’t get to save any results), (C) sync the filesystem again, (D) set the filesystem to read-only, and (E) force shutdown or reboot (an immediate force, not a graceful shutdown, but since you are already read-only, then only the data from killed running programs would be lost).
You’re probably thinking this isn’t useful since you’re not there to produce the right keystrokes. However, this is also used for remote debugging over serial console, and anything enabled for sysrq keystrokes can be used with an echo and redirect to file “
/proc/sysrq-trigger”. This allows remote debugging of the Linux kernel to do things like halt the kernel, set break points, and then continue the debugger running the Linux kernel itself. You are not debugging, but a series of echo of characters to that file could conceivably provide an emergency shutdown which would not corrupt the filesystem.
On a typical system (not just a Jetson) running Linux, if I’ve done something to lock up the system I will usually “
ALT-SYSRQ-s” to sync, then “
ALT-SYSRQ-u” to remount the filesystem read-only, followed by “
ALT-SYSRQ-b” to force immediate reboot.
The file normally used to modify the availability of
sysrq is “
/etc/sysctl.conf”. There is a parameter in this such as:
Sysrq enable is based on a bitwise mask. Not all sysrq function is valid on all architectures, and so everything possible might use a mask of other than
1. There are other ways of enabling this as well, and so even if the parameter is commented out in “
/etc/sysctl.conf”, then the feature could still be enabled. I suggest monitoring “
dmesg --follow” and trying “
ALT-SYSRQ-s” to see if an emergency sync message shows up.
A way to see what is currently allowed in the sysrq mask:
An example of using an echo of a character instead of a hot key to call sync:
sudo echo 's' > /proc/sysrq-trigger
I think it is a difficult and complicated task try to alter the entire operating system to try to run in a lower power mode in some real time performance prior to emergency shutdown. Killing applications and sync prior to switch to read-only mode would save the system against corruption, but if you are looking to also shut down individual programs gracefully, then going to a low power mode is going to likely leave you unsatisfied with the results. You would either have to have some sort of backup power which allows graceful shutdown, or else accept running programs are going to die without saving their data.