Suspend/Resume in Karmic /2
Published by Luigi November 25th, 2009 in Linux, Hardware, MacPreviously I wrote that suspend/resume was not working in Karmic on my MacBook Pro 5.1, and I posted a solution. Now I found a better solution from the Apple Users forum on Ubuntu. The advantage is that with this fix, the suspend/resume is much faster.
First you need to revert the change I suggested previously.
Then... (copied from the forum)
install a package called uswsusp
sudo apt-get install uswsusp
the package carries two nice tools: s2ram and s2disk
First of all make sure they work launching
sudo s2ram --force
to suspend to ram or
sudo s2disk
to hibernate.
I personally don't care too much about hibernation. Nice thing about s2ram, though, is that it goes to sleep maintaining somehow the proper wifi settings so that when you open up the lid again the machine is immediately connected to the internet, exactly as it happens in OSX1. The resume takes about 5 seconds and you are ready to go.
By default gnome prompts you with the password after resume. If you don't like this behaviour, you can change it running
gconftool -s /apps/gnome-power-manager/lock/suspend -t bool false
you can of course use s2ram and s2disk as default tools. to do so, you need to replace two of the existing scripts.
sudo cp /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux.bak sudo cp /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux.bak
and then
sudo gedit /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux
replace what you find with:
#!/usr/bin/env bash /usr/sbin/s2disk
sudo gedit /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux
replace what you find with:
#!/usr/bin/env bash /usr/sbin/s2ram --force
Credits for this post: crocowhile
Luigi's notes on above post
1: this doesn't happen to me, it seems that, before suspending the wifi connection is brought down, then it needs to be restarted on resume. There is an option in the Gnome Configuration Editor apps/gnome-power-manager/general/network_sleep which is described as "Whether NetworkManager should disconnect before suspending or hibernating and connect on resume". By default this is disabled, which I think should mean to not disconnect/reconnect. I played a little bit with it; but it seems that is not taking any effect, and every time I resume the NetworkManager reconnects to the WIFI. Suspending with the command line, this doesn't happen, and the WIFI is immediately available; I need further investigations on this. I suspect the pm-utils is playing some quirk, and I cannot find a configuration variable for pm-utils to specify to avoid this.
UPDATE: NetworkManager is fixed!
I just found that the cause of the NetworkManager to disconnect/reconnect on suspend/resume was actually the pm-utils. So I modified the script located at /usr/lib/pm-utils/sleep.d/55NetworkManager to not manage the NetworkManager. I've commented the two lines in bold:
luigi@hal9000:~$ cat /usr/lib/pm-utils/sleep.d/55NetworkManager
#!/bin/sh
# If we are running NetworkManager, tell it we are going to sleep.
# TODO: Make NetworkManager smarter about how to handle sleep/resume
# If we are asleep for less time than it takes for TCP to reset a
# connection, and we are assigned the same IP on resume, we should
# not break established connections. Apple can do this, and it is
# rather nifty.
. "${PM_FUNCTIONS}"
suspend_nm()
{
# Tell NetworkManager to shut down networking
dbus_send --print-reply --system
--dest=org.freedesktop.NetworkManager
/org/freedesktop/NetworkManager
org.freedesktop.NetworkManager.sleep 2>&1 > /dev/null
}
resume_nm()
{
# Wake up NetworkManager and make it do a new connection
dbus_send --print-reply --system
--dest=org.freedesktop.NetworkManager
/org/freedesktop/NetworkManager
org.freedesktop.NetworkManager.wake 2>&1 > /dev/null
}
case "$1" in
hibernate|suspend)
# suspend_nm
;;
thaw|resume)
# resume_nm
;;
*) exit $NA
;;
esac
With this change now, from the time I open the laptop lid, it takes 2-3 seconds to wake up and be online. Wow!
UPDATE: Suspend-after-resume bug
During the resume it could happen that the mac goes back into a suspend (see gnome-power-manager bug #425411). This is resolved by the following:
- Run gconf-editor
- Go to apps -> gnome-power-manager -> actions
- Uncheck the box next to event_when_closed_battery.
7 Responses to “Suspend/Resume in Karmic /2”
Leave a Reply
Search
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Sep | Dec » | |||||
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | ||||||
Archives
- January 2010 (2)
- December 2009 (1)
- November 2009 (3)
- September 2009 (2)
- August 2009 (4)
- July 2009 (1)
- June 2009 (2)
- May 2009 (4)
- April 2009 (2)
- March 2009 (7)
- February 2009 (5)
- January 2009 (2)
- December 2008 (1)
- November 2008 (8)
- October 2008 (12)
- September 2008 (3)
- August 2008 (2)
- July 2008 (6)
- June 2008 (16)
- May 2008 (2)
- April 2008 (3)
- March 2008 (6)
- October 2007 (1)
- September 2007 (1)
- August 2007 (5)
- July 2007 (6)
- June 2007 (6)
- May 2007 (1)
- March 2007 (1)
- February 2007 (2)
- January 2007 (1)
- December 2006 (2)
- November 2006 (4)
- October 2006 (7)
- September 2006 (1)
- August 2006 (2)
- July 2006 (6)
- June 2006 (3)
- February 2006 (1)
- January 2006 (1)
- December 2005 (5)
- November 2005 (2)
- October 2005 (2)
- September 2005 (7)
- August 2005 (2)
- July 2005 (8)
- June 2005 (12)
Categories
- Books (7)
- Eclipse (10)
- Errors (2)
- Firefox (7)
- Hardware (14)
- Horror Code (8)
- Internet (17)
- Java (85)
- JavaScript (8)
- Life, universe and everything (29)
- Linux (44)
- Mac (18)
- Software (25)
- Speeches and Conferences (8)
- Web (19)
- Windows (16)
Latest
- Syntactic sugar and Java arrays.
- 3G USB Stick on Ubuntu
- Ipod touch with Linux
- Karmic and Luks: USB drive encryption made (almost) easy
- Suspend/Resume in Karmic /2
- Suspend/Resume problem in Ubuntu Karmic 9.10 running on MacBook Pro 5.1
- MacBook International Keyboard and Linux
- Mighty Mouse: reverse horizontal scrolling workaround on Ubuntu Linux 9.04
- Skype 2.1.0.47 beta released, and amd64 packages available!
- Linux RAM Disks
My open source projects
Blog License
Blogs I like
Friends' Blogs
- Antonio Terreno & Valter Bernardini
- Bruno Bossola
- Daniele Galluccio
- Domenico Ventura
- Ed Schepis
- Fabrizio Gianneschi
- Filippo Diotalevi
- JavaJournal.it Blog
- Luca Grulla
- Luigi Zanderighi
- Marcello Teodori
- Mida Boghetich
- Muralidharan Chandrasekaran
- Piero Ricca
- Renzo Borgatti
- Simone Bordet
- Uberto Barbini
- Valvolog
- Webtide blogs (Greg Wilkins & Jan Bartel)
Links








Hi Luigi, Thank’s for this really interesting post
It solved my suspend issue (not tried Hibernation, because it already works by default) but I have one minor new issue with screen brightness
I had previously downloaded nvida-bl package from Mactell PPA and put it in etc/modules in order to load it on startup and in order to change screen brightness (that doesn’t work on Karmic with Nvidia restricted drivers).
With your solution, after wakin from suspend, it seems that that module is not loaded because brightness is lower and i can’t change it (i click on the button, but brightness doesn’t increase
Can you help me?
Thank’s
DemoneIVo
Hi Ivo, I haven’t such issue. But you can try to add something like “modprobe nvidia_bl” somewhere - at beginning of the resume_video() function ? - of the file /usr/lib/pm-utils/sleep.d/99video
If it doesn’t work you may want to ask on the forum for further help:
http://ubuntuforums.org/showthread.php?t=1215928
I actually don’t use nvidia_bl, fortunately my mac works fine (and better) without it.
Good luck!
Luigi, how can you change brightness screen without nvidia-bl??
With Karmic and after the installation of Nvidia restricted drivers, i found that load this module on startup was the only way to allow screen brightness change.. Do you use another method?
I would remove nvidia-bl package if only i could normally change screen brightness…
Hi Ivo, I don’t know… I had nvidia_bl in my /etc/modules, but I removed after karmic update and the brightness works even better on my mac (macbook pro 5.1, alluminium)
I don’t know, but it seems that my systems loads mbp_nvidia_bl without needing to specify any particular configuration:
I suggest you to actively partecipate to the apple users on the Ubuntu forums, if you aren’t doing it already. It’s a great source of informations and a way to contribute to make ubuntu work on Apple hardwares.
Luigi.
Hi,
Beside the acpi irq suggestion that you gave in the other blog item, I have tried this one here as well on my Macbook pro 4,1 (that doesn’t suspend but instead hangs). The s2ram –force does not work either, unfortunately! There is a difference, in the sense that instead of going to a blanked screen with the acpi irq ‘remedy’, here I get a login console (but it is hung as well) and a message like “resume libgcrypt version 1.4.4″ type of message. But it does not resume.
Hi Iubuntu,
from the ubuntu community documentation wiki, they claim that the suspend/resume works out of the box with karmic. But evidently it is not. I have no idea to suggest you, but try to find somebody that solved your issue on the same hardware you are using.
I am sure that, with some patience, you will sort out this problem. Linux is always like this: to have everything working you need patience to write on forum and discuss with people, but at the end you will know your hardware better and get the best from your system.
Don’t give up! And best luck!
Luigi.
Hi, in the other post about karmic sound problem on resume I wrote:
I tried your tip too but it didn’t work for me…
Anyway the following workaround fixed the issue in a quite elegant way for now.
After resuming your computer, if the speaker-phones sound went away and only the headphones keep working, try the following from the command line to restore full functionalities to your sound system:
$ sudo alsa force-reloadciao.
Let me add that I don’t use a Mac, my karmic 9.10 is on a HP Compaq nx8220 laptop.
ciao.