본문 바로가기

리눅스

[리눅스] CentOS 7 전원 버튼을 비활성화하는 방법

728x90

CentOS 7 전원 버튼을 비활성화하는 방법

 - 시스템이 비정상적으로 종료되는 현상이 발생하였다.

서버 모델

$ dmidecode -t system | egrep 'Manufacturer|Product Name'
        Manufacturer: HP
        Product Name: ProLiant DL360p Gen8
$ cat /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)

$ uname -a
Linux test-server 3.10.0-1127.18.2.el7.x86_64 #1 SMP Sun Jul 26 15:27:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

messages 로그(Power OFF)

$ vim /var/log/messages
Oct 30 10:48:32 test-server systemd-logind: Power key pressed.
Oct 30 10:48:32 test-server systemd-logind: Powering Off...
Oct 30 10:48:32 test-server systemd-logind: System is powering down.

messages 로그(Power ON)

$ vim /var/log/messages
Nov  1 08:49:54 test-server systemd-logind: Watching system buttons on /dev/input/event0 (Power Button)

logind.conf 설정 파일 확인

$ cat /etc/systemd/logind.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See logind.conf(5) for details.

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=no
#UserTasksMax=

조치

서버가 비정상적으로 종료되는 현상을 막기 위해 아래와 같이 조치하였습니다.
-  (전원 버튼을 눌러 시스템이 종료되는 것을 방지하기 위해) 전원 버튼의 동작 방식을 변경

$ cat /etc/systemd/logind.conf | grep HandlePowerKey
#HandlePowerKey=poweroff

HandlePowerKey=ignore 추가

$ cat /etc/systemd/logind.conf | grep HandlePowerKey
#HandlePowerKey=poweroff
HandlePowerKey=ignore

systemd-logind 재시작

$ systemctl restart systemd-logind
$ systemctl status systemd-logind 
● systemd-logind.service - Login Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-logind.service; static; vendor preset: disabled)
   Active: active (running) since Mon 2021-11-01 10:26:53 KST; 6s ago
     Docs: man:systemd-logind.service(8)
           man:logind.conf(5)
           http://www.freedesktop.org/wiki/Software/systemd/logind
           http://www.freedesktop.org/wiki/Software/systemd/multiseat
 Main PID: 741 (systemd-logind)
   Status: "Processing requests..."
    Tasks: 1
   Memory: 324.0K
   CGroup: /system.slice/systemd-logind.service
           └─741 /usr/lib/systemd/systemd-logind

Nov 01 10:26:53 test-server systemd[1]: Starting Login Service...
Nov 01 10:26:53 test-server systemd[1]: Started Login Service.
Nov 01 10:26:53 test-server systemd-logind[741]: New seat seat0.
Nov 01 10:26:53 test-server systemd-logind[741]: Watching system buttons on /dev/input/event0 (Power Button)
Nov 01 10:26:53 test-server systemd-logind[741]: New session 45 of user mtsysman.
Nov 01 10:26:53 test-server systemd-logind[741]: New session 3 of user mtsysman.
Nov 01 10:26:53 test-server systemd-logind[741]: New session 4 of user oracle.
728x90