I administer Linux servers (different distributions - Ubuntu server, CentOS, Fedora) - physical and virtual machines. Most of them have an unpleasant feature - if in the "physical console" (which is not ssh, and in a hardware monitor with a hardware keyboard, real or remote via iKVM), for a long time you do not "write" from the keyboard, it goes out.

In reality, it looks like this: you approach the server with a physical monitor, you catch it - the monitor shows a black screen. You cling to the keyboard, press any key - the monitor comes to life and the "physical console" becomes visible (if we are talking about a machine without X, it is always visible starting from the OS boot, if there are X, it can be reached via Ctrl + Alt + F1 ). Or you connect to a virtual machine via VNC - and the same, until you touch the keyboard - there is no picture.

We are not talking about the "screensaver", this is the console falling asleep in text mode.

How to wean Linux-hosts from this behavior?

    1 answer 1

    The described behavior comes directly from the Linux kernel, apparently this is a hello from the distant past, when text terminals with luminous visualization devices that had to be protected from burning out were connected to such hosts.

    You can check the time after which the physical terminal goes out when there is no user input into it, by looking at the contents of the / sys / module / kernel / parameters / consoleblank file:

    $ cat /sys/module/kernel/parameters/consoleblank 600 

    This file is available only for reading, you cannot change the setting by overwriting it. The value in it is seconds, that is, in the example shown, the console goes out after 10 minutes of inactivity.

    To disable this behavior globally and permanently, add the line consoleblank=0 to the kernel parameters in the grub config and reboot the OS (do not forget about update-grub after editing). For example:

     $ cat /etc/default/grub | grep -v '#' GRUB_DEFAULT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=7 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="" GRUB_CMDLINE_LINUX="consoleblank=0" 

    After the reboot, we see that the parameters were considered and accepted by the kernel:

     $ cat /proc/cmdline BOOT_IMAGE=/boot/vmlinuz-4.6.0-040600-generic root=UUID=544c13df-3ff3-47ba-94cc-407e414c6906 ro consoleblank=0 

    And the console “falling asleep” setting has changed:

     $ cat /sys/module/kernel/parameters/consoleblank 0 

    You can change this parameter on the fly, without rebooting, using the setterm , like this: setterm -blank 0 or even like this: setterm -blank 0 -powerdown 0 -powersave off , however, there are two BUT:

    1. it works only if the setterm command setterm entered into the "physical" console ( Ctrl + Alt + F1 ), and when entered via ssh does not work
    2. setterm Internet, they write that the behavior of setterm changes from kernel to kernel and from distribution to distribution, i.e. it is impossible to consider this method as completely universal
    • Damn, dude, you wrote very helpful, I rummaged through the Internet, I didn’t know how to formulate the question correctly, and here it’s right on time. Thank you very much. - don Rumata
    • superuser.com/questions/206622/… - the campaign has already been asked and answered. - don Rumata