Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems
Linux

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

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.
Markdown format allowed


Submitted comments will be subject to moderation before being displayed.