How to permanently turn off wi-fi power management in Ubuntu
How to permanently turn off wi-fi power management in Ubuntu – Fixes loss of wi-fi connection when on battery power.
My better half recently installed Ubuntu 11.04 (Natty Narwhal) on her notebook and quickly realised that when she removed the AC power lead the wi-fi connection would cut out, only resuming when she plugged the power lead back in. This meaning she could not access or use wi-fi whilst running on battery power alone – which kind of defeats the purpose of having a laptop/notebook if you need the power cable plugged in at all times to surf the web.
Anyway, the root of the cause is that Ubuntu’s new default power management setting turns ‘on’ the power management for the wi-fi device when on battery power. Meaning you lose the wi-fi connection if you unplug the AC power from your laptop/notebook. There is a simple little solution that can fix this problem.
All we need to do is run a couple of commands and create or edit a file in /etc/pm/power.d that will basically tell Ubuntu to turn the wi-fi power management off and to keep it off permanently when in battery mode, so we can use the wi-fi wherever and whenever we choose to.To apply the fix, follow the steps below but make sure you do NOThave the AC power plugged into your laptop/notebook, follow the steps on battery power.
Step 1 – Check that wi-fi power management is turned on
In order to turn off the power management we first need to ensure that it is turned on.
*Open a terminal window by pressing Ctrl+Alt+t
*Now type: iwconfig and press Enter
‘iwconfig’ will then list all the available wireless devices connected to your system (see below)
Step 2 – Turning Power Management off
*Type: sudo iwconfig wlan0 power off – This disables the wi-fi power management
Step 3 will show us how to make this fix permanent by firstly moving to another directory and then editing or creating (if it doesn’t exist already) the file /etc/pm/power.d/wireless
Step 3 – Making the fix permanent – Moving to /etc/pm/power.d directory
We must now move to the directory/etc/pm/power.d we do this by typing the command below into the terminal (see image below)- Note, if the directory does not exist you must create it by typing: mkdir /etc/pm/power.d
*Type: cd /etc/pm/power.d and press Enter
Step 4 – Creating the wireless file in the /etc/pm/power.d directory
Once we are in /etc/pm/power.d we must create the wireless file.
*Type: sudo pico /etc/pm/power.d/wireless into the terminal command and press enter, this will create the wireless file and open the file for editing as a root user.
Step 5 – Add a couple of lines of code to the wireless file, save and exit and its all done !
Now that you are in /etc/pm/power.d/wireless we add two lines of code (shown below) which tell Ubuntu to stop managing the power management of our wireless device, thus keeping the wi-fi power management permanently turned off (even if we shut down or restart the system)
*Type: #!/bin/sh
/sbin/iwconfig wlan0 power off
Now save and exit – note if you can’t find a save button (like us) just close the terminal window and restart your laptop/notebook. The changes will take effect. Also note that when you reboot, do it on battery power, reopen the terminal and type iwconfig’ and check that the power management for your wlan0 device reads: OFF.
Sit back and enjoy browsing the web and having your laptop/notebook back to its good old self, without having to have your AC cable plugged in all the time.
Posted on September 25, 2011, in How-to-Guides, Uncategorized and tagged how-to guide, Natty Narwhal, power management, Ubuntu, ubuntu 11.04 wifi fix, wifi, wifi guide, wifi solution. Bookmark the permalink. 9 Comments.
I REALLY appreciate this article – the fix worked 100% on a new install of LinuxMint14 on a six year old Targa/MSI 812 MT30 notebook. Because the wireless network kept disconnecting I was convinced there was a hardware failure and I wasn’t far from throwing it in the trash (or selling it on eBay for spares!). As a newbie I found every step in the process was precise and accurate. My sincere thanks for your help and a great job well done
Thanks Tony, I’m glad it helped!
Thanks for that. Quick simple and to the point.
Thank you. The wifi on my girlfriend’s ultrabook kept not working, but my windows 7 laptop was fine, so I knew something was going on with Ubuntu. I noticed power management was turned on for wifi, but couldn’t figure out how to disable that (Ubuntu’s power management GUI is rather simplistic). Your post help immensely.
A tip: You can save a file in pico by pressing ctrl+o (says write out in pico)
In my case (ubuntu 13.10.), i also had to type:
sudo chmod +x /etc/pm/power.d/wireless
which made the change run after every start up.
thanks great help .. it worked for me … TIP : you can save the file using ctrl+o
THANK YOU!!! My wifi in my Lenovo Ultrabook U515 was dropping every 45sec after boot and I couldn’t do anything. I thought it might be hardware related since my laptop stopped even seeing my wifi card until I removed and reseated the card. Made my night!
Thank you for this!!! I’ve been doing it manually each time I take the laptop off A/C.
Suggestion: If you change WiFi devices or have more than one, the script should be able to handle all devices. The following will list all wireless interfaces and disable power management on them all:
IWC=/sbin/iwconfig
$IWC 2>&1|grep -v “no.wireless” | egrep “^[a-z|A-Z|0-9]” | awk ‘{print $1}’ | \
while read if
do
$IWC $if power off
done
exit 0
Ehud Gavron
Tucson AZ
Thank you so much for this post! It took me about 4-6 hours to finally figure out that once you remove the power cord, the wireless Power Management in Linux Mint kicks in that slows down the internet connection like anything!