Tuesday, July 14, 2009

Ubuntu linux hibernation to file

The most recent project on my netbook was to get Ubuntu to hibernate correctly. Since netbooks are made for portability and conserving battery as much as possible is important I wanted to get this working badly. However, whenever I pressed the "Hibernate"button in the power options, it would just complain of not enough swap. So I decided to try and setup a file to use to hibernate to. In my situation this may not be the best option, but it was fun figuring it out. Here is what I ended up doing to get it to work.

Setup swapfile and some configuration for hibernation
Instead of rewriting a huge section, follow the instructions from: http://ubuntuforums.org/showpost.php?p=6570140&postcount=1

Additional configuration items
You can try to hibernate your system at this point now if you want. However, for me there was more work to be done. Here are the additional steps I had to take to take hibernation to completion.

Enable swap for hibernate then disable it after resume
  1. Create file /etc/acpi/suspend.d/01-swapctl.sh with the following:
    • #!/bin/sh
      swapon
    • Make sure to make it executable:
      • chmod +x /etc/acpi/suspend.d/01-swapctl.sh
  2. Create file /etc/acp/resume.d/99-swapctl.sh with the following:
    • #!/bin/sh
      swapoff
    • Make sure to make it executable:
      • chmod +x /etc/acpi/resume.d/99-swapctl.sh
Disable need for keyring password for Network Manager on resume
  1. Create file /etc/acpi/suspend.d/56-kill-wpa_supplicant.sh with the following:
    • #!/bin/sh

      killall wpa_supplicant
      sleep 5
    • Make sure to make it executable:
      • chmod +x /etc/acpi/suspend.d/56-kill-wpa_supplicant.sh
  2. Open gconf-editor:
    • gconf-editor
      • uncheck gnome_keyring_hibernate under path /apps/gnome-power-manager/lock
Restart Network Manager to refresh wireless
  1. Create file /etc/acpi/suspend.d/63-NetworkManager.sh with the following:
    • #!/bin/sh
      /etc/init.d/NetworkManager restart
    • Make sure to make it executable:
      • chmod +x /etc/acpi/suspend.d/63-NetworkManager.sh
Edit Shutdown Menu "hibernation button" script
  1. First we'll make a backup of the original script:
    • cp /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux.orig
  2. Now we will wipeout the original:
    • > /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux
  3. Now put the following contents into /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux:
    • #!/bin/sh

      /etc/acpi/hibernate.sh

      exit $RET
References:

Something I started to look into that I may try in the future:

No comments: