-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Can't write to a file from udev Run+= #2497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Here's the syslog after running
Note the records:
|
@davthomaspilot Sorry about the delay - are you still experiencing this issue? It sound more like a generic kernel issue than Pi specific, does Google throw up anything? |
I've been using a work-around. When you say "are you still experiencing..", do you want want me to test on something newer? Google searches show many have reported what seems like the same issue |
The same issue only on Raspberry Pi, or on other systems as well? |
Both, just google it. Here are a couple of examples: https://www.raspberrypi.org/forums/viewtopic.php?t=210243 I'd guess the issue is in how services get started at boot time. Perhaps some service needs an additional dependency. Probably udev getting started too soon is the issue, since the filesystem becomes writeable if you restart udev. |
I had a similar problem. I've seen various workarounds suggested, one is to comment out the line:
in /lib/systemd/system/systemd-udevd.service |
While investigating why my 'th-cmd' rules are all failed, I just found that systemd-udevd daemon is running with / mounted RO ! (Saw this by checking /process//mounts of udev daemon) |
I think I can confirm this. For some reason, on a Raspberry Pi running Debian 9 (Stretch), I cannot write to files from an USB mount script after boot. But if I restart the I'm using a |
This is one of the ugliest hacks I wrote this year, but it seems to work so far 🙈 # /etc/systemd/system/udev-restart-after-boot.service
[Unit]
Description=Restart udev service after boot (ugly hack to work around file system being readonly)
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/systemctl restart systemd-udevd.service
[Install]
WantedBy=multi-user.target There is surely a cleaner way to fix this problem though. |
I suspect this is a generic systemD issues, rather than Pi specific, so this issue will be closed within 30 days unless further interactions are posted. If you wish this issue to remain open, please add a comment. A closed issue may be reopened if requested. |
I wish to contribute with two facts:
This is the shell script (write same log message in two different file system paths) and rule used in both sceneries: $ cat /etc/udev/rules.d/70-ics-reles.rules Following is a partial list of /dev after insertion of USB serial device showing the symlink of the rule and the file written by the shell script: Here the content of log file created in /dev and /tmp: $ cat /dev/device-added.log $ cat /tmp/device-added.log Saludos. |
Uh oh!
There was an error while loading. Please reload this page.
Fresh install of 3/13/2018 stretch-lite on an rpi zero W. The only things that were done to the "stock" image:
headless config--added wpa_supplicant.conf and ssh file to /boot
raspi-config stuff
added /home/pi/.ssh directory (for ssh keys)
I have a udev rule that matches when a bluetooth device disconnects:
The script bt_disconnected runs when the device is disconnected, but fails if it tries to write to a file in /tmp or /home/pi. It fails, even if the rule is not added to /etc/udev/rules.d/99-bt.rules until after a fresh boot. File permissions are 777.
It seems the file system is readonly for udev after boot has finished.- At least directories /tmp and /home/pi--tried both those locations for the disconnects file). Yet, the logger command has no problem writing to /var/log/syslog.
Here's the script:
The udev rule triggers, when I disconnect a connected bluetooth device from the device. The logger command works and reports the user is root, when the command is not commented. But, the last line fails without writing to the file and a message in /var/log/syslog reports it exited with return code 1:
If the following command is executed:
sudo /etc/init.d/udev restart
future bt disconnects trigger the udev rule and the bt_disconnected script writes to the /tmp/disconnects file without issue.
Using the command:
udevadm control --reload-rules
doesn't "fix" the issue. Just the udev restart.
Workaround is to restart udev in /etc/rc.local or in a daemon that runs late in the boot process.
Maybe related--this message occurs in /var/log/syslog, whether my rules are in udev or not:
Not sure if it's normal, but I see this in dmesg after booting (before adding the udev rules);
Here's the syslog without the udev rules added:
syslog.txt
And, with the 99-bt.rules file:
syslog_after.txt
Note these records which only appear in /var/log/syslog when the 99-bt.rules file has the rule for triggering the script execution:
But, based on the timestamps and the location of these records in the /var/syslog file, they were written at shutdown, not at the beginning of the reboot sequence.
The text was updated successfully, but these errors were encountered: