TuxOnIce

From Gentoo Linux Wiki

(Redirected from HOWTO TuxOnIce)
Jump to: navigation, search
This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc



Wikipedia has an article on:

Suspending or hibernating are alternatives to halting (turning off) the OS when powering down. Instead of closing all running applications, it writes the contents of the RAM (Random Access Memory) to the disk. Upon restarting the computer, the RAM is restored and users can continue exactly where they left off.

The RAM may be stored either on a swap partition or a file. In most cases, a swap partition will need at least as much capacity as the RAM. A workaround is available for computers with large amounts of memory which is usually not completely used.

As of 2.6.9, an earlier version of TuxOnIce (formerly Suspend2 (swsusp)) was implemented in the linux kernel. This guide describes installing and configuring TuxOnIce (a.k.a swsusp2) which is a newer and improved version. It has more features, and in many instances works much better than the one included in the kernel. TuxOnIce is not in the vanilla kernel, but a patched version is maintained in the sys-kernel/tuxonice-sources package.

Contents

[edit] Before You Start

This guide assumes some prior knowledge. Please read through the following if you need a refresher (this guide is already too long to detail these).

[edit] Official Documentation

You may also want to have a look at the Official TuxOnIce How-To.

[edit] Installation

There are two ways of getting a kernel with TuxOnIce support: (1) using a pre-patched Gentoo kernel, or (2) patching the vanilla kernel yourself.

[edit] Using tuxonice-sources

This is the recommended method because there are kernels with the Gentoo patchset that have the TuxOnIce patch applied to them. Emerging sys-kernel/tuxonice-sources will allow you to build a TuxOnIce-enabled Gentoo kernel. Once you install the package, head to the Recommended Packages section.

[edit] Applying the TuxOnIcePatch to the vanilla-sources

If you are already patching the vanilla kernel, you want this method.

  1. Install sys-kernel/vanilla-sources.
  2. Download the stable TuxOnIce patch that matches your kernel version from the TuxOnIce download page.
  3. Assuming the patches were downloaded to /usr/src/, apply the patch with the following commands.
Code: Patching the vanilla kernel
  % cd /usr/src/linux 
  % bzcat /usr/src/patch.bz2 | patch -p1
Note: The TuxOnIce patch below may not be applied to any sources other than vanilla-sources. Also, if errors occured when patching, make sure you downloaded matching kernel and patch versions.

[edit] Recommended Packages

Emerging the following packages are not required to get hibernation to work, but they make using it friendlier.

  1. sys-power/hibernate-script -- Simplifies the configuring and activation of hibernation.
  2. sys-apps/tuxonice-userui -- Provides graphical feedback about the hibernation process by either text-based output or support for fbsplash. Without this only a black screen will be visible while hibernation takes place.
    Note: sys-kernel/tuxonice-sources already has this as a dependency.

[edit] Configuration

[edit] Primary Kernel Configuration

If the kernel was patched correctly, the following should be enabled for you.

Linux Kernel Configuration: Enable TuxOnIce features
 Power management options (ACPI, APM)  --->
   [*] Hibernation (aka 'suspend to disk')
   (/dev/<swap-partition>) Default resume partition
   <*>   Enhanced Hibernation (TuxOnIce)  ---> 
     ---   Image Storage (you need at least one allocator)
     <*>   File Allocator
     <*>   Swap Allocator
     ---   General Options
     <*>   Compression support
     <*>   Userspace User Interface support
     (/sbin/tuxoniceui_text) Default userui program location 
     [ ]   Allow Keep Image Mode
     [*]   Replace swsusp by default
     < >   Cluster support  --->
     [*]   Checksum pageset2
     (25)  Default waiting time for emergency boot messages
     < >   Test pageflags
 Cryptographic options  --->
   <*>   LZF compression algorithm

Here are some things to notice about the configuration above.

  1. Default resume device name -- Set this to your swap partition. This setting can be overridden with the resume variable in the bootloader.
  2. Compression support -- This option may speed up the hibernation process if you have a fast CPU. You may want to have a look at some benchmarks from the TuxOnIce wiki about whether or not to use compression.
    Warning: Having this option requires you to build the LZF compression algorithm INTO the kernel, and NOT as a module. Make sure that you DO NOT compile LZF compression algorithm as a module. Otherwise, you will NOT be able to resume from a compressed image!
  3. Userspace User Interface support -- This option is required in order to use the tuxonice-userui package.
  4. Default userui program location -- Set this to /sbin/tuxoniceui_fbsplash if you are going to use fbsplash, or /sbin/tuxoniceui_text if not. (The tuxonice-userui package installs both these programs in /sbin, but if you have them in a different location, alter the path accordingly)
  5. Replace swsusp by default -- Not enabling this might cause a delay during the Grub boot loader stage without

