[HowTo] Disable / Turn off Hibernate completely!

Difficulty: ★★☆☆☆

This tutorial is to ensure you correctly turn off hibernation completely. You need to do this in 3 places in that order :

  1. systemd

    Create the following files:

  • /etc/systemd/sleep.conf.d/no-hibernate.conf

    • Add:

      [Sleep]
      # disable hibernation
      # doc : https://archived.forum.manjaro.org/t/turn-off-disable-hibernate-completely/139939
      AllowHibernation=no
      AllowHybridSleep=no
      AllowSuspendThenHibernate=no
      
  • /etc/systemd/logind.conf.d/no-hibernate.conf

    • Add:

      [Login]
      # disable hibernation
      HibernateKeyIgnoreInhibited=no
      
  • Save and exit all

  • Test:

    sudo systemctl hibernate
    

    should fail with:

    Failed to hibernate system via logind: Sleep verb "hibernate" not supported
    
    I'm a N00b! I don't know how to to this: give me more help!

    Don’t worry! :slight_smile: Here is an example for the first file:

    1. Execute:
    sudo mkdir /etc/systemd/sleep.conf.d/
    sudo mkdir /etc/systemd/logind.conf.d/
    # If the above give: "mkdir: cannot create directory: File exists" that's OK!
    sudo nano --backup /etc/systemd/sleep.conf.d/no-hibernate.conf
    
    1. copy-paste the following text in there:
    [Sleep]
    # disable hibernation
    # doc : https://archived.forum.manjaro.org/t/turn-off-disable-hibernate-completely/139939
    AllowHibernation=no
    AllowHybridSleep=no
    AllowSuspendThenHibernate=no
    
    1. Ctrl+X, then Y and Enter to save.
    2. Repeat for each of the files in the section above.
  1. Desktop Environment
  1. Kernel
  • Change the /etc/default/grub:GRUB_CMDLINE_LINUX_DEFAULT and remove the resume=UUID= parameter.

  • Remove the resume item from the HOOKS= line in /etc/mkinitcpio.conf and perform a sudo mkinitcpio --allpresets

    I'm a N00b! I don't know how to to this: give me more help!

    Don’t worry! :slight_smile: /etc/default/grub:GRUB_CMDLINE_LINUX_DEFAULT just means there is a file /etc/default/grub which contains the word GRUB_CMDLINE_LINUX_DEFAULT and that you need to change it!

    1. Execute:

      sudo nano --backup /etc/default/grub
      
    2. Press Ctrl+W to start searching

    3. Type GRUB_CMDLINE_LINUX_DEFAULT Enter

    4. You’ll now see:

      GRUB_CMDLINE_LINUX_DEFAULT=
      
    5. with a whole bunch of :poop: behind it all separated by spaces. :wink:

    6. You’re looking for resume=UUID=SomeWeirdNumberCalledAGUID

    7. Before you do the next step, ensure there is at least one space left between the previous and next parameter.

    8. Remove resume=UUID=SomeWeirdNumberCalledAGUID and maximum one space!

    9. Verify again there is at least one space left before and after each parameter in that line or your computer will not boot any more! . If you’re unsure at this stage, press Ctrl+X then press N and try again at step 1

    10. You’re sure??? Well, then press Ctrl+X then press Y and Enter to save.

    For mkinitcpio:

    1. sudo nano --backup /etc/mkinitcpio.conf

    2. Start the search functionality by pressing Ctrl+W (Meaning: W here is?) and type HOOKS= and Enter

    3. You will now see a line that has the word resume in it: remove that word and if you don’t see that word, just exit without saving by pressing Ctrl+X

    4. If you did find and remove the word, save and exit by Ctrl+X Y Enter and execute:

      sudo mkinitcpio --allpresets
      
  • Execute:

    sudo update-grub
    

So you’ve done all the above in one session?

  • Reboot

  • Final test:

    sudo systemctl suspend
    

Which should still suspend your system but not hibernate it any more!

24 Likes

In Xfce

  1. Go to Power Manager
  2. Tabs "General" and "System": Remove any mention of Hibernate by choosing one of the other option available.
  3. (Edit: removed screenshots as they were added to the initial post)

