I've been struggling with the issue in the topic for a few days now. Actually the ideal solution would be a read-only root file system (with a writable overlayfs on top), so that I can just turn the power off, without risking any SD-card/filesystem corruption. There seems to be an easy solution for that according to this page:
section "How to freeze your filesystem?". But the package "overlayroot" that is mentioned there does not seem to be available for Debian (Armbian Stretch).
A quick attempt to adopt the overlayfs-startup scripts to Debian failed, because Debian is using systemd and the script that I found was obviously for sysv-init.
Anyway, next best solution that I searched for was using the on-board power button to shut down the system. I found two posts that seemed like a solution: using acpid and adding a udev-rule to detect the onboard power button as acpi-power-button. But neither of the two worked on my BananaPi M2+ board.
I've not been able to see any events in acpid (acpi_listen or in the acpi-log files) when pressing the power button. And in the meantime, I doubt, that it can work on the BananaPi M2+, as the power button is connected to one of the GPIO-Pins here.
What I did manage to do so far, after inspecting the circuit diagrams of the board and thus finding out which GPIO-pin the power button is connected to, is to write a little python program that estabilshes an interrupt when that GPIO shows a fallig edge (i. e. when the power button is pressed) and then shuts down the system. This python script I have installed as a systemd service. So currently, I managed to shut down the BananaPi by pressing the power button.
(For anyone who is interested: I uploaded the source code to GitLab here:
Anyway, I am still interested in the readonly-root / overlayfs / overlayroot solution for Debian stretch, as this is safer in the long run. Does anyone have any pointers for me there? Has anyone tried that already or is there a solution for the u-boot / systemd combination that would be easy to adopt?