Disable Suspend and Hibernation Modes on Linux

Disable Suspend and Hibernation Modes on Linux

Linux provides various power management options to reduce energy consumption and extend the life of the computer, with features like suspend and hibernation modes. Suspending the system is an effective way to save power when the computer is idle. To awaken it, a simple mouse-click or a tap on any keyboard key is usually sufficient, but sometimes, you may need to press the power button. However, there are scenarios where you might need to disable these modes. For instance, when configuring a server, you would want the system to run without interruption. This tutorial shows how to disable suspend and hibernation modes on Linux.

To prevent the Linux system from entering suspension or hibernation, you must deactivate the following systemd targets:

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

The output will look like:

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.

Confirm whether the changes have taken effect by using the command:

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

The output will look like:

● sleep.target
     Loaded: masked (Reason: Unit sleep.target is masked.)
     Active: inactive (dead)

● suspend.target
     Loaded: masked (Reason: Unit suspend.target is masked.)
     Active: inactive (dead)

● hibernate.target
     Loaded: masked (Reason: Unit hibernate.target is masked.)
     Active: inactive (dead)

● hybrid-sleep.target
     Loaded: masked (Reason: Unit hybrid-sleep.target is masked.)
     Active: inactive (dead)

To restore the ability to use suspend and hibernation modes, execute the following command:

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

The output will look like:

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.

Leave a Comment

Cancel reply

Your email address will not be published.