Suggest adding a third bulleted list for sudo update-grub (though it is mentioned in the “I’m a n00b” toggle).

1 Like

Followed @Fabby’s procedure with these modifications on XFCE.

To prevent the use of hibernate and suspend on a desktop computer

systemd implements the org.freedesktop.login1.Manager dbus interface and these changes cause the methods (CanHibernate, CanHybridSleep, CanSuspend) to return “na”, rather than “yes”.

I added “AllowSuspend” in the sleep configuration. And for the logind configuration I added “SuspendKeyIgnoreInhibited”.

mkdir /etc/systemd/sleep.conf.d/

nano /etc/systemd/sleep.conf.d/no-hibernate-suspend.conf

[Sleep]
# disable hibernate and suspend
# doc : https://archived.forum.manjaro.org/t/turn-off-disable-hibernate-completely/139939
AllowHibernation=no
AllowHybridSleep=no
AllowSuspend=no
AllowSuspendThenHibernate=no
mkdir /etc/systemd/logind.conf.d/

nano /etc/systemd/logind.conf.d/no-hibernate-suspend.conf

# disable hibernate and suspend
HibernateKeyIgnoreInhibited=no
SuspendKeyIgnoreInhibited=no

Since xfce4-session-logout calls the dbus interface no xfconf changes are required. This means that when you logout, you will not see these options on the dialog.

I’ve seen commands like xfconf-query -c xfce4-session -np '/shutdown/ShowSuspend' -t 'bool' -s 'false'. This is not required.

Also no policykit rules were required.

@Fabby covered it all.

Test

Commands issued to prove that hibernate and suspend functionality are truely disabled:

===> systemctl suspend
Failed to suspend system via logind: Sleep verb "suspend" not supported

===> systemctl hibernate
Failed to hibernate system via logind: Sleep verb "hibernate" not supported

===> systemctl hybrid-sleep
Failed to put system into hybrid sleep via logind: Sleep verb "hybrid-sleep" not supported

===> systemctl suspend-then-hibernate
Failed to suspend system, hibernate later via logind: Sleep verb "hybrid-sleep" not supported

NOTE: I installed the super nice tool, D-Feet, to query and execute dbus functionality.

2 Likes

So nothing to change in the tutorial, or am I misunderstanding you?

:thinking:

I didn’t need to do step 2 (not running Power Management) and 3 (wasn’t there), thus no reboot :slight_smile:

Added one additional option to each file in step 1.

Spent some time searching for a solution, and just wanted to add at the end above, there are incomplete and deprecated solutions out there. xfconf or policykit aren’t addressing the root cause as they say. Your solution addresses the right software layer. These systemd solutions today are tough to find. :dizzy_face:

1 Like

I believe in Too Much Information Is A Good Thing, and it’s a 2 star difficulty, so I’m expecting people to skip stuff that isn’t there…

1 Like

2 posts were split to a new topic: I have hibernation issues I don’t understand

A post was split to a new topic: HIbernation problems

2 posts were split to a new topic: I cannot figure out why hibernation is bugging me

Doesn’t xfconf-query apply changes to the user only? The systemd settings then has the advantage to apply to all users.

very helpful. thank you.

Another possibility using systemctl

Disable hibernate:

sudo systemctl mask hibernate.target

Test

sudo systemctl hibernate

Failed to start hibernate.target: Unit hibernate.target is masked.

Back to enable hibernate:

sudo systemctl unmask hibernate.target

Turn off all rest states (Sleep, suspend, hibernate, hybrid-sleep)

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

Back to enable all rest states

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
4 Likes

I found a Plasma Desktop gui that seems to work.
Open System settings, ( I opened every nook and cranny )

  1. Opened screen locking , unchecked everything
    2 Opened Energy Saving, unchecked everything in all three tabs: AC Power - Battery-Low battery
    3 Opened Activity Power Settings, Unchecked : Do not use special settings
    then
    Checked : Define a special behavior
    checked : Never shutdown the computer or let it go to sleep

From there you can slowly add in items as needed