cIddeab Posted January 4, 2019 Posted January 4, 2019 (edited) Hi all, 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: https://docs.armbian.com/User-Guide_Advanced-Features/ 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. https://frank-mankel.de/kategorien/10-bananapi/62-bananapibananapro-powerbutton https://stackoverflow.com/questions/53757996/banana-pi-m2-execute-script-when-power-button-was-pressed-via-udev-does-not-wo 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: https://gitlab.com/cIdde/bananapim2pluspowerbuttonshutdownservice ) 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? Edited January 4, 2019 by Tido I changed the title as you look for Overlay, not shutdown
yam1 Posted January 8, 2019 Posted January 8, 2019 I haven't, but you may want to try this aufs blog post: https://superuser.com/questions/833576/differences-of-aufs-unionfs-and-overlayfs-from-each-other
cIddeab Posted January 10, 2019 Author Posted January 10, 2019 @yam1: thanks for the link. After reading it, I still think, that overlayfs is the best way to go. Well, as there doesn't seem to be a ready-to-use solution, it looks like I'll have to do some porting of the "overlayroot"-package solution to systemd ... Will surely take a while, but when I have something, I'll report it here - for anyone else, who might be looking for such a solution.
cIddeab Posted January 4, 2020 Author Posted January 4, 2020 Ok, finally I found some time to solve this problem. I adopted the root-ro project which is for the RaspberryPi to standard Debian / Armbian. If anyone is interested, the code can be found here: https://gitlab.com/cIdde/bananapim2pluspowerbuttonshutdownservice Clone the repo, call install.sh and you are done. (Well, maybe read the docs first and have a backup of your root drive at hand, if anything should fail.) At least for me, it worked like a charm: on a virtual standard Debian 10 system as well as on my BananaPi M2+ EDU board running Armbian / Debian 9.
Petr StehlÃk Posted May 5, 2020 Posted May 5, 2020 On 1/4/2020 at 3:49 PM, cIddeab said: Ok, finally I found some time to solve this problem. I adopted the root-ro project which is for the RaspberryPi to standard Debian / Armbian. If anyone is interested, the code can be found here: https://gitlab.com/cIdde/bananapim2pluspowerbuttonshutdownservice Clone the repo, call install.sh and you are done. Well, there's no "install.sh" in that repo. Don't you happen to have a different repo with the root-ro for Armbian, please?
Recommended Posts