Tuesday, February 24, 2009

Enabling TuxOnIce hibernation with EEEbuntu

Enabling hibernation (suspend to disk) support is a bit tricky, and I never found a good and complete tutorial. Also mine is not, but after several attempts I got hibernation working and now I want to record my steps, to be able to repeat them.
On EEEbuntu, hibernation is possible through "swsuspend" which is told to be slower than "TuxOnIce" (true) which is told to be faster than normal booting without resuming (true, but not impressive).
TuxOnIce needs to be patched into the kernel and compiled, and can completely replace swsuspend without reconfiguration.
My steps were (mixing different guides, an EEEbuntu forum post and TuxOnIce wiki):
  1. check that swsuspend is working;
  2. check that the package hibernate is installed;
  3. open a terminal for the normal user;
  4. become "root":
    # sudo bash
  5. install "git-core":
    # sudo apt-get install git-core
  6. clone the Array kernel for Intrepid:
    # git clone git://git.array.org/array/ubuntu-intrepid.git
  7. enter the directory:
    # cd ubuntu-intrepid
  8. join the split config files to a .config for the kernel:
    # cat debian/config/i386/config debian/config/i386/config.eeepc > .config
  9. check kernel version:
    # uname -r
  10. download a suitable patch from TuxOnIce site;
  11. apply patches:
    # bunzip2 -c path/to/patchname.patch.bz2 | patch -p1
  12. choose TuxOnIce options:
    # make oldconfig
    (press enter on all, except say Y for IGNORE_LATE_INITCALL);
  13. install some tools:
    # sudo apt-get install kernel-package libncurses5-dev fakeroot
  14. choose your config options:
    # make menuconfig
  15. move config where ubuntu looks for it, and make a backup:
    # cp .config debian/config/i386/config.eeepc
    # cp .config config
  16. if you want to change the config later, just do:
    # cp config .config
    # make menuconfig

  17. create a file:
    # sudo nano /usr/share/initramfs-tools/scripts/local-premount/tuxonice_do_resume
    with the following content:
    #!/bin/sh
    PREREQ=""
    prereqs()
    {
    echo "$PREREQ"
    }
    case $1 in
    # get pre-requisites
    prereqs)
    prereqs
    exit 0
    ;;
    esac
    if [ -d /sys/power/tuxonice ]; then
    echo 1 > /sys/power/tuxonice/do_resume
    fi
  18. compile:
    # fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers
  19. in the parent directory there are now two .deb packages to install:
    # cd ..
    # sudo dpkg -i *custom*.deb
  20. reboot using the new kernel and the new initrd;
  21. check the new GRUB entry has the boot kernel option like "resume=swap:/dev/xxx";
  22. check hibernate is working, by typing in a console:
    # sudo hibernate -v3 --no-suspend
  23. check that resuming is possible, because some buggy initramfs building scripts fail to include the tuxonice_do_resume file into the new initrd
    • inspect the new initrd:
      # follow this
    • if not OK, add the file, create an initrd again:
      # follow this
    • and replace it;
  24. check that the hibernate button is visible; if not, use gconf-editor to tick "can_hibernate" property (go to apps -> gnome-power-manager -> can_hibernate);
  25. test hibernating and resuming.
Even if the test succeded, I gave up: too slow. I'll wait for GRUB to boot directly from resume image.