[edit] Secondary Kernel Configuration for Kernels with SMP (Symmetric MultiProcessing)

You must activate CPU hot-plugging to enable suspend on SMP systems.

Linux Kernel Configuration: Enable CPU hot-plugging

Kernels before 2.6.22

Processor type and features  --->
 [*] Support for hot-pluggable CPUs (EXPERIMENTAL)

Kernel 2.6.22 and after:

Processor type and features  --->
 [*] Support for suspend on SMP and hot-pluggable CPUs (EXPERIMENTAL)
Note: If you have an old version of the TuxOnIce patch, you may need to disable SMP to enable the Software Suspend options.


[edit] Boot Loader Configuration

Skip this section if you set your swap partition in the kernel.

TuxOnIce will only resume if it finds valid data. If the swap device used for suspending wasn't set in the kernel configuration, it may be passed as a parameter to the kernel at boot time by adding it to the boot loader config file.

File: kernel parameter in bootloader configuration
    resume=swap:/dev/sda3
Note: If you have an older version of TuxOnIce (the one named Suspend2) then you have to use the resume2 kernel parameter instead of resume.


To verify TuxOnIce loads correctly, check dmesg output or message log for the following:

File: Sample dmesg output
   TuxOnIce 3.0-rc3, with support for checksumming, usm, compression, swap storage, file storage, userui.
   TuxOnIce: Normal swapspace found.


Here are some things you should keep in mind:

  1. To suspend to more than one swap partition, activate all of them with swapon and set one of them, either as the default swap device in the kernel config, or the resume kernel option.
  2. The kernel must be booted with the correct resume option before trying to hibernate. If it isn't, hibernation will refuse to activate.
  3. Should resuming not work, noresume parameter can be added to the kernel options when booting to tell TuxOnIce to ignore the saved data and not resume.
    Note: This option is called noresume2 if you have the older Suspend2 version.

[edit] Hibernate Script Configuration

Once you have emerged sys-power/hibernate-script package, the hibernate script will allow you to take care of any extra tasks before and after hibernating. A common use is to disable hardware or software that will not work with TuxOnIce.

The main configuration file is /etc/hibernate/hibernate.conf. This file will by default try several methods of hibernating until it finds one that works. These methods are configured in other files in /etc/hibernate/.

