How to Disable Suspend and Hibernation Modes In Linux

In this article, we take you through how to disable suspend and hibernation modes on a Linux system. But before we do that, let’s briefly have an overview of these two modes.

When you suspend your Linux system, you basically activate or put it into sleep mode. The screen goes off, even though the computer remains very much powered on. Also, all of your documents and applications remain open.

Suspending your system helps save power when you are not using your system. Getting back to using your system requires a simple mouse-click or a tap on any keyboard button. Sometimes, you may be required to press the power button.

There are 3 suspend modes in Linux:

  • Suspend to RAM (Normal Suspend): This is the mode that most laptops automatically enter incase of inactivity over a certain duration or upon closing the lid when the PC is running on the battery. In this mode, power is reserved for the RAM and is cut from most components.
  • Suspend to Disk (Hibernate): In this mode, the machine state is saved into swap space & the system is completely powered off. However, upon turning it on, everything is restored and you pick up from where you left.
  • Suspend to both (Hybrid suspend): Here, the machine state is saved into swap, but the system does not go off. Instead, the PC is suspended to RAM. The battery is not used and you can safely resume the system from the disk and get ahead with your work. This method is much slower than suspending to RAM.

Disable Suspend and Hibernation in Linux

To prevent your Linux system from suspending or going into hibernation, you need to disable the following systemd targets:

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

You get the output shown below:

hybrid-sleep.target
Created symlink /etc/systemd/system/sleep.target → /dev/null.
Created symlink /etc/systemd/system/suspend.target → /dev/null.
Created symlink /etc/systemd/system/hibernate.target → /dev/null.
Created symlink /etc/systemd/system/hybrid-sleep.target → /dev/null.
Disable Suspend and Hibernation in Ubuntu
Disable Suspend and Hibernation in Ubuntu

Then reboot the system and log in again.

Verify if the changes have been effected using the command:

$ sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target
Verify Suspend and Hibernation in Ubuntu
Verify Suspend and Hibernation in Ubuntu

From the output, we can see that all four states have been disabled.

Enable Suspend and Hibernation in Linux

To re-enable the suspend and hibernation modes, run the command:

$ sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

Here’s the output that you will get.

Removed /etc/systemd/system/sleep.target.
Removed /etc/systemd/system/suspend.target.
Removed /etc/systemd/system/hibernate.target.
Removed /etc/systemd/system/hybrid-sleep.target.
Enable Suspend and Hibernation in Ubuntu
Enable Suspend and Hibernation in Ubuntu

To verify this, run the command;

$ sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target
Verify Suspend and Hibernation in Ubuntu
Verify Suspend and Hibernation in Ubuntu

To prevent the system from going into suspend state upon closing the lid, edit the /etc/systemd/logind.conf file.

$ sudo vim /etc/systemd/logind.conf

Append the following lines to the file.

[Login] 
HandleLidSwitch=ignore 
HandleLidSwitchDocked=ignore

Save and exit the file. Be sure to reboot in order for the changes to take effect.

This wraps our article on how to disable Suspend and hibernation modes on your Linux system. It’s our hope that you found this guide beneficial. Your feedback is most welcome.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

6 thoughts on “How to Disable Suspend and Hibernation Modes In Linux”

      • Hi James, thanks for the info but how can I remove being suspended in my own hiber account cause the hiberofficials suspended me i did not even do something wrong please help me James thanks.

        Reply
  1. Hi James,

    Great tutorial, thanks! The other day I installed a music server on an old notebook running Ubuntu Server 20.04.1. Whenever I closed the lid it went to sleep (or hibernation?). The command sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target, and editing the file edit the /etc/systemd/logind.conf file, solves the issue indeed.

    However, with a side effect: the process /lib/systemd/systemd-logind starts eating up most of the CPU power, going up to 80% and remaining there. When I open the lid it slowly decreases; I close the lid, and up goes the CPU load again:

    Last login: Fri Jan  1 14:12:51 2021 from 192.168.1.110
    [email protected]:~$ ps -aux | grep systemd-logind
    root         634 77.0  0.2  17208  8232 ?        Rs   14:41   1:20 /lib/systemd/systemd-logind
    mark        1113  0.0  0.0   9032   740 pts/0    S+   14:43   0:00 grep --color=auto systemd-logind
    [email protected]:~$ ps -aux | grep systemd-logind
    root         634 78.8  0.2  17208  8232 ?        Rs   14:41   2:16 /lib/systemd/systemd-logind
    mark        1117  0.0  0.0   9032   736 pts/0    S+   14:44   0:00 grep --color=auto systemd-logind
    

    Checking /var/log/auth.log shows it starts being filled up with this when I close the lid, and until opening again:

    Jan  1 13:38:53 X201 systemd-logind[2542]: Lid closed.
    Jan  1 13:38:53 X201 systemd-logind[2542]: Suspending...
    Jan  1 13:38:53 X201 systemd-logind[2542]: Unit suspend.target is masked, refusing operation.
    Jan  1 13:38:53 X201 systemd-logind[2542]: Failed to execute suspend operation: Permission denied
    Jan  1 13:38:53 X201 systemd-logind[2542]: Suspending...
    Jan  1 13:38:53 X201 systemd-logind[2542]: Unit suspend.target is masked, refusing operation.
    Jan  1 13:38:53 X201 systemd-logind[2542]: Failed to execute suspend operation: Permission denied
    Jan  1 13:38:53 X201 systemd-logind[2542]: Suspending...
    Jan  1 13:38:53 X201 systemd-logind[2542]: Unit suspend.target is masked, refusing operation.
    Jan  1 13:38:53 X201 systemd-logind[2542]: Failed to execute suspend operation: Permission denied
        :    :    :
    
    [email protected]:~$ tail /var/log/auth.log
    Jan  1 14:45:43 X201 systemd-logind[634]: Suspending...
    Jan  1 14:45:43 X201 systemd-logind[634]: Unit suspend.target is masked, refusing operation.
    Jan  1 14:45:43 X201 systemd-logind[634]: Failed to execute suspend operation: Permission denied
    Jan  1 14:45:43 X201 systemd-logind[634]: Suspending...
    Jan  1 14:45:43 X201 systemd-logind[634]: Unit suspend.target is masked, refusing operation.
    Jan  1 14:45:43 X201 systemd-logind[634]: Failed to execute suspend operation: Permission denied
    Jan  1 14:45:43 X201 systemd-logind[634]: Suspending...
    Jan  1 14:45:43 X201 systemd-logind[634]: Unit suspend.target is masked, refusing operation.
    Jan  1 14:45:43 X201 systemd-logind[634]: Failed to execute suspend operation: Permission denied
    Jan  1 14:45:43 X201 systemd-logind[634]: Lid opened.
    [email protected]:~$
    

    With some more searching I found this page:
    https://serverfault.com/questions/1045949/how-to-disable-suspend-on-ubuntu-20-04-systemd-via-cli

    In my case unfortunately updating /etc/systemd/logind.conf & reboot does not help. Continuing my googling …

    Thanks & best regards
    Mark

    Reply
    • One more line in /etc/systemd/logind.conf does the trick:

      LidSwitchIgnoreInhibited=no
      

      Now all is fine, no extra CPU load, and all normal in auth.log.

      BR Mark

      Reply
  2. The title should be “How to disable suspend and hibernate in SYSTEMD”. To claim that this is universal across all of Linux is just plain wrong. The steps outlined in the article do not work on many distros. Ubuntu is NOT the be-all and end-all of Linux.

    Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.