TuxOnIce

From ArchWiki
Revision as of 10:22, 26 August 2009 by Buergi (talk | contribs) (→‎Recreating the initramfs: added note and workaround about bug #15240)
Jump to navigation Jump to search

This is a quick start guide for installing Tuxonice (formerly suspend2), an advanced suspend/hibernate framework which supports suspending to a swap-disk or a regular file with fast LZO-compression. Visit the Tuxonice website for a full list of features.

Preparing the kernel

Tuxonice consists of a kernel patch, plus an optional user interface. Only the kernel patch is necessary, the user interface merely provides a graphical interface displayed during the hibernation/resume cycle.

You can use the kernel26-ice package in the AUR. It automatizes all the patch routines, the compilation and installation of the kernel, the regeneration of the initramfs with an appropriate hook. If you use Yaourt this procedure is very simple:

 # yaourt -S kernel26-ice

You can also build the package manually, see Installing packages from the AUR for more information. Otherwise, you need to patch, configure and compile your own kernel, visit Kernel Compilation From Source and Kernel Compilation with ABS for instructions. The required patch can be obtained from the Tuxonice website mentioned above.


Next, install the hibernate-script package from the Extra repository which we will use to call Tuxonice. Hibernate-script is the default script developed by the Tuxonice development team:

# pacman -S hibernate-script

The configuration files for hibernate-script are in /etc/hibernate, we will get back to them shortly.

Setting up the bootmanager

Before your can use the suspend function, you need to add the "resume" parameter in your bootmanager, unless you have hardcoded your swap partition during the kernel configuration. The resume parameter points to the swap partition or swap file, below are the steps involved for both methods.

Suspend to swap partition

If your swap partition is for instance /dev/sda3, you have to append "resume=swap:/dev/sda3" as a kernel parameter in your lilo.conf file or GRUB's /boot/grub/menu.lst. For example:

title Arch Linux Ice
kernel /boot/vmlinuz26-ice root=/dev/sda2 ro resume=swap:/dev/sda3
initrd /boot/kernel26-ice.img

Adjust accordingly to your specific case. Then uncomment and set the swap method in /etc/hibernate/suspend2.conf:

SuspendDevice swap:/dev/sda3

Suspend to file

For the file allocator, you will have to prepare a hibernation file. First configure the /etc/hibernate/suspend2.conf file, uncomment the "FilewriterLocation" option:

FilewriterLocation /suspend_file 1000

1000 is the amount of diskspace reserved for the hibernation file, in this case 1000 Megabytes. Usually an amount of 50% - 75% of your total amount of RAM will suffice.

Next, run the following command to create the hibernation file:

# hibernate --no-suspend

Take a look in /sys/power/tuxonice/resume for what to pass to your kernel. You should see something like file:/dev/hda7:0x10011f, in which case you should append "resume=file:/dev/hda7:0x10011f" as a kernel parameter in your lilo.conf file or GRUB's menu.lst.

Recreating the initramfs

Note: Resuming doesn't work with mkinitcpio 0.5.25 due to a bug in /lib/initcpio/hooks/resume.

As a workaround downgrade to version 0.5.24 or replace the 6th line in /lib/initcpio/hooks/resume by

resumedevice=${resume#*:}
resumedevice=${resumedevice%:*}
if [-n "${resumedevice}" ] && poll_device "${resumedevice}" ${rootdelay}; then

If you use an initramfs, you need to add the resume hook in the HOOKS in the configuration of mkinitcpio. Additionally, if you want to speed things up by using LZO compression, add the lzo module to the MODULES array in the same file.

/etc/mkinitcpio.conf example:

MODULES="lzo"
HOOKS="base udev autodetect pata scsi sata resume filesystems"

Rebuild the initramfs:

# mkinitcpio -p kernel26-ice

Suspending and resuming

With hibernate-script, your preferred hibernation method can be set in the file /etc/hibernate/hibernate.conf. If you list several methods, the first one will be used. Note that hibernate can also be used with Suspend to RAM or vanilla swsusp, but this is not part of this guide.

For Tuxonice use:

TryMethod suspend2.conf

Specific settings for Tuxonice are in /etc/hibernate/suspend2.conf. Make sure that the following lines are uncommented and appropriately configured:

UseSuspend2   yes
Compressor    lzo

There is a number of additional settings and tweaks which you can set in /etc/hibernate/suspend2.conf and /etc/hibernate/common.conf, more information about these can be found on the Tuxonice website and on the Suspend to Disk page of this wiki.

Now try Tuxonice hibernation with the following method:

# hibernate -F /etc/hibernate/suspend2.conf

You can abort a suspend cycle if you press the escape key. If you press a capital R, you will force the system to reboot after hibernation.

If all goes well, you should be able to resume using the same Grub menu selection. If you make that option the default for Grub, you will always default to resuming if a resume image is available. Do never use a different kernel to resume than you used to suspend! If pacman updates your kernel, don't suspend before you have rebooted properly. It is recommended that you test the suspend/hibernate from a text console first and then once you have confirmed that it works try it from within X.

You can make this practice safer adding the hibernate-cleanup daemon to your DAEMONS array in /etc/rc.conf. This script will make sure that any stale image is deleted from your swap partition at boot time. This should make your system safe also in the case that you have chosen the mistaken kernel at the grub prompt. The hibernate-cleanup service is included in the hibernate-script package.

Using userui - a user interface for Tuxonice (optional)

Optionally, you can use a text or graphical (fbsplash) interface with a progress bar with tuxonice. To do this, install the tuxonice-userui package from the AUR. This package depends on the static freetype2 library that is provided by freetype2-static (also in the AUR).

In /etc/hibernate/suspend2.conf, set the desired user interface:

ProcSetting user_interface/program /usr/sbin/tuxoniceui_text       # Text interface

or

ProcSetting user_interface/program /usr/sbin/tuxoniceui_fbsplash   # Graphical fbsplash interface

The fbsplash interface also needs a fbsplash theme placed in /etc/splash/suspend2/.

The text interface may be good for debugging suspend2, as it displays some messages. You won't see a user interface for the first few seconds of the resume process unless you add the userui hook to your mkinitcpio (before the resume hook) configuration and regenerate your initramfs, but this is also optional.

Generate initramfs:

# mkinitcpio -p kernel26-ice

To test if userui works, switch to a text console and run:

tuxoniceui_text --test

For the graphical interface run:

tuxoniceui_fbsplash --test

References

  • The Tuxonice website and Tuxonice wiki are excellent sources of documentation.
  • More general information about suspend/hibernate with hibernate-script can be found on the Suspend to Disk page of this wiki. This also covers some advanced topics like problems with specific hardware and configurations.
  • Another good source of information is the Gentoo wiki