In previous posts, I found a workaround for the iwlwifi crashing driver. In this post, I wrote small script to detect the crash and apply the workaround. Also, I installed systemd service to run the script on boot so i don’t have to.
Starting with the script. It’s basically while(1) to monitor the crash
found=0
while [ $found -eq 0 ]
do
rm -f /tmp/d.log
dmesg > /tmp/d.log
if tail -n 5 /tmp/d.log |grep -q "Failed to wake NIC for hcmd" ; then
echo "Fixing iwlwifi"
echo "1" > /sys/bus/pci/devices/0000:03:00.0/remove
echo "1" > /sys/bus/pci/rescan
fi
sleep 5
done
The service itself is very simple, just ExecStart
to call the script.
[Unit]
Description=Fix iwlwifi crash
[Service]
ExecStart=/bin/bash /home/user/fix-iwlwifi-crash.bash
[Install]
WantedBy=multi-user.target
To install the service, I just need to create /etc/systemd/system/fixiwlwifi.service
and i am good to go.
sudo touch /etc/systemd/system/fixiwlwifi.service
The last thing is starting the service and enabling it.
sudo systemctl start fixiwlwifi # to start the serveice
sudo systemctl enable fixiwlwifi # to enable at boot time