Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems

Wifi doesn't work after resume from suspend in Ubuntu 15.04 (Dell Latitude E4310) Linux

Posted by Admin • Sunday, May 17. 2015 • Category: Linux

Although toggling the hardware Wi-Fi switch usually fixed this issue, it was decidedly annoying for the non-technical user of this laptop. Googling for a well-known solution turned up several, but none of these worked. I found that either running
nmcli r wifi off
nmcli r wifi on
usually worked, so I tried to stick that into /etc/pm/sleep.d - but that script was never used. I then discovered that in 15.04 Ubuntu switched to systemd, which requires a service file in /etc/systemd/system/ In the end, it turns out that the problem is intermittent, therefore it is not possible to simply toggle networking blindly and hope for the best. Half the time it will not work. The ultimate solution turned out to be a combination of a toggle and a check, and both could be done via network manager, as follows:

Create a script

(doesn't matter where, but might as well throw it in here): /etc/pm/sleep.d/fix-wifi.sh
#!/bin/sh
# For some reason on the dell after suspend, wifi is on but really off..
case "${1}" in
        resume|thaw)
		logger -t wifidebug "Trying to restart wifi"
		until nm-online -t 5 ; do
			/etc/init.d/network-manager restart
			logger -t wifidebug "Wifi still no go"
			sleep 1
		done
        ;;
esac
Make it executable

Create a systemd service

/etc/systemd/system/fix-wifi-resume.service
[Unit]
Description=Toggle wifi because it doesn't come back on its own after resume
After=suspend.target

[Service]
Type=simple
ExecStart=-/etc/pm/sleep.d/fix-wifi.sh resume

[Install]
WantedBy=suspend.target

Enable the service:

systemctl enable fix-wifi-resume.service
Now try to suspend/resume. You should see the log statements in your syslog - otherwise, your script is not running. Once you get it working you can remove the logging.

0 Trackbacks

  1. No Trackbacks

1 Comments

Display comments as (Linear | Threaded)
  1. This worked for me on MacBookPro8,1 with Ubuntu 15.04. Thanks!!

Add Comment


You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

What is the primary language of this blog? (Anti-SPAM question)


Submitted comments will be subject to moderation before being displayed.