0

I am trying to diagnose why /etc/rc.local is not successfully executing on boot of a raspberry pi.

I have stripped the content of /etc/rc.local to a minimal version, and still cannot get it to touch a file in the /tmp directory.

I am getting this relevant output in /var/log/syslog on startup.

So looks like systemd is responsible for executing /etc/rc.local but is failing.

Have done lots of googling, no luck yet.

Thanks

Notes

System info (new to raspberry pi so let me know what else i can post):

uname -a:

Linux raspberrypi 4.14.79-v7+ #1159 SMP Sun Nov 4 17:50:20 GMT 2018 armv7l GNU/Linux

/etc/rc.local content:

#!/bin/bash
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
touch /tmp/foo

exit 0

/var/log/syslog content:

raspberrypi systemd[1]: Starting /etc/rc.local Compatibility...
raspberrypi systemd[290]: rc-local.service: Failed at step STDOUT spawning /etc/rc.local: No such device
raspberrypi systemd[1]: rc-local.service: Control process exited, code=exited status=209
raspberrypi systemd[1]: Failed to start /etc/rc.local Compatibility.
raspberrypi systemd[1]: rc-local.service: Unit entered failed state.
raspberrypi systemd[1]: rc-local.service: Failed with result 'exit-code'

/etc/rc.local appears to have correct permissions:

pi@raspberrypi:~ $ ls -la /etc/rc.local 
-rwxr-xr-x 1 root root 345 Jan 16 18:03 /etc/rc.local

Edit/Update:

I ended up abandoning attempts to start my server via /etc/rc.local and instead created a systemd unit, which was pretty straight forward.

Guide here : https://learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup

  • 1
    Is your rootfs read-only? Where's your /tmp? Is it part of the rootfs? Or a tmpfs file system? – Dougie Jan 27 at 8:37
  • 2
    Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. Following the recommendation of the developers from systemd you should avoid using it. Instead you should create a systemd unit file for your script. – Ingo Jan 27 at 21:09
  • I went with a systemd unit, as @Ingo suggested and everything started working as desired. – zayquan Jan 28 at 9:58
  • @Dougie the /tmp is part of the root filesystem. – zayquan Jan 28 at 9:59
  • Please make your Edit/Update an answer. This will finish your question and shows other user that it has a solution. – Ingo Jan 28 at 23:25
0

I did not end up getting my additions to /etc/rc.local to correctly execute.

Instead created a systemd unit, which was pretty straight forward, and is recommended over additions to /etc/rc.local.

Guide here : https://learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup

Please comment with better guides and I will edit the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.