Hibernation in Gnu / Linux

Hibernate menu in Ubuntu.

Many of you will tell me that hibernation technology is not something new, but it is being the center of many articles and publications due to the recent problems that both proprietary systems and distributions as well as users are having lately with hibernation.

Here we will not talk about the problems that Windows 10 has with hibernation, but we will talk about this utility in the main Gnu / Linux distributions, as well as its differences with respect to other ways to shut down or suspend the computer and thus know which is the best option we have for each situation.

We will not mention all the distributions that are currently available to everyone, but we will talk about hibernation on major Gnu / Linux distributions that currently exist.

First we have to know what hibernation is and what it is not. Hibernation is a process of the operating system in which all the data, services and settings that we are using are "frozen" in order to turn off the computer and restart it as it was.

Thus, hibernation does not mean leaving documents and files as they were when we turned off the computer to use them again, nor does it mean suspending the computer. It is somewhat faster than the former and less expensive than the latter.

What is suspension?

Suspend a team or enter in sleep mode means that the operating system creates a live image of the entire system (personal data included) and send it to ram or volatile memory of the computer in order to turn off the rest of the components, but the ram memory and the motherboard continue to work although at a slower rate.

Going to sleep means that the equipment continues to consume power, although less than fully operational and will be reactivated with a key or mouse gesture or simply by lifting the lid in the case of laptops.

This method is really useful in computers that have more than 2 Gb of ram memory and little internal storage on the hard disk (for example, because it is an SSD disk).

What is restart with open documents?

Operating systems like MacOS have a hybrid function that It supposes shutting down the operating system but when it is turned back on, the operating system opens the latest applications that have been closed or certain documents.

This is practical for many, so many Gnu / Linux distributions do the same. However, this option is still a restart or a simple shutdown of the computer, with the subsequent initial loading of processes and configurations that is done at each startup, something that we can do manually but that can slow down the startup of the operating system.

So what is hibernation?

Hibernation is a process in which a live image of the current system is created, but it is not saved in ram memory but in swap memory or hard disk swap memory. That is, on the disk and therefore can be turned off without erasing the information.

This means that the computer can be turned off because it has nothing in the ram memory, the volatile memory, but the system load is not as long as at the start of the operating system, since the image is used.

All the information of the system is dumped in a single file that is the file that is loaded, therefore also we will need to have a hard drive with a large capacity to be able to use hibernation no problem.

Can i have hibernate function in gnu / linux?

We can only have this function if the Linux kernel really supports it. This is important to remember because if we want to use a kernel compiled by us we must have this function activated, otherwise we will run out of this functionality and we will not be able to activate hibernation.

Window with the menu to hibernate, suspend and shut down the computer.

However, the most common is to use the kernel offered by the distribution, a version in which the hibernate function as well as other functions and drivers are enabled. So the normal thing is that hibernation is present in our computer with Gnu / Linux.

How do I activate hibernation on my Gnu / Linux distribution?

As we have said, hibernation is present in all Gnu / Linux distributions (at least most). This means that just go to the shutdown menu on our desktop and we will find the option to hibernate, along with shutting down, restarting, suspending and logging out. Once we are in hibernation mode, we only have to press the power button to activate the system again.

If we want to use this function through a terminal command, first we have to have the pm-utils tools installed, something that surely will already be. But if we have any error messages, we may not have these tools installed, which are found in all official distributions repositories. Thus, if we have these tools, to enter hibernation mode we have to use the following command:

sudo pm-hibernate

If we have a distribution that is based in ArchLinux or derived from it, we only have to write the following:

hibernate -F /etc/hibernate/ususpend-disk.conf

In the case of using OpenSUSE, we have to use the following command:

systemctl hibernate

If we are more risky and we have a distribution that is based on or is Gentoo, the command is as follows:

pm-hibernate

This is the general rule, but there are some exceptions like Ubuntu.

How to enable hibernation in Ubuntu

Although Ubuntu allows the system to go into hibernation in its kernel, this option is not enabled by default in the distribution and we have to activate it ourselves. But this it can be fixed in a very easy way.

First we have to create a text file with gedit and write the following in 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;org.freedesktop.login1.hibernate-multiple-sessions

ResultActive=yes

We will save this file with the following name:

com.ubuntu.enable-hibernate.pkla

Now we have to open our file manager with administrator permissions and paste the file that we have created in the following folder:

/etc/polkit-1/localauthority/50-local.d

Once we have pasted the file, we close all the windows and restart the operating system so that the appropriate changes are applied. And after the system restart, we will see how the option of this function is now available in the desktop menus of our Ubuntu and not just through the terminal.

Hibernate in ubuntu.

Conclusion on hibernation

Hibernate is generally more environmentally friendly than sleep, but we must take into account our needs. If we need a quick start, suspension is the fastest option of them all.

If, on the other hand, we want to save energy and resources, restarting with opening documents is the best option. But if, on the contrary, we do not have problems with resources but we do not want to waste energy, hibernation is the best option and therefore it is usually the best suited to modern equipment where there are no limits on hard drive space but there are battery problems.


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

10 comments, leave yours

Leave a Comment

Your email address will not be published.

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Gregory ros said

    So suddenly an article / discussion comes to mind, I don't remember where I read it, in which it was said that swap is no longer necessary if we have more than 8GB of ram. But if we take into account options such as hibernation, no matter how much ram we have, there are no more noses than to have the swap partition yes or yes, and also the reason why it is recommended that its size be, at least, that of ram memory.

    1.    01101001b said

      I know I am responding to a comment from 2 years ago, but it is because no one pointed out in the comments or in the article, that the file where the hibernation and the swap are saved are different unrelated things, although with a slight similarity. Perfectly swap-free and hibernation is not affected.

      And yes, swap in the case of a user no longer makes sense (with the always exception of the super unusual). The swap was a palliative for when the system ran out of free ram. I have 4GB of ram and rarely go beyond 1,5GB. So in my case it doesn't make sense. Another would be the issue if I was always on the verge of running out of free ram. With this example, everyone can already know if they need swap or not.

  2.   tralinux said

    The article is good, comprehensive and sufficiently explained, but -please- watch out for spelling mistakes. A writing is no longer useful if the "what" you do not know if they are a question or a conjunction, for example.

  3.   rooster said

    Good article. Thank you.

  4.   g said

    good publication and useful

  5.   g said

    very good publication and useful

  6.   Willarmand said

    Greetings.

    How to schedule a certain time to hibernate automatically? To schedule the scheduled shutdown, for example at 23:00, it would be shutdown -h 23:05, but
    How would it be to schedule hibernation?

    Greetings.

    1.    Linux addicted said

      You tried with pm-hibernate -h 23:05

  7.   Omar Beltran said

    Well, I have ubuntu 20.04 and I am new to this world, I wanted to enable hibernation in the system and I followed all the steps as indicated in the article but it did not work for me. :(

  8.   Federman-Moreno said

    Excellent article, I solved the problem that the pc turned off completely when it ran out of charge. But since I did the indicated procedure, when it reaches a critical state the battery goes into hibernation. In addition, I enable the hibernate function both on the off button and when closing the lid. Thank you.