Previously 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:

  1. Run gconf-editor
  2. Go to apps -> gnome-power-manager -> actions
  3. Uncheck the box next to event_when_closed_battery.

8 Responses to “Suspend/Resume in Karmic /2”  

  1. 1 Ivo

    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

  2. 2 Luigi

    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!

  3. 3 Ivo

    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…

  4. 4 Luigi

    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:

    luigi@hal9000:~$ lsmod | grep nvidia_bl
    mbp_nvidia_bl           3736  0 
    

    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.

  5. 5 lubuntu

    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.

  6. 6 Luigi

    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.

  7. 7 clata

    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-reload

    ciao.

    Let me add that I don’t use a Mac, my karmic 9.10 is on a HP Compaq nx8220 laptop.
    ciao.

  1. 1 Ubuntu 10.10 on MacBook pro 5.2 « jefsen's blog


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>



Calendar

November 2009
M T W T F S S
« Sep   Dec »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Follow me

twitter flickr LinkedIn feed

Subscribe by email

Enter your email address:

Archives


Categories

Tag Cloud


Listening