I'd like to execute a shell script for some pre-configuration tasks on the first boot. I found
systemd.run like this in the
cmdline.txt on the boot partition:
console=serial0,115200 console=tty1 root=PARTUUID=d2b047ad-02 rootfstype=ext4 fsck.repair=no rootwait systemd.run=/boot/my_init.sh
During the troubleshooting, I minimized
my_init.sh to just return 0:
#!/bin/bash exit 0
But this minimal example still doesn't work: During the boot, the screen went off and only the red power LED keeps being active. Since the output logs are written fast, I made a video to see if there is any usefull output:
Starting File System Check is the last line, then the screen went black. I found this documentation which indicates that shutting down is the default action. It seems a bit odd to me that this happens before a file system check without any log messages, but it could explain this behavior.
I also tried
systemd.run=/boot/ulabs_image2card_init.sh systemd.run_success_action=reboot without any difference. After adding
systemd.run_failure_action=reboot the Pi was rebooted. So it seems something went wrong, but what? The minimal script just return 0 which should indicate success. Setting the execute bit doesn't help, too.