Uswsusp is a program that allows you to suspend your computer to ram, to disk or even to both disk and then ram. This allows you to resume your work quickly if your battery is still working. If not, your computer will still be able to resume from disk.
Unfortunately, the Ubuntu package does not contain the s2ram binary that just suspends to ram (I don't need s2both nor s2disk on my stationary computer, I just want it to suspend to ram).
To be able to use s2ram on Ubuntu, you have to compile uswsusp by yourself.
Go to: http://prdownloads.sourceforge.net/suspend/suspend-0.8.tar.gz?download and download the sources. Then, untar and compile them.
Be warned that you will probably need to resolve some dependencies using apt-get or adept (namely: build-essential, pciutils-dev, libx86-dev).
To allow you to suspend your computer without root priviledges, do the following:
Finally, if you use an Nvidia graphics card, your X session will probably hang when trying to resume. To make it work correctly, you have to make some changes in xorg.conf.
Open /etc/X11/xorg.conf, find the "Device" section and add the following line:
Restart your X server (ctrl+alt+backspace) and you should have now suspend to ram working. Just type
You can now put an icon on the desktop or in the K menu.
If you want, you can make it the default in Ubuntu too but I found that a shortcut in the K menu is easier to use.