Ubuntu 20.04 suspends randomly

~ 2 min.

While setting up Ubuntu 20.04 LTS on a tablet/laptop (Medion Akoya), I faced a very strange issue. I wanted to install Ubuntu via a live USB stick.

Once the Ubuntu live system was booted completely, the laptop went to sleep. I was able to wake it by pressing the power button, but after some random 20-30 seconds, it would suspend again, over and over. Within a few cycles of going to sleep and waking the PC again, I was able to run a command on the shell.

The output of dmesg let me know that it was an issue connected to systemd always suspending my machine. After some research, I found a solution to this problem. The core problem is that systemd wants to suspend your PC because it thinks the laptop lid is closed.

There is a way to prevent this (by editing the file /etc/systemd/logind.conf), but unfortunately this was not possible in my live environment, as it requires a reboot. Rebooting the live system will discard all changes to the file system and the error would persist.

Fortunately, DELL Austria provides a solution to this problem. Run the following commands in a terminal, and systemd will stop hibernating/suspending your device:

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

After successfully installing Ubuntu on the PC, the error came back, obviously, as the issued command was only a temporary fix. But as the PC was now installed with Ubuntu 20.04, i could go the normal way of preventing the laptop-lid-close-bug.

I edited the file /etc/systemd/logind.conf

sudo nano /etc/systemd/logind.conf

and uncommented the following line, by removing the leading hash:


Here it says suspend, which is not the preferred behaviour, therefore I changed it to


Save the file by pressing CTRL+O and exit from the editor by pressing CTRL+X and reboot the PC.

Resource: https://www.dell.com/support/article/en-us/how12691/how-to-disable-sleep-and-configure-lid-power-settings-for-ubuntu-or-red-hat-enterprise-linux-7?lang=en

5 Kommentare zu „Ubuntu 20.04 suspends randomly“

  1. Based on reading the Dell article you link to, and the fact that the systemctl command you give failed to work for me, I believe that systemctl command’s subcommand should be „mask“ *not* „unmask“. The „unmask“ version *enables* random sleep. Am I wrong?

    1. Hi Phil,

      yes you are right. The correct one is „mask“ and not „unmask“. Looks like I copy-pasted the wrong line from the DELL article. I’ve already corrected the command.

      Thanks a lot for clarification!

  2. Hi Gabriel,
    you most definitely saved a life today. Been facing this thing since yesterday and even thought running Ubuntu in dual-boot mode would help (there’s more to this thought, trust me).
    Thanks so much for this.

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert