Suspend and Hibernate

From gr0x0rd
Jump to navigation Jump to search

Configuring Hardware - Suspend and Hibernate

If you have a laptop, chances are you'll want your system to go to sleep based on various actions, such as closing the lid when running on battery power. There are a number of packages that can perform suspend and hibernate functionality, but the most compatible one is the sys-power/pm-utils package.

$ sudo emerge -av sys-power/pm-utils

You can test to see if your system is capable of suspending or hibernating by calling

$ sudo pm-suspend

and

$ sudo pm-hibernate

respectively.

Not all systems can suspend or hibernate easily; these features are very dependent on your kernel configuration. Some drivers, such as USB, network and sound, may need to be unloaded before going into either of these states, and loaded again when the system resumes. To enable this, you'll first need to compile the necessary components as modules in the kernel. Once you've done this, you can test the effect manually before automating it by issuing the command

$ sudo modprobe -r modulename

before suspending or hibernating and calling

$ sudo modprobe modulename

once the system has resumed. If you've found the necessary configuration allowing your system to suspend or hibernate and resume successfully, you can automate this by creating and editing /etc/pm/config.d/modules. This example unloads the USB, USB 2.0 and USB 3.0 modules.

$ sudo nano -w /etc/pm/config.d/modules

/etc/pm/config.d/modules

SUSPEND_MODULES="xhci_hcd ehci_hcd uhci_hcd"

You should now be able to suspend without having to unload the modules above manually. If things seemed to work, you can check your logs

$ sudo tail -100 /var/log/messages

to ensure the modules were loaded after resuming.