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