1. 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

$ sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target
[sudo] password for alexlai: 
β—‹ sleep.target - Sleep
     Loaded: loaded (/usr/lib/systemd/system/sleep.target; static)
     Active: inactive (dead)
       Docs: man:systemd.special(7)

β—‹ suspend.target - Suspend
     Loaded: loaded (/usr/lib/systemd/system/suspend.target; static)
     Active: inactive (dead)
       Docs: man:systemd.special(7)

β—‹ hibernate.target - System Hibernation
     Loaded: loaded (/usr/lib/systemd/system/hibernate.target; static)
     Active: inactive (dead)
       Docs: man:systemd.special(7)

β—‹ hybrid-sleep.target - Hybrid Suspend+Hibernate
     Loaded: loaded (/usr/lib/systemd/system/hybrid-sleep.target; static)
     Active: inactive (dead)
       Docs: man:systemd.special(7)
  ξ‚° alexlai@hc4Gnome ξ‚°  ξ‚° sudo systemctl mask sleep.target suspend.target hibernate.target 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.
 
 ξ‚°  ξ‚° sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target
β—‹ 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)
  1. 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

  1. Open the GNOME Settings app and navigate to the "Privacy" section.
  • Under the "Screen Lock" section, change the "Automatic Screen Lock" setting to "Off". This will prevent the screen from automatically locking after a period of inactivity.
  • Check your power management settings in your BIOS or UEFI firmware to make sure that there are no settings that are causing your computer to go into a low-power state or suspend mode after a period of inactivity.
  • Check your system logs to see if there are any error messages related to power management or suspend mode. You can view the system logs by opening a terminal window and typing the following command:
journalctl -b
  1. If all else fails, you can try disabling suspend mode and power management altogether by adding the following kernel boot parameter:
noacpi
  • To add this kernel boot parameter, edit your GRUB configuration file by typing the following command:
sudo nano /etc/default/grub
  • Add the "noacpi" parameter to the "GRUB_CMDLINE_LINUX_DEFAULT" line, like this:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash noacpi" or "acpi=off apm=off"
# my orangepi5
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet acpi=off apm=off"
  • Update GRUB by typing the following command:
sudo update-grub
git clone https://aur.archlinux.org/update-grub.git
cd update-grub
makepkg -si
$ sudo mkdir /boot/grub
[alexlai@orangepi5 update-grub]$ sudo update-grub
Generating grub configuration file ...
Found linux image: /boot/Image
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
  • Then restart your computer.
  1. Not Nwcessary --->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
Return to Top