Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tankibaj/71547848decdd7cc3bf0c6df68935c8f to your computer and use it in GitHub Desktop.
Save tankibaj/71547848decdd7cc3bf0c6df68935c8f to your computer and use it in GitHub Desktop.

Laptop running as a server

I am running an old Dell Laptop as a server with Ubuntu 18.04 on it. Installing Ubuntu on the system was straight forward, but at a certain point you want to close the lid of the laptop. This puts your laptop in sleep, which for a server is not the intended result.

Disable Sleep on Lid Close

Debians Suspend Wiki page had the right solution for this

Mask the targets using systemctl

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

Edit /etc/systemd/logind.conf and change the accodring values

  • HandleLidSwitch=ignore
  • HandleLidSwitchDocked=ignore
sudo sh -c "echo 'HandleLidSwitch=ignore\nHandleLidSwitchDocked=ignore' >> /etc/systemd/logind.conf"

Afterwards just reboot.

Switch Off Backlit

Sadly, the backlit of the display is not switching off, which leads to a broken display after a while and consumes additional energy. The simplest way to fix the issue was to change the consoleblank setting at boot. This did not need any additional packages like ACPI or any extra user scripts at startup.

Verify the value used at the moment with cat /sys/module/kernel/parameters/consoleblank. The value is in seconds. The easiest way to add the parameter at boot is using the kernel command-line.

sudo nano /etc/default/grub

Once there, just add consoleblank=60 to GRUB_CMDLINE_DEFAULT, it should look like this:

GRUB_CMDLINE_LINUX_DEFAULT="quiet consoleblank=60"

Then close the file and save it, after that just run sudo update-grub, every time you boot the screen will turn off automatically every 60 sec. (again, if idle). And this way (adding the consoleblank to the GRUB) works even from remote terminals (ssh).

Enjoy! (again).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment