On Ubuntu 18.04, I would like to run a shell-script before systemd-udevd
starts.
The reason for that is this bug: Ubuntu 18.04 systemd-udevd uses high CPU, conflict with nvidia graphics
The solution, just moving rule 71-nvidia.rules
so it will not be found, will not work for me: I have a Razer Blade Stealth, which I operate with and without a Razer Core (with Nvidia card). When the laptop is connected to the Razer Core (via Thunderbolt-3), everything is fine. But when the laptop is not connected, I have the same problem as described in the other question.
As a workaround, I wanted to move /lib/udev/rules.d/71-nvidia.rules
to /lib/udev/rules.available/71-nvidia.rules
. The shell script should then use lspci
to determine whether an nvidia card is found. If an Nvidia card is found, it would create a symbolic link to /lib/udev/rules.available/71-nvidia.rules
at /lib/udev/rules.d/71-nvidia.rules
. If no Nvidia card is found, it would remove that symbolic link.
#!/bin/bash
set -e ; set -o pipefail
mkdir -p /lib/udev/rules.available/
if [ ! -e /lib/udev/rules.available/71-nvidia.rules ] ; then
mv /lib/udev/rules.{d,available}/71-nvidia.rules
fi
rm -f /lib/udev/rules.d/71-nvidia.rules
if lspci | grep nvidia ; then
ln -s /lib/udev/rules.{available,d}/71-nvidia.rules
fi
So, how can I get a shell script like the one above to run before systemd-udevd is started?
P.S.:
If anyone knows a better, smarter workaround, maybe with the built-in capabilities of systemd-udevd
, I'd be curious to know as well.
before
flag to run that script before systemd-udevd runs – George Udosen Sep 09 '18 at 07:46