Find the one you wish to use (below we use /etc/hibernate/suspend2.conf and configure it according to your system needs.

[edit] Image Storage Methods

There are three ways to store the contents of the RAM: On the swap partition, in a swap file, or in a dedicated file.

[edit] Swap Partition

Point TuxOnIce to your swap partition by adding SuspendDevice swap:/dev/<swap-partition> to /etc/hibernate/suspend2.conf.

[edit] Swap File

To use a Swap File, do the following:

  1. Temporarily configure the hibernate script by adding SuspendDevice swap:/dev/sda3/<swap_file> to /etc/hibernate/suspend2.conf.
  2. Run hibernate --no-suspend and examine /sys/power/tuxonice/swap/headerlocations. The suspend device will look simliar to swap:/dev/sda3:0xfd400
  3. Use what you find in /sys/power/tuxonice/swap/headerlocations as the kernel parameter in the bootloader. In our case, we will add resume=swap:/dev/sda3:0xfd400 as the kernel parameter.
  4. Update the SuspendDevice config directive in the hibernate script (i.e. /etc/hibernate/suspend2.conf) to match the kernel parameter. In our case, we changed it to SuspendDevice swap:/dev/sda3:0xfd400.

For more information, see TuxOnIce HOWTO: Using a swapfile.

[edit] Dedicated File

Similar steps as using a Swap File.

  1. Temporarily configure the hibernate script by adding FilewriterLocation /<suspend_file_name> <integer size in megabytes> to /etc/hibernate/suspend2.conf. For example, FilewriterLocation /dedicated/file 1024 will create a the dedicated file in the /dedicated folder with a file name of file and a size of 1024 megabytes.
  2. Run hibernate --no-suspend and examine /sys/power/tuxonice/resume. The suspend device will look simliar to file:/dev/hda7:0x10011f.
    Note: If /sys/power/tuxonice/resume is not updated after running the command, delete the suspend file, add VerifyFilewriterResume2 yes to /etc/hibernate/suspend2.conf and re-run the command again.
  3. Once you've successfully created a suspend file, use it as the kernel parameter in the bootloader. In our case, we will add resume=file:/dev/hda7:0x10011f as the kernel parameter.

Be sure to update all your kernel lines with the resume parameter, or they won't be able to resume.

[edit] Problematic Modules

Some things in the kernel will have to compiled as modules so that they can be unloaded and loaded. Make hibernate-script to unload and reload them modules that are a problem:

File: /etc/hibernate/suspend2.conf
UnloadModules sd_mod
GentooModulesAutoload yes

GentooModulesAutoload loads modules from the file /etc/modules.autoload.d/kernel-2.6. Thus, make sure the modules you want are included in the list.

If you are not using Gentoo or have complicated module issues, you probably have to reload the module yourself by adding LoadModules <module name> to the configuration file.

Note: In 2.6.14 and older kernels, USB modules did not support the suspend/resume cycle. Newer kernels don't need any special configuration.

Have a look at /etc/hibernate/blacklisted-modules after emerging the TuxOnIce kernel to get an idea what you should compile as modules. You can also have a look at the TuxOnIce Hardware Compatibility List for further reference.

[edit] Restarting Services

To restart a certain service upon resuming, use the RestartServices config directive in the hibernate script config files. For example, adding RestartServices alsasound ntp-client will restart the ALSA and NTP services.

Here are some common services or modules that might need to be restarted.

  • ACPI -- If your laptop suspends when the lid is closed, it might double suspend because the opening of the lid triggers the suspend process again. The simple fix is to restart acpid by adding RestartServices acpid.(I am using Stop and Start, but restart should work just fine.)
  • Audio -- If your soundcard isn't able to resume on its own, the hibernate script can restart the appropriate service via RestartServices alsasound
  • Winmodem -- Suspending with the hsfmodem drivers loaded may lead to segfaults. Thus, add RestartServices hs to your configuration file.
  • Clock -- If your clock goes out of sync, you can resync it by running ntp-client on resume.

[added by a reader]

  • NetworkManager
  • NetworkManagerDispatcher -- If tuxonice Hangs on Atomic Restore randomly, both of this may be the cause. I edited my /etc/hibernate/suspend2.conf adding RestartServices NetworkManager NetworkManagerDispatcher and the problem seems solved. here is where I found it out: Tuxonice + Fedora = Hangs on Atomic Restore

[edit] Mounted Partitions

Accessing a mounted partition while it is suspended can easily corrupt the data on that device. If you have partitions that you would like to access while your Linux system has been suspended (e.g. a Windows partition), hibernate must unmount them before hibernation and remount them on resume:

File: /etc/hibernate/suspend2.conf
Unmount /media/c
OnResume 20 mount /media/c

[edit] Post Configuration

Add the hibernate-cleanup service to the boot startup level. This will invalidate any stale suspend images from swap partition and TuxOnIce filewriter files.

Note: It seems that this is done automatically now. Please verify and delete this section if that is the case. UPDATE (not from original author): actually, up to hibernate-script-1.97-r5 there's a warning upon compiling time that tells to do that, so at least for now it's not automatic; it's good to have it pointed here as not everyone reads those warnings.

[edit] Hibernating

Warning: If hibernation isn't resumed by the same kernel it was suspended with, or not resumed at all, filesystem corruption may occur.

To test the actions taken before suspending and after resuming, run # hibernate -n. This will simulate suspending, and in the end should return the system to a usable state. If it does not, modification to the configuration files may be needed (see below).

To minimize any risks resulting from unsuccessful resuming, try first without X (from console), then with X, but without being logged in (otherwise ). Unmount any partitions not being used before trying suspending for the first time.

Initiate suspend by running # hibernate.

[edit] Hibernating as a Regular User

You can use app-admin/sudo to allow non-root users to hibernate.

Note: See the official Gentoo Sudo(ers) Guide or the Gentoo Wiki Sudo config guide for more on sudo.

Either give everyone execution rights to /usr/sbin/hibernate, or create a new group (e.g. "hibernate") and add those users who should be allowed to hibernate. If you use fbsplash, you also need the rights to execute /sbin/splash.

[edit] Use Power Button to Suspend

First, configure your kernel with acpi. Specifically, you need to enable ACPI_BUTTON. (You may also need to enable the appropriate functionality in your BIOS to suspend rather than power off when the power button is pressed.) Then, install acpid, and add it to your default runlevel, to start it automatically:

# emerge acpid
# rc-update add acpid default

All events are passed to /etc/acpi/default.sh per default, which you edit next:

File: /etc/acpi/default.sh
#!/bin/sh
# Default acpi script that takes an entry for all actions

set $*

group=${1/\/*/}
action=${1/*\//}

case "$group" in
   button)
      case "$action" in
         power)  /usr/sbin/hibernate &
           ;;
         *) logger "ACPI action $action is not defined"
            ;;
      esac
      ;;

   *)
      logger "ACPI group $group / action $action is not defined"
      ;;
esac

Then simply reload acpid:

# /etc/init.d/acpid reload

Which should result in the hibernate script being called when you press the power button. This allows you to skip sudo configuration as well, since acpid runs with root priviliges anyway.

[edit] Other Tools

[edit] Using gnome-power-manager

With a little modification, gnome-extra/gnome-power-manager can be used as an interface to the hibernate scripts. It places an icon in the tray and can automatically suspend/hibernate on certain ACPI events (lid closure, low battery). gnome-power-manager uses HAL for everything, including suspend/hibernate. HAL must be compiled with the acpi USE flag for gnome-power-manager to work.

Since HAL is designed to work independently of the underlying platform, by default it tries a number of methods to suspend/hibernate the system and it doesn't always choose the best method. Specifically, if ACPI sleep states are enabled in the kernel, HAL may use these directly instead of the hibernate scripts. To overcome this, some scripts in /usr/lib/hal/scripts need to be fixed/replaced:

Warning: Backup the following files before modifying them.
File: /usr/lib/hal/scripts/hal-system-power-hibernate
#!/bin/sh

unsupported() {
    echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
    echo No hibernate script found >&2
    exit 1
}

if [ -x "/usr/sbin/hibernate" ] ; then
    /usr/sbin/hibernate
    RET=$?
else
    unsupported
fi

# Refresh devices when resuming from a hibernate
for type in button battery ac_adapter ; do
   devices=$(hal-find-by-capbility --capability $type)
   for device in $devices ; do
      dbus-send --system --print-reply --dest=org.freedesktop.Hal $device \
                org.freedesktop.Hal.Device.Rescan
   done
done

exit $RET
File: /usr/lib/hal/scripts/hal-system-power-suspend
#!/bin/sh

unsupported() {
    echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2
    echo No suspend method found >&2
    exit 1
}

if [ -x "/usr/sbin/hibernate-ram" ] ; then
    /usr/sbin/hibernate-ram
    RET=$?
else
    unsupported
fi

if [ $RET -ne 0 ]; then
    echo "org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported" >&2
    exit 1
fi

exit $RET

These scripts have been modified/simplified from the originals provided with HAL to ensure that HAL uses the hibernate scripts only to suspend/hibernate the system.

[edit] Dealing with Duplicate Button Events

I've written a little script to hibernate when I hit the power button. On my laptop, every time you hit the power button it registers two power button events in the acpid log. So I needed to work around it a little, to prevent two consecutive suspend-resume cycles everytime I hit the power. In /etc/acpi/events I have a script "power", which has:

File: /etc/acpi/events
# This is a sample ACPID configuration

event=button[ /]power
#action=sudo /usr/local/sbin/hibernate
action=/etc/acpi/events/start_suspend.sh %e

The %e passes the full entry of the acpi event to the script. I'm not using this yet. Here's the start_suspend.sh script:

File: start_suspend.sh
#!/usr/bin/perl
$DIR = "/etc/acpi/events";

$counter=`cat $DIR/buttoncounter | bc`;

if ( $counter == 0 ) {
# First button event, suspend computer

$out = `echo 1 > /etc/acpi/events/buttoncounter`;
$out = `sudo /usr/local/sbin/hibernate` || die "Unable to start hibernating: $!";

} else {
# Second button event, insert usb controller module

$out = `echo 0 > /etc/acpi/events/buttoncounter`;

}

What's nice about it is that it makes it easy to run additional things upon resume. I don't need this yet, but I can see how sometimes one would want to do this. As you can tell, it's basically a work-around for my dual-acpi-event-when-power-button-is-pressed problem.

However, in recent swsusp2-versions, there is an implemented workaround: two events within three seconds will be taken as one single event. So try for yourself if you need this.

[Edit] Doesn't work for me. I don't know why, but I always got 0 in the buttoncounter file. So I "translated" this script to shell-script and now its working. Now it looks like this:

File: start_suspend.sh
#!/bin/sh
DIR="/etc/acpi/events"
COUNTER=$(cat $DIR/buttoncounter)


if [ "$COUNTER" -eq 0 ] ; then
# First button event, suspend computer
        echo 1 > $DIR/buttoncounter
        hibernate 
else
# Second button event, reset counter
        echo 0 > $DIR/buttoncounter
fi

[/Edit]

[edit] Suspend When Battery is Low

This script will poll the battery status (in /proc/acpi/battery/BAT) in 60 seconds intervals and call an action if the capacity falls below a certain limit.

You should probably change the LIMIT, BAT, and HIBERNATE options. Then you could call this script in /etc/conf.d/local.start on startup for example.

File: /etc/conf.d/local.start
#!/bin/bash

LIMIT="200" ## Suspend if battery level drops below this (in mAh/mWh)
SLEEP="60"  ## Seconds between each battery level check
BAT="BAT1" ## Part of path: /proc/acpi/battery/BAT/
HIBERNATE="/usr/sbin/hibernate" ## command used to suspend
#HIBERNATE="echo 4 > /proc/acpi/sleep"

while [ true ]; do
  if [ -e "/proc/acpi/battery/$BAT/state" ]; then
     PRESENT=$(/bin/sed -ne "/present:/{s/^present:[ ]*\([a-z]*\)$/\1/p;q}" /proc/acpi/battery/$BAT/state)
     #echo $PRESENT
     if [ "$PRESENT" = "yes" ]; then
        STATE=$(/bin/sed -ne "/charging state:/{s/^charging state:[ ]*\([a-zA-Z]*\)$/\1/p;q}" /proc/acpi/battery/$BAT/state)
        BATTERY=$(/bin/sed -ne "/remaining capacity:/{s/^remaining capacity:[ ]*\([0-9]*\) m[WA]h$/\1/p;q}" /proc/acpi/battery/$BAT/state)
        #echo $BATTERY
        #echo $STATE
        if [ "$BATTERY" -lt "$LIMIT" ] && [ "$STATE" = "discharging" ]; then

           ## Comment out the following line if you don't
           ## want to log the event to system log:
           logger "Battery at ${BATTERY} mWh. Suspending to disk."
           #echo "Battery at ${BATTERY} mWh. Suspending to disk."

           ## Suspend:
           exec "$HIBERNATE"
       fi
     fi
  fi
  echo "Checking lid state:"
  if [ -e "/proc/acpi/button/lid/LID/state" ]; then
        LIDSTATE=$(/bin/sed -ne "/state:/{s/^state:[ ]*\([a-zA-Z]*\)$/\1/p;q}" /proc/acpi/button/lid/LID/state)
        echo $LIDSTATE
        if [ "$LIDSTATE" = "closed" ]; then
                exec "$HIBERNATE"
        fi
  fi
  sleep ${SLEEP}s
done


Tip: If you are using KDE with KLaptop, you can use it to hibernate. Open KLaptop dialog -> "Low Battery Critical". Activate "Run command" and add /usr/bin/sudo /usr/sbin/hibernate. You should also set the trigger. (You may need to add hibernate to your list of passwordless sudoers.)


Tip: If you are using laptop-mode-tools, you can use it to hibernate. Open /etc/laptop-mode/laptop-mode.conf and configure the section named "Auto-hibernation settings"
File: /etc/laptop-mode/laptop-mode.conf
# Should laptop mode tools perform auto-hibernation?
ENABLE_AUTO_HIBERNATION=1

# The hibernation command that is to be executed when auto-hibernation
# is triggered.
HIBERNATE_COMMAND=/usr/sbin/hibernate

# Auto-hibernation battery level threshold, in percentage of the battery's
# total capacity.
AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT=2

# Enable this to auto-hibernate if the battery reports that its level is
# "critical".
AUTO_HIBERNATION_ON_CRITICAL_BATTERY_LEVEL=0

[edit] Conky

It is generally a good idea to stop Conky before hibernation and start it after resuming. If you load it with a script such as:

File: /usr/bin/conkystart
#!/bin/bash
conky -c /path/to/config/files/.conkyrc1
conky -c /path/to/config/files/.conkyrc2
conky -c /path/to/config/files/.conkyrc3
conky -c /path/to/config/files/.conkyrc4

Edit /etc/hibernate/ram.conf and/or /etc/hibernate/hibernate.conf and add the following lines:

File: /etc/hibernate/ram.conf
OnSuspend 00 killall conky
OnResume 00 DISPLAY=:0.0 nohup conkystart &> /dev/null &

[edit] initramfs with TuxOnIce

Using initramfs with TuxOnIce is possible. To use this, you MUST edit your linuxrc (or init) script to contain echo > /sys/power/suspend2/do_resume AFTER the script mounts /sys, but BEFORE the script mounts your filesystem.

Warning: If the line comes after mounting the filesystem, you will most likely suffer from filesystem corruption.
Note: If using version suspend2-sources < 2.6.18 and hibernate-script < 1.93, then you want to use echo > /proc/suspend2/do_resume line instead. You will place this line after /proc has been mounted for the first time, but before /proc has been remounted.
Note: sys-kernel/genkernel-3.4.9 contains support for TuxOnIce by way of calling function tuxonice_resume in /usr/share/genkernel/generic/initrd.scripts from /usr/share/genkernel/generic/linuxrc. The function is called before even the correct root device is determined so it should be safe (no guaranties are implied :) ). This function should also behave correctly if the noresume kernel parameter is used.

[edit] Supported Video Adapters

One of the more problematic things when using suspend2 is the video adapter driver. Since the driver cannot be unloaded when suspending, it must function properly during this operation. Below are notes for ATI, Nvidia, and Intel Video Adapters.

[edit] ATI Users

Below is a sample configuration for ATI cards. It was used for Mobility Radeon x600, m24, in September 2007.

File: /etc/hibernate/hibernate.conf courtesy of Maniac
UseSuspend2 yes
Reboot no
EnableEscape yes
DefaultConsoleLevel 1
Compressor lzf
Encryptor none
SuspendDevice swap:/dev/hda6
ProcSetting expected_compression 50
ProcSetting userui_program /sbin/suspend2ui_text
ProcSetting extra_pages_allowance 5000

disable_textmode_support 0
Verbosity 0
LogFile /var/log/hibernate.log
LogVerbosity 1
Distribution gentoo

SaveClock restore-only
UnmountFSTypes smbfs nfs vfat ntfs
LockXScreenSaver yes
OnSuspend 15 sudo killall dhcpcd
OnSuspend 20 echo "Good night!"

OnResume 10 sudo /sbin/dhcpcd eth0
OnResume 10 sudo /etc/init.d/acpid restart
OnResume 20 echo "Good morning!"

UnloadAllModules yes
UnloadBlacklistedModules yes
LoadModules auto

GentooModulesAutoload yes
IncompatiblePrograms xmms

RestartServices alsasound hotplug
EnableVbetool yes
SwitchToTextMode yes

XStatus gnome
XSuspendText Preparing to suspend...
XResumeText Resuming from suspend...


[edit] Nvidia Users

It is recommended to use a driver version with 100.14.9 or greater.

[edit] Nvidia AGP Cards

If you have a Nvidia card which uses AGP, you have to disable AGPGart. For further details see the forum post at the end of this HowTo.

[edit] NVidia PCI Express Cards

If you have a Nvidia card which uses PCI Express, and you want to use Nvidia's properitary driver. Also, you will need to configure the device section for the video card in xorg.conf.

File: /etc/X11/xorg.conf
Section "Device"
   Identifier  "gf8"
   Driver      "nvidia"
   Option "NvAGP" "1" 
       # unsupported card
   #VideoRam    262144
   # Insert Clocks lines here if appropriate
EndSection

Then, edit your suspend2.conf and add this:

File: /etc/hibernate/suspend2.conf
ProcSetting extra_pages_allowance 0

This works for my GF8 8800 GTX. Maybe you have to change the number value. With a Onboard Geforce (i.e. Geforce 6150), the value should be 7200.

[edit] Intel 855GM and Non-Standard Displays

Many notebooks with Intel 855GM chipset are equipped with a non-standard display (e.g. a native resolution of 1400x1050). They do not have a VESA setting in the video BIOS matching the native display resolution. To overcome this use sys-apps/915resolution. 855resolution does the same thing but is not supported by the hibernate script.

The VGA BIOS modification made by this tool is lost during the power cycle. The solution is to enable it in the hibernate script configuration:

File: /etc/hibernate/common.conf
Runi915resolution yes


[edit] List of Configurations that Worked

There is also a list of supported hardware in the TuxOnIce Hardware Compatibility List.

  • Cards known to work:
CardKernelDriverNoteUser
Mobility Radeon X700 suspend sources 2.6.17-r2 Drakos7
Mobility Radeon X700 2.6.18 after the fix mentioned (doing atomic copy issue) blackr2d
Mobility Radeon X700 2.6.21-suspend2-sources; 2.6.22-suspend2-r2 11-drivers/ati-drivers-8.40.4 x11-base/xorg-x11-7.2 tw04l124 (forums.gentoo.org)
Mobility Radeon X600 (M24) all ati drivers, X11-7.0 and X11-7.1
Mobility Radeon X300 ati-drivers 8.23.7, X11-6.8.2-r7 (both PCI Express)
Mobility Radeon X200 suspend2-sources 2.6.20/2.6.21/2.6.22 ati-drivers: 8.32.5, 8.33.6, 8.34.8, 8.35.5, 8.37.6, 8.40.8; X11-7.1-X11-7.2
Mobility Radeon M6 (7000) X11-7.1
Radeon 9600 Pro ati-drivers 8.26.18, X11-6.8.2-r8
NVIDIA Geforce2 Go (NV11) =sys-kernel/tuxonice-sources-2.6.23 =x11-drivers/nvidia-drivers-96.43.01 =x11-base/xorg-x11-7.2 Disable kernel AGP and/or ensuring NvAGP=1. Enable within kernel config: "Suspend to RAM and standby" & "Hibernation (aka 'suspend to disk')" but do not enable "Enhanced Hibernation (TuxOnIce)". Install the "sys-apps/tuxonice-userui" package and hibernate as usual. Hibernating to disk or ram works using this configuration. Roger
NVIDIA NV34 FX5200 (glx)]-1.0.8762-r1
nVidia GeForce 6150 onboard + TurboCache(32MB) =sys-kernel/tuxonice-sources-2.6.23-r6 =x11-drivers/nvidia-drivers-169.09 =x11-base/xorg-server-1.4.0.90-r2 Kernel AGP disabled; NvAGP=1; ProcSetting extra_pages_allowance 7200; BIOS Option: TurboCache Size = 32MB, I've tested 256MB Turbocache, but it doesnt Work!! January 2008
NVIDIA FX5200Go, 6600GT, GeForce Go 7300 and GeForce 6100 (glx)]-1.0.8762-r1
    • nVidia FX5200 works fine with agpgart disabled and nvidia-drivers after removing nvidia-module from blacklist
    • nVidia GeForce4 440 Go with nvidia-[(kernel)|(glx)]-1.0.8762-r1
    • nVidia GeForce Go 7600 with nVidia Beta driver and with NUMA and agpgart disabled in kernel
    • Intel 855GM Integrated Graphics Device with X11-7.0
    • Intel 915GM Integrated Graphics Controller w/ x.org-7.1 and i810 driver
    • Intel 945G Integrated Graphics Controller w/ x.org-7.1 and i810 driver
    • SiS 760GX Integrated Graphics Chipset with X11-7.0
  • Cards known not to work:
    • nVidia GeForce Go 7600 with nVidia stable driver (patched sometimes works when GL acceleration is not used) or with NUMA or agpgart enabled in kernel

[edit] Troubleshooting

[edit] Hanging at "Doing atomic copy"

If suspend hangs with a message "Doing atomic copy", try disabling the following options in the kernel:

Linux Kernel Configuration: Disable local APIC support
-> Processor type and features
 [ ] Local APIC support on uniprocessors
 [ ]   IO-APIC support on uniprocessors (NEW)
Note: In certain configurations (e.g. SMP enabled) these options are not visible.

Also check if kexec system call is enabled

Linux Kernel Configuration: Enable kexec system call
-> Processor type and features
 [*] kexec system call

[edit] Pageset Problems

[edit] ATI fglrx Driver

If the ATI binary module is loaded and suspending fails with an error similar to:

Pageset1 has grown by 4901 
pages. Only 100 growth is allowed for.
Suspend failed, trying to recover...

and eventually hard locks the system, add the following to the hibernate script configuration:

File: /etc/hibernate/suspend2.conf
ProcSetting extra_pages_allowance 7500
Note: For Mobility X1600: Set extra_pages_allowance to 0 (with every other value it crashes after some resumes).

[edit] suspend2-2.2.9 and Kernels 2.6.18/19

Suspend2-2.2.9 for kernels 2.6.18 and 2.6.19 introduced a new algorithm for calculating which memory pages require atomic copy, and which don't. This new algorithm still has a few bugs, and can lead to failures in suspending, especially when suspending repeatedly. If older versions of the Suspend2 patch worked but version 2.2.9 doesn't, try switching to the old algorithm.

Add the setting to startup if not using hibernate script:

File: /etc/conf.d/local.start
# Switch to old suspend2 algorithm
echo 1 > /sys/power/suspend2/full_pageset2

or to the hibernate script config:

File: /etc/hibernate/suspend2.conf
# Switch to old suspend2 algorithm
ProcSetting full_pageset2 1

[edit] Poor Graphics Performance After Resume

If you encounter poor graphics performance after resume (GPU intensive applications may even freeze for several seconds from time to time), try enabling DummyXServer mode in /etc/hibernate/hibernate.conf.

File: /etc/hibernate/hibernate.conf
### xhacks
SwitchToTextMode yes
UseDummyXServer yes

[edit] Random Crashes During Suspend

Make sure you compile black-listed drivers in the kernel as modules. More information can be found in the Problematic modules section.

[edit] Incorrect Num Lock LED Status After Resume

After resuming the numlock LED might be turned off, while numlock is actually enabled. You'll have to press the numlock key one or two times to get LED and numlock status in sync. This can be fixed by installing x11-misc/numlockx (emerge numlockx) and adding the following two lines to the appropriate configuration file:

File: /etc/hibernate/suspend2.conf
OnSuspend 50 numlockx off
OnResume 50 numlockx on

This will make sure numlock is enabled on resume.

[edit] BIG FAT WARNING!! Failed to Translate "..." Into a Device ID

If you get this error message when you boot the system with a suspend2-enabled kernel, swsusp2 probably does not know how to access your swap partition -- even though the same kernel without suspend2 can access it. If the swap partition is on a SATA disk, using the new SATA drivers (kernel 2.6.19 and higher) might help. During kernel configuration, disable the section "ATA/ATAPI/MFM/RLL support" entirely; instead, enable "Serial ATA (prod) and Parallel ATA (experimental) drivers", but not as a module, of course. Under "SCSI device support", enable "SCSI disk support", and, optionally, "SCSI CDROM support".

For more information, check the forum thread that discussed this issue.

[edit] Tips & Tricks

  • To make swsusp reboot rather than shut off, press "R" while suspending (this toggles it)
  • Change verbosity (console logging level) while suspending/resuming by pressing 0 and 1
  • Should resuming not work for some reason, when using TuxOnIce you have to add noresume to your kernel boot options. With the older Suspend2 versions, use noresume2.
  • To solve module un/loading permissions (udev here) call OnResume 10 /sbin/pam_console_apply in hibernate.conf. This seems to work with /dev stuff too. If you don't have pam_console_apply, re-emerge pam with pam_console USE flag.
  • For swap suspend, your swap partition must be of type "82", or suspend2 will refuse to write to it. Unfortunately, there's no loud error message like "suspend2 cannot write to swap partition". It will just complain that it couldn't free enough memory. Apparently, "swapon <partition>" doesn't really care about the partition type, so this could be masked if you didn't set the partition type correctly.
  • To enable Wake-on-LAN (WOL) with suspend to RAM, make sure you set your ethernet device to wake on PHY activity. To do this, add ethtool -s ethX wol pg to your startup scripts (e.g. /etc/conf.d/local.start). The p flag enables wake on PHY activity, the g flag enables wake on MagicPacket. Another place to stick it is in /etc/hibernate/ram.conf like this: OnResume 10 /usr/sbin/ethtool -s ethX wol pg. On some systems, this is necessary where the NIC needs to be told every time after a resume to wake up on PHY activity.

[edit] Links

Personal tools