drtyhlpr / rpi23-gen-image

Advanced Debian "stretch" and "buster" bootstrap script for RPi 0/1/2/3 and QEMU
GNU General Public License v2.0
307 stars 123 forks source link

rc.local: touch: cannot touch '/run/systemd/resolve/resolv.conf': No such file or directory #179

Closed BrainStone closed 5 years ago

BrainStone commented 5 years ago

The rc.firstboot script errors with the following issue:

Jun 22 11:12:00 SERVICE-COCKPIT rc.local[254]: touch: cannot touch '/run/systemd/resolve/resolv.conf': No such file or directory
Jun 22 11:12:00 SERVICE-COCKPIT systemd[1]: rc-local.service: Control process exited, code=exited status=1
Jun 22 11:12:00 SERVICE-COCKPIT systemd[1]: rc-local.service: Failed with result 'exit-code'.
Jun 22 11:12:00 SERVICE-COCKPIT systemd[1]: Failed to start /etc/rc.local Compatibility.

I am using the testing branch.

BrainStone commented 5 years ago

From what I can tell so far it seems like the file /etc/resolv.conf exists for some odd reason. I'm not sure when it gets added, but it's there, which means the check here https://github.com/drtyhlpr/rpi23-gen-image/blob/testing/files/firstboot/25-create-resolv-symlink.sh#L4 fails and doesn't restart the service.

Now I know the file should've been removed before the image is created and the log suggests it is. So I really don't know where this file is coming from.
I can't check if it's in my image or not, simply because I don't know how to list files in the image. If anyone knows how to do that, I can check.

BrainStone commented 5 years ago

Second update, the file is not in the image, which makes it even weirder. Something must create during the first boot before the /etc/rc.firstboot script executes.
That means most likely something I'm doing must add it if none of you have the same issue.

Will keep you posted!

burnbabyburn commented 5 years ago

I'll watch for this error on my next install. I didn't notice smth. special as systemd-resolved and /etc/resolv.conf are in my image atm.

However i did experience this error once. It was a prepending error in rc.firstboot which caused it. Does the service gets enabled?

Btw: While looking at the referenced line - This looks wierd to me. Both -a and -e do check if file exists and one is negated. But script doesn't break so it seems atleast valid :D

BrainStone commented 5 years ago

The -a is an AND in that situation.

And no it doesn't. As I said, the first check fails. And the file should've been removed from the image: https://github.com/drtyhlpr/rpi23-gen-image/blob/testing/rpi23-gen-image.sh#L693

BrainStone commented 5 years ago

Also I just tested removing the file /etc/resolv.conf, then rebooting. The script still failed at the same spot, so something is actively adding the file before rc.firstboot is run.

BrainStone commented 5 years ago

I suggest either just removing the check for /etc/resolv.cong or additionally also removing the file entirely, so it becomes that symlink in any case.

BrainStone commented 5 years ago

@burnbabyburn do you also happen to have dhcpcd added to your image?

burnbabyburn commented 5 years ago

@burnbabyburn do you also happen to have dhcpcd added to your image?

i found dhcpcd. but i think it is from pihole not from the image. We'll see next cycle :) €dit: no it's not installed after imaging.

Maybe dhcpcd is related to sysv-init?

root@pihole:/etc/pihole# systemctl disable dhcpcd
dhcpcd.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable dhcpcd

and i just did a new firstboot (but without dhcpcd watching yet)

rc.firstboot: Creating /etc/resolv.conf symlink
rc.firstboot: Reload systemd manager configuration
BrainStone commented 5 years ago

Ok. I disabled the service before first boot and the issue went away, so it's dhcpcd for sure.

I'll soon create a PR that will improve the wireless stuff. That will also include the fix, as I only even have that service for WiFi.