What is the difference between Sleep (Suspend to RAM) and Hibernate (Suspend to Disk) ?
Entering a Sleep or Hibernate mode could be considered pausing the state of your computer. When restored, it allows you to continue from the same point, having the same programs and documents opened.
Sleep mode: It writes the computer’s state to RAM and cuts power to the rest of subsystems (CPU, hard disk etc). However, RAM is a volatile memory and requires power to maintain its stored information; when the power is interrupted, the data is immediately lost. For a laptop, keeping it in a Sleep state, means that RAM will continue to draw power from the battery, discharging it even when you think the laptop is off.
Hibernate mode: This mode, on the other hand, writes the computer’s state onto the hard drive (which doesn’t require power to maintain its information), therefore, in the case of a laptop, no power will be drawn from the battery while it’s in hibernation state.
Now for the tricky part. When entering a Linux OS in hibernating state, the computer’s state is saved to the swap partition which is required to be equal or bigger in size than the computer’s RAM. Linux users, while installing a distribution, set different sizes for their swap partitions, often smaller than their RAM, which will break the whole hibernation process. This is the reason why hibernation is not available by default.
To see if your swap partition size is equal to the RAM size, open a terminal and type:
grep MemTotal /proc/meminfo
grep SwapTotal /proc/meminfo
If the SwapTotal is equal or larger than the MemTotal, try to force your computer to enter hibernation state by running this command. Your computer will shut down and when the power button is pressed, it will try to resume to the previous state. However, this may or may not work so be sure to save all your work before doing this.
If everything worked out good, permanently enable hibernate support. In a terminal run this command:
sudo gedit /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla
(if you get a file not found error, try this command instead:)
sudo gedit /etc/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla
and search for these sections:
[Disable hibernate by default in upower]
[Disable hibernate by default in logind]
For both of them, replace ResultActive=no with ResultActive=yes (obviously).
Save and close the file. After a reboot, you should have the hibernate option enabled from the settings button.
If you want your laptop to enter into hibernate mode when the lid is closed, open this file:
sudo gedit /etc/systemd/logind.conf
Find this line:
Remove the hashtag (#) in front of it (if it has one) and replace suspend with hibernate. It will be available after the next reboot.