Are you doing multi-tasking on your Linux machine and suddenly there is a power cut? Is your Laptop battery low or have any problem with your PC’s UPS? Then Hibernate is a good option for you! You can save all your work and resume where you left after switching on the computer.
What is Hibernate?
Hibernate is an option that allows you to save your system state immediately to your hard-disk, so that when you switch on back then all the programs can be restored from the hard-disk and you can start working again with the same system state as you had before switching off, without losing any data.
Hibernate saves all of your RAM data to hard-disk and restores back into RAM after you turn on the computer.
In Ubuntu Hibernate is not enabled by default, so you will have to do it manually. But don’t worry It will not take much time once you’ve all the requirements.
Before we continue there are some important things to know in order to enable Hibernate.
Why Hibernate is not enabled?
When Hibernate can save work in an emergency then why it’s not enabled by default. Well, Hibernate does not work properly with many hardware configurations in Ubuntu and other Linux distributions. If hibernate does not work properly then this might cause data loss after switching back on from hibernation. So PCs or Laptops capable of enabling hibernate option can enable it manually.
Is my Hardware is Capable of Hibernate?
You can simply know if your system works properly with hibernate or not. Simply save all your work (otherwise you’ll lose work if hibernate does not work properly) and Open up Terminal from dash or ctrl+alt+t.
Type and run the following command in Terminal.
$ sudo pm-hibernate
As you run the command, your computer will switch off. Switch back on and see if all your programs that were running before switching off are still running. If all programs are running then Hibernate is working properly.
There is one more common problem. As I told you above hibernate saves all your RAM data to the swap partition that you configured when you installed Ubuntu. That’s why the swap partition must be more than or equal to RAM. To check your swap partition open ‘System Monitor’.
In the Resources Tab check your RAM memory and Swap. If swap is more then you’re good to go, Otherwise, if you still need to enable hibernate then run gparted from a live cd and increase Swap memory.
Enable Hibernate in System Menu
The indicator-session was updated to use logind instead of upower. Hibernate is disabled by default in both upower and logind.
Run the following commands to enable hibernate.
$ sudo -i $ cd /var/lib/polkit-1/localauthority/50-local.d/ $ gedit com.ubuntu.enable-hibernate.pkla
Tips: if the config file does not work for you, try another one by changing /var/lib to /etc in the code.
Copy and paste the below lines to the file and save it.
[Re-enable hibernate by default in upower] Identity=unix-user:* Action=org.freedesktop.upower.hibernate ResultActive=yes [Re-enable hibernate by default in logind] Identity=unix-user:* Action=org.freedesktop.login1.hibernate ResultActive=yes
Log out or Restart your system and you’ve done. After you login, you’ll see hibernate option in your system Menu above in the tray.