This week I started thinking why I was still shutting down my computer every time I wanted to stop using my notebook, and got that I could make my suspend-to-ram works with my Gentoo, so I could always just suspend my gentoo instead of shutting it down every time.
The first thing that I did was read the Gentoo Power Management Guide, that helped me setting lots of things to use my battery in a good way. After setting everything I started to look how I could use suspend-to-ram (yes, I didn’t want to use suspend-to-disk). I did everything that the guide tells and got nothing, just a black screen when getting from suspend mode.
After searching a lot at Linux ThinkPad mailing list and other sites I got the idea of how this thing could work, so, I started working on it.
Note: I have a ThinkPad T60 with a Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller, probably it’s different if you have an ATI instead of an Intel video card.
Here I’ll show all the steps to make your suspend works with your thinkpad with Gentoo.
Kernel Configuration (2.6.21)
The first thing was setting the Linux Kernel so I could make suspend works correctly, and here is my kernel configuration:
Processor type and features --->
[*] Local APIC support on uniprocessors
[*] IO-APIC support on uniprocessors
Power management options (ACPI, APM) —>
[*] Power Management support
ACPI (Advanced Configuration and Power Interface) Support —>
[*] ACPI Support
[*] Sleep States
<*> IBM ThinkPad Laptop Extras
When using the Intel video card, you’ll have to pass an additional parameter to acpi to make suspend works (acpi_sleep), here is my gentoo entry:
# For booting GNU/Linux
title Gentoo GNU/Linux 2.6.21-gentoo
kernel /boot/kernel-2.6.21-gentoo root=/dev/sda2 vga=792 video=vesafb:mtrr,ywrap acpi_sleep=s3_bios
After setting your kernel, you can use just s2ram to do the suspend (recommended for testing purpose), or use the hibernate-script, that does lots of things in you system before and after supend (recommended for normal use).
If you use Gentoo, you’ll see that we don’t have the s2ram ebuild in portage tree yet, you’ll have to use the Sunrise Overlay’s ebuild to install s2ram for you. To install Sunrise Overlay just go to http://overlays.gentoo.org/proj/sunrise and follow the instructions.
After getting the s2ram, you can test if the suspend is working or not (first try without X, to make sure that’s not a problem with you video card).
To test suspend with s2ram:
host ~ # s2ram -f -p -m
Probably, if everything is ok in your kernel, you’ll see that your notebook will be in the “sleep” state (that’s nice, first step🙂. To get to your system again just type “Fn” and beg to see your shell again🙂
Here is a couple of results that I got:
1 – The system got working again, but my screen was all black (you can still give Ctrl + Alt + Del to restart it);
2 – The system froze with just a “INU” written in the screen;
3 – The shell😀
The first problem happens to me when I’m not using the correct parameters with ACPI, at grub configuration. Try passing nothing to the kernel, just s3_mode or both s3_bios and s3_mode (acpi_sleep=s3_bios,s3_mode) to see if you get into better results.
The second one happens when I don’t give “-m” flag to s2ram. Try testing with “-s” instead of “-m” to see if you get different results (‘s2ram –help’ gives you all the options). This problem also happens when I compile my kernel with the “Tickless System”, I don’t know why exactly, yet😦
The third one is the better one, and if you get to this point it’s time to go to the next step🙂
The hibernate-script helps you a lot getting your system to suspend status, letting you configure what you think it’s better to do before and after going to suspend state (unloading modules, restarting services and etc). To suspend your system (suspend-to-ram), hibernate-scripts uses s2ram or just the sysfs to change your system to suspend state. If you have s2ram installed (what I think is what you should do), you just have to set hibernate-script config files correctly (/etc/hibernate) and install it with a patch that I did to activate the s2ram “-m” flag.
At the moment, the newest hibernate-script that we have at gentoo is the 1.95 (masked with ~x86). With this version we have 2 new options that we could pass to s2ram when suspending our system (-s and -p), but we don’t have the “-m” that we need (when running with the newest intel video driver at the moment). So, to deal with this I made a patch to add this new flag and sent to hibernate-script’s owner, but it’s not upstream yet. To let you use hibernate-script with my patch, I changed the ebuild file, adding the patch. You can get it here hibernate-script ebuild.
[Notice] You don’t need to do this anymore, as I sent the patch to the hibernate-script’s maintainers and it’s now upstream, you can use the ebuild >= 1.95-r3
After installing hibernate-script, you’ll just need to set all options correctly at the config files, and here are my files:
Now, after setting your files you’re able to use ‘hibernate-ram’ script to suspend your system🙂 (you can also give it a try with X opened🙂.
Fn + F4
Ok, now you got everything working to make your system suspend and get back to work normally, but we’re still not using the “Fn + F4” to go to suspend state (that runs hibernate-ram automatically).
To make this work (after installing acpid), just put this file at /etc/acpi/events:
event=(ibm/hotkey HKEY 00000080 00001004)
Now just give ‘/etc/init.d/acpid restart’ and start using “Fn + F4” to go to suspend mode🙂
I hope that this can help you, at least a little, setting your system to be able to get to suspend mode. If you’re still facing problems with it, don’t give up, setting this is not that easy as we all wanted to be😦
If you think that I could help you, just send me an email to rsalveti-NOSPAM-at-gmail-com, I’ll be glad to help (if you want my kernel’s .config file just send me an email too).
Here is where you can find more information about this (because it’s not that ok yet with most of notebooks):
Thanks for reading🙂