TuxOnIce

From ArchWiki
Revision as of 16:44, 13 April 2009 by Litemotiv (Talk | contribs) (Tuxonice quick start guide - first iteration)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, 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

Otherwise, you need to patch, configure and compile your own kernel. See 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 either the swap or filewriter method.

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 hibernate 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

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
Reboot no
EnableEscape yes
DefaultConsoleLevel 1
Compressor lzo
Encryptor none

There is a number of additional settings and tweaks which you can set in /etc/hibernate/common.conf, more information about these are 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 fbsplash interface with a progress bar with tuxonice. To do this, install the userui package in the extra repo:

# pacman -S userui

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

## Specify a userui like this:
# text interface
ProcSetting user_interface/program /usr/sbin/tuxoniceui_text

or

## Specify a userui like this:
# fbsplash interface interface
ProcSetting user_interface/program /usr/sbin/tuxoniceui_fbsplash

The fbsplash interface also needs a fbsplash theme 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. When you use the kernel26tp 2.6.25 (or any other newer kernel versions, I guess), you have to edit /lib/initcpio/hooks/userui so that it searches for tuxonice at the right place, make it look like this:

# vim:set ft=sh:
run_hook ()
{
   if [ -d "/sys/power/tuxonice" ]; then
        suspend2ui="/sys/power/tuxonice/user_interface/program"
   else
        suspend2ui="/proc/suspend2/userui_program"
   fi
   if [ -e ${suspend2ui} ]; then
       echo "/sbin/suspend2ui" > ${suspend2ui}
   fi
}

Then run mkinitcpio -p kernel26-ice or similar


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 more advanced topics like problems with specific hardware and configurations.