How to Disable Suspend and Hibernation Modes In Linux?

Suspend and hibernation modes are power management features in Linux that help conserve battery life and allow quick system recovery. However, there are situations where you might want to disable these features ? such as preventing system instability, avoiding unexpected wake-ups on servers, or ensuring continuous operation of critical applications.

Suspend mode puts your computer into a low-power state while keeping the session active in RAM. Hibernation mode saves the current system state to disk and completely powers down the machine. Both modes can sometimes cause issues with certain hardware configurations or interfere with system operations.

Disabling Suspend Mode

To disable suspend mode, you need to modify the systemd configuration file that controls power management behavior.

Step-by-Step Instructions

Follow these steps to disable suspend mode in Linux

# Open the systemd login configuration file
sudo nano /etc/systemd/logind.conf

In the configuration file, find and modify the following lines

# Find these lines (they may be commented with #)
#HandleSuspendKey=suspend
#HandleLidSwitch=suspend

# Change them to:
HandleSuspendKey=ignore
HandleLidSwitch=ignore

Save the file and restart the systemd-logind service

sudo systemctl restart systemd-logind

Alternative Method Using systemctl

You can also disable suspend using systemctl commands

# Disable suspend target
sudo systemctl mask sleep.target suspend.target

# Verify the status
systemctl status sleep.target

Disabling Hibernation Mode

Hibernation can be disabled using similar methods, either through configuration files or systemctl commands.

Method 1: Configuration File

Edit the same logind.conf file

sudo nano /etc/systemd/logind.conf

Add or modify these lines

HandleHibernateKey=ignore
HandleSuspendKey=ignore
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore

Method 2: Using systemctl

# Disable hibernation and hybrid sleep
sudo systemctl mask hibernate.target hybrid-sleep.target

# Verify hibernation is disabled
systemctl status hibernate.target

Verification and Testing

After making changes, verify that suspend and hibernation are properly disabled

# Check current power management targets
systemctl status sleep.target suspend.target hibernate.target

# Test if suspend is disabled (should show "masked")
sudo systemctl status suspend.target

Configuration Options

Configuration Option Function Values
HandleSuspendKey Controls suspend key behavior suspend, ignore, poweroff, hibernate
HandleHibernateKey Controls hibernate key behavior hibernate, ignore, poweroff, suspend
HandleLidSwitch Controls laptop lid close action suspend, ignore, poweroff, hibernate
HandleLidSwitchExternalPower Lid behavior when on AC power suspend, ignore, poweroff, hibernate

Re-enabling Suspend and Hibernation

To re-enable these features later, reverse the process

# Unmask the targets
sudo systemctl unmask sleep.target suspend.target hibernate.target

# Reset configuration to default
sudo nano /etc/systemd/logind.conf
# Change "ignore" back to "suspend" or "hibernate"

# Restart the service
sudo systemctl restart systemd-logind

Alternatives to Suspend and Hibernation

If you disable these power management features, consider these alternatives

  • Screen blanking Configure automatic screen turn-off without system suspend

  • CPU frequency scaling Reduce processor speed during idle periods

  • Manual shutdown Develop a habit of properly shutting down when finished

  • Scheduled tasks Use cron jobs for automatic system maintenance during off-hours

Conclusion

Disabling suspend and hibernation modes in Linux is straightforward using systemd configuration files or systemctl commands. This approach is particularly useful for servers, systems with problematic hardware, or environments requiring continuous operation. Always test the changes and consider alternative power management strategies to maintain system efficiency.

Updated on: 2026-03-17T09:01:38+05:30

12K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements