|  About Me  |  Blogs  |  Photos  |  Publications  |  Resume  | 

Software Suspend2

$ emerge -av suspend2-sources hibernate-script

This will install a gentoo kernel source with the software suspend2 patches. Configure the new kernel with the following options:

$ cd /usr/src; ln -s linux-2.6.12-suspend2-r6/ linux; cd linux
$ make menuconfig
Power management options (ACPI, APM)  --->
  [*] Power Management support
  Software Suspend []
  Software Suspend 2  --->
    <*> Software Suspend 2
    Image Storage (you need at least one writer)
    <*> Swap Writer
    <*> Warn if possibility of filesystem corruption
Cryptographic --->
<*> Cryptographic API
<*> LZF compression algorithm

To enable software suspend2 we need to pass resume2=swap:/dev/hdx to the kernel boot parameter, where /dev/hdx is your swap device, e.g.,

title=Gentoo Linux 2.6.12 Suspend2 r6
root (hd0,1)
kernel /boot/kernel-2.6.12-suspend2-r6 root=/dev/hda2 gentoo=nodevfs video=radeonfb splash=verbose,theme:gentoo quiet CONSOLE=/dev/tty1 resume2=swap:/dev/hda4

Now we can reboot into the new kernel.

In the beginning we also installed hibernate-script. It contains the script to hibernate the computer using suspend2 and allows you to configure various options on suspend and resume. I configured mine to use the following:

### suspend2 (for Software Suspend 2)
UseSuspend2 yes
Reboot no
EnableEscape yes
DefaultConsoleLevel 1
Compressor lzf
Encryptor none
PowerdownMethod 5

Verbosity 4
LogFile /var/log/hibernate.log
LogVerbosity 1
AlwaysForce yes
AlwaysKill yes
Distribution gentoo
SaveClock restore-only
### filesystems
UnmountFSTypes vfat ntfs smbfs nfs
UnmountGraceTime 1
OnResume 20 mount /mnt/shared
### misclaunch
OnResume 19 /sbin/rc default&
### modules
UnloadBlacklistedModules yes
LoadModules auto
GentooModulesAutoload yes
### services
StopServices net.eth0 net.eth1 ntp-client
### xstatus
XStatus gnome
XSuspendText Preparing to suspend...
XResumeText Resuming from suspend...

To hibernate, just run:

$ hibernate

Try hibernating in console mode first and see if it resume properly, then try in graphical mode. A word of warning, there’s a danger that your file system might get corrupted if you switch between an operating system or kernel which does not support software suspend2. If you have a shared partition between windows/linux, you must unmount that partition before suspend. If you boot into a kernel which does not support software suspend2, you must not try to resume from the suspend2 kernel later. In such cases, boot the suspend2 kernel with noresume2 in the kernel parameter instead.

I also configured ACPI to suspend when I close the lid, i.e.,

case "$group" in
    button)
        case "$action" in
            lid)
                if [[ ! -e /var/run/hibernate-script.pid ]] ; then
                    /usr/sbin/hibernate &
                    logger "hibernate"
                fi
                ;;

If you have other acpi script that gets called after hibernate gets called it might prevent hibernate from completing successfully. So perhaps one could add a check in the beginning of acpi script to abort if it sees that hibernation is running.

Leave a Reply

You must be logged in to post a comment.