How to Disable or Block Hibernation in Fedora

How to Disable or Block Hibernation in Fedora

Learn how to disable or block hibernation in Fedora with easy-to-follow steps. Protect system resources, enhance security, and optimize performance by disabling the hibernation feature on your Linux system.

Table of Contents

🔈Introduction

Hibernation is a useful feature in Linux distributions, allowing users to save the current state of their system to disk and power it down. When powered on again, the system resumes from where it left off. However, there are situations where hibernation may not be necessary or even desirable. Perhaps it is causing system issues, consuming unnecessary resources, or you simply don’t need it for your use case.

In this blog post, we will show you how to disable or block hibernation in Fedora. This guide is designed for Fedora users who want to control the behavior of their system’s power management and ensure that hibernation is no longer available.


✅ Why Disable or Block Hibernation?

There are several reasons why you might want to disable hibernation in Fedora:

  • System Resources: Hibernation often requires a swap partition or swap file to store the system state. If your system doesn’t have a large enough swap area, this could cause issues during the hibernation process.
  • Security Concerns: The swap partition or file used for hibernation may contain sensitive data from your system state. Disabling hibernation can help ensure this data is not left unencrypted on disk.
  • Performance Issues: If your system experiences performance degradation when waking from hibernation, disabling it may help improve your system’s responsiveness.
  • Power Consumption: If you rarely use hibernation, you might prefer to disable it to simplify power management.

✅ Prerequisites

Before proceeding with the process of disabling or blocking hibernation in Fedora, ensure you have the following:

  • Root (sudo) Access: You will need administrative privileges to modify system settings related to power management.
  • Backup: While this process is generally safe, it’s a good practice to back up important data in case something goes wrong.
How to Disable or Block Hibernation in Fedora

Photo by admingeek from Infotechys


đŸ› ïž How to Disable Hibernation in Fedora Using CLI

Fedora, like most Linux distributions, provides a straightforward method of disabling hibernation via the command-line interface (CLI).

Step 1: Check if Hibernation is Enabled

First, let’s confirm that hibernation is enabled on your system. Run the following command:

				
					sudo systemctl status hibernate.target
				
			

If hibernation is enabled, you’ll see an output like this:

				
					● hibernate.target
   Loaded: loaded (/usr/lib/systemd/system/hibernate.target; static; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd.special(7)
				
			

Step 2: Disable Hibernation

To disable hibernation, we need to modify the systemd configuration. You can do so by executing the following commands:

				
					sudo systemctl mask hibernate.target
				
			

This command will prevent the system from entering hibernation mode by “masking” the hibernation target, which essentially disables it. To disable hibernation entirely, issue the following commands: 

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

To reverse this later:

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

Step 3: Verify the Change

After masking the hibernation target, verify that it is no longer active by running:

				
					sudo systemctl status hibernate.target
				
			

You should see that the hibernation target is now masked or effectively disabled.

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

Removing Swap Space (Optional)

While disabling hibernation via systemd is one approach, it is also possible to remove swap space entirely, which prevents the system from being able to hibernate. This method is more permanent, but it requires careful handling.

Step 1: Disable Swap

First, you will need to turn off the swap space:

				
					sudo swapoff -a
				
			

This command will disable all swap devices currently in use.

Step 2: Remove Swap Entry from /etc/fstab

Next, remove the swap entry from your /etc/fstab file to ensure it doesn’t get reactivated after a reboot. Open the file using a text editor like vim:

				
					sudo vim /etc/fstab
				
			

Locate the line that corresponds to the swap partition or file, and comment it out by adding a # at the beginning of the line:

				
					#/dev/mapper/fedora-swap swap swap defaults 0 0
				
			

Save and exit the file.

Step 3: Reboot

Now, reboot your system to apply the changes:

				
					sudo reboot
				
			

After rebooting, hibernation will be effectively disabled because the swap partition is no longer available.


đŸ› ïž How to Adjust Logind.conf

Modify the systemd login manager to prevent auto-hibernate when idle or on lid close.

Step 1: Edit the logind.conf

				
					sudo vim /etc/systemd/logind.conf
				
			

Step 2: Uncomment the following lines

Set or change the following lines:

				
					HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore
HandleHibernateKey=ignore
IdleAction=ignore
				
			

Step 3: Reload logind

				
					sudo systemctl restart systemd-logind
				
			

🏁 Conclusion

Disabling or blocking hibernation in Fedora is a relatively simple process that can be achieved through the command-line (CLI), by removing swap space, or by modifying the logind configuration file. With these methods, you can tailor your Fedora system to suit your preferences and ensure that hibernation is no longer a factor in your power management strategy.

Did you find this article helpful? Your feedback is invaluable to us! Feel free to share this post with those who may benefit, and let us know your thoughts in the comments section below.


Related Posts
Install KVM on Fedora 41
Commands
Install KVM on Fedora 41

Learn how to install KVM on Fedora 41 step-by-step—covering prerequisites, CLI & GUI configuration, networking, performance tuning, and best practices for virtualized environments. Table of

Read More »

Leave a Reply

Your email address will not be published. Required fields are marked *