UbuntuHelp:PowerManagement/Hiberate
来自Ubuntu中文
点击翻译: |
English |
请不要直接编辑翻译本页,本页将定期与来源同步。 |
目录
Introduction
When a computer hibernates, it will save its current state to the hard disk and power down completely. When next the computer boots, the prior state is restored just as you left it. There are three methods of hibernation:
- kernel (aka suspend or swsusp): The linux kernel includes built-in support for hibernation. This method is triggered by modifying
/sys/power/state
. - uswsusp: uswsusp is a rewrite of swsusp that does not rely on the kernel. Thus, uswsusp is a "userspace" tool because it is run entirely as a program separate from the kernel. It can be used by installing the package
uswsusp
and runningsudo s2disk
. This is reported to work in many situations where swsusp does not. Now supports encryption and compression for hibernation. - !TuxOnIce (formerly suspend2): TuxOnIce has more features and works with more hardware than the other two. Unfortunately, it requires building and patching kernel your own kernel.
Here is a great comparison table of the various hibernation methods. The general impression is that swsusp was first, so is in the main kernel trunk, uswsusp is cool because it is userspace, while TuxOnIce is better but can't get in the kernel. There is a feud between the authors. Although is seems most users greatly prefer TuxOnIce when they try it out ('it just works'), it may never make it into the kernel.
swsusp
In Ubuntu, the default method of hibernation is to use swsusp which is built into the kernel. Gnome and pm-utils will use this method unless configured otherwise.
The way you manually trigger hibernation using this 'kernel' method is to write 'disk' to /sys/power/state
. There are two modes of 'kernel' hibernation: platform and shutdown. If one does not work, you can try the other:
sudo -s echo platform > /sys/power/disk echo disk > /sys/power/state
Or:
sudo -s echo shutdown > /sys/power/disk echo disk > /sys/power/state
Platform is the default and recommended mode of hibernation. Unfortunately, the "platform" mode of hibernation does not work on some systems with broken BIOSes. In such cases the "shutdown" mode of hibernation might work.
See Also
uswsusp
The package uswsusp
(for Userspace Software Suspend) includes an executable called s2disk
. This program is an alternate method of hibernation. In general, s2disk
should not be called directly, but it can useful to do so for testing. Typically, the program pm-hibernate
is responsible for calling s2disk
.
The s2disk
program does the following in order to hibernate the machine:
- Tell the kernel to create a snapshot of the current system state.
- Read the snapshot data from the kernel and write it to the swap partition, possibly encrypting and compressing the data.
- Power off the machine.
When next you power up, the reverse happens:
- After a basic system boot, but before mounting any partitions,
resume
runs from the initrd. - The snapshot data from the swap partition is read (and possibly decrypted and decompressed).
resume
tells the kernel to restore the snapshot.- the kernel returns at the place it was before the hibernation.
To install s2disk
:
sudo aptitude install uswsusp
It is not generally useful to trigger s2disk
manually, unless you are debugging. For example:
sudo tail -f /var/log/pm-suspend.log & sudo s2disk
When you run s2disk
manually like this, it is likely that when you restore a lot of your devices will not be working.
To change your uswsusp settings:
sudo dpkg-reconfigure uswsusp
Alternately, you can edit /etc/uswsusp.conf
manually.
Integrating uswsusp with pm-utils
Currently, installing s2disk does not actually make it so that it is used by gnome or pm-utils. To do so, edit /etc/pm/config.d/00sleep_module and change the value of SLEEP_MODULE:
SLEEP_MODULE="uswsusp"
Then, to test, you can run this:
sudo tail -f /var/log/pm-suspend.log & sudo pm-hibernate
pm-hibernate
(part of pm-utils) is the preferred way to run s2disk
. By default, when you choose hibernate from within gnome, the command pm-hibernate
will get called.
Troubleshooting
- I have encryption configured and when I resume the wrong term is open. To get to the password prompt, I have to hit Alt-1.
See Also
TuxOnIce
See Also
- Suspend2Kernel - building a kernel in ubuntu that supported !TuxOnIce
- Ubuntu Brainstorm: TuxOnIce for Ubuntu
- How to install TuxOnIce for Ubuntu