Hibernate Configuration

HIbernate

This section documents how hibernate was setup with Debian GNU/Linux on Linuxvillage's desktop and laptop computers. This disclosure is made in the spirit of Free Software so that users can help themselves and their neighbours.

Software Suspend2 was chosen for all desktop and laptop computer. Unlike suspend to RAM, hibernate does not use any power and is not susceptible to power outage. Hibernate does however, take slightly longer to hibernate and resume. Typically less than 1/2 a minute. No suspend to RAM is available on any machine.

All material presented are licensed under The GNU Free Documentation License.

Please report problems and direct enquiries to Contact US.


  1. Prerequisite
  2. Kernel Patch
  3. Hibernate Configuration
  4. Grub Configuration
  5. User Guide
  6. References

  1. Prerequisite

    To have Software Suspend2 working on your Debian machine, you will need:

    1. Root password.
    2. Kernel source, it can be downloaded from Synaptic Package Manager.
    3. Suspend2 patch file matching the kernel source version, it can be downloaded from www.suspend2.net. Download the patch into /usr/src directory.
    4. Hibernate application, it can be downloaded from Synaptic Package Manager.
    5. Download init-suspend2 to /usr/src for creating initrd image, can be found in Downloads.
    6. Optional: desktop file and graphic file for GNOME Desktop, can be found in Downloads.
    7. Optional: suspend2wrapper.sh to trigger older algorithm and add custom routines prior to hibernate, can be found in Downloads.
    8. Optional: suspend2-userui application, it can be downloaded from Synaptic Package Manager.
    9. Optional: kernel module sources, they can be downloaded from Synaptic Package Manager.
    10. Add user to the src group.

    Updated: 2006-11-17

    Back to top
  2. Kernel Patch

    Select Application->Accessories->Terminal and Change directory into source, uncompress the kernel source file and create a symbolic link to it.

    $ cd /usr/src
    $ tar --bzip2 -xf linux-source-2.6.18-product_XX.XX_i386.tar.bz2
    $ ln -s linux-source-2.6.18 linux

    Edit kernel-pkg.conf, to add maintainer, email and version information. You will need to SU to root prompt to accomplish that.

    $ su 
    # editor /etc/kernel-pkg.conf
    # exit
    ...
    # The maintainer information.
    maintainer := Linuxvillage.ca
    email := support@linuxvillage.ca
    ...
    # debian = $(version)-0.01.Custom
    debian = 10.03
    ...

    Test patch the kernel, if no errors patch it. Copy init-suspend2 to /etc/initramfs-tools/scripts/init-premount/

    $ cd /usr/src/linux 
    $ bzcat /usr/src/suspend2-2.2.9-for-2.6.18.3.patch.bz2 | patch -p1 --dry-run
    $ bzcat /usr/src/suspend2-2.2.9-for-2.6.18.3.patch.bz2 | patch -p1
    $ su
    # cp /usr/src/init-suspend2 /etc/initramfs-tools/scripts/init-premount
    # exit 

    Get a copy the running kernel's configuration as a starting point. Replace the name found in /boot directory. Change directory to source, initialize the environment and configure kernel.

    $ cp /boot/config-2.6.18-7-k7 /usr/src/linux/.config
    $ cd /usr/src/linux
    $ make menuconfig
    

    In menuconfig:

    • Select Power management options ACPI, ..., enable Suspend2 (CONFIG_SUSPEND_SMP=y, CONFIG_SUSPEND2_CRYPTO=y, CONFIG_SUSPEND2=y)
    • enable File Allocator, Swap Allocator and Replace swsusp by default (CONFIG_SOFTWARE_SUSPEND=y, CONFIG_SUSPEND2_FILE=y,CONFIG_SUSPEND2_SWAP=y, CONFIG_SUSPEND2_REPLACE_SWSUSP=y).
    • Select Cryptographic options from the root menu, enable LZF compression algorithm (CONFIG_CRYPTO_LZF=y).

    Compile the kernel.

    $ cd /usr/src/linux
    $ make-kpkg clean
    $ fakeroot make-kpkg --initrd --append_to_version -custom kernel_image modules_image

    If there are no errors, remove the init-suspend2 file and install the custom kenrel.

    $ cd /usr/src
    $ su
    # rm /etc/initramfs-tools/scripts/init-premount/init-suspend2
    # dpkg -i linux-image-2.6.18-7-custom_10.03_i386.deb
    # exit

    That's it for kernel compile and patching.

    Updated: 2006-11-17

    Back to top
  3. Hibernate Configuration

    After hibernate program from Synaptic Package Manager was installed. A few extra configuration is needed. Each computer model may have slightly different settings, the patchset form the private repository contain patch files to update them automatically.

    To change the configuration files, Select Application->Accessories->Root Terminal and edit the following list.

    • Hibernate Configuration

      # editor /etc/hibernate/suspend2.conf

      Change the swap partition and userui program during suspend and resume. Note: userui is optional.

      SuspendDevice swap:/dev/sda7
      ProcSetting userui_program /usr/sbin/suspend2ui_text
      # editor /etc/hibernate/common.conf

      Force suspend because of NVIDIA kernel driver, Full speed cpu, Lock GNOME screen during resume for security, Mute/Pause audio to save you from getting kick out of the library, switch to text mode and use dummy xserver for reliability.

      AlwaysForce yes
      FullSpeedCPU yes
      LockGnomeScreenSaver yes
      MuteAudio yes
      PauseAudio yes
      SwitchToTextMode no
      UseDummyXServer no
    • Grant Permission to Hibernate

      Create a group to contain permission for hibernation and add existing users to group.

      # addgroup hibernate
      # useradd -G hibernate johnny

      Use visudo to grant privilege for group hibernate to execute hibernation program.

      # visudo

      Add the following line in sudoer file. Replace suspend2wrapper.sh with hibernate if you don't want to use it.

      %hibernate ALL=NOPASSWD: /usr/sbin/suspend2wrapper.sh

      Note: when ever new users are added, you will need to add them to this group to allow for hibernation.

    • Suspend2 Wrapper

      Copy suspend2wrapper.sh to /usr/sbin

      cp /usr/src/suspend2wrapper.sh /usr/sbin

      suspend2wrapper.sh reverts to older alogrithm and contains model specific customization prior to calling hibernate.

      echo 1 > /sys/power/suspend2/full_pageset2

    For model specific details check the Product Information section in support.

    Updated: 2006-11-17

    Back to top
  4. Grub Configuration

    Edit grub parameters in /boot/grub/menu.lst and add the swap parameters. Replace sda7 with the swap partition on your system.

    # defoptions=... resume2=swap:/dev/sda7
    # altoptions=(single-user mode) single resume2=noresume ...

    Update grub. Make sure not to update the kernel parameters in the selection menu because they would get lost mysteriously next time grub is updated. Check the updated menu.lst file with less.

    $ su
    # editor /boot/grub/menu.lst
    # update-grub
    # less /boot/grub/menu.lst
    # exit

    The following lines should be in menu.lst.

    ...
    ## additional options to use with the default boot option, but not with the
    ## alternatives
    ## e.g. defoptions=vga=791 resume=/dev/hda5
    # defoptions=... resume2=swap:/dev/sda7
    ...
    ## altoption boot targets option
    ## multiple altoptions lines are allowed
    ## e.g. altoptions=(extra menu suffix) extra boot options
    # altoptions=(single-user mode) single resume2=noresume ...
    ,,,

    Updated: 2006-11-17

    Back to top
  5. User Guide

    User guide are specific to products, Laptops have special keys on the keyboard for hibernating and is triggered by acpi-support. Desktop computers uses GNOME menu items to trigger hibernation. Please check individual product for more detail documentation.

    Updated: 2006-11-17

    Back to top
  6. References

    • Software Suspend2 by Nigel Cunningham. You can find the kernel patch as well as many trouble shooting tips.
    • Grub originally designed and implemented by Erich Stefan Boleyn..
    Back to top