반응형
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 설정 파일 확인
vim /etc/systemd/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=
728x90
조치
서버가 비정상적으로 종료되는 현상을 막기 위해 아래와 같이 조치하였습니다.
- (전원 버튼을 눌러 시스템이 종료되는 것을 방지하기 위해) 전원 버튼의 동작 방식을 변경
$ cat /etc/systemd/logind.conf | grep HandlePowerKey
#HandlePowerKey=poweroff
** ACPI(Advanced Configuration and Power Interface) events
Event handler | Description | Default action |
HandlePowerKey | Triggered when the power key/button is pressed. | poweroff |
HandleSuspendKey | Triggered when the suspend key/button is pressed. | suspend |
HandleHibernateKey | Triggered when the hibernate key/button is pressed. | hibernate |
HandleLidSwitch | Triggered when the lid is closed, except in the cases below. | suspend |
HandleLidSwitchDocked | Triggered when the lid is closed if the system is inserted in a docking station, or more than one display is connected. | ignore |
HandleLidSwitchExternalPower | Triggered when the lid is closed if the system is connected to external power. | action set for HandleLidSwitch |
- HandlePowerKey=ignore 추가
$ cat /etc/systemd/logind.conf | grep HandlePowerKey
#HandlePowerKey=poweroff
HandlePowerKey=ignore
vim /etc/systemd/logind.conf
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.
참고URL
- https://wiki.archlinux.org/title/Power_management#Power_management_with_systemd
728x90
반응형
'리눅스' 카테고리의 다른 글
쿠버네티스 초기화 오류(kubeadm init) (0) | 2021.11.01 |
---|---|
Docker 중지 시 Warning (0) | 2021.11.01 |
html 페이지 모바일에서 반응형으로 나오게 하는 방법 (viewport) (0) | 2021.10.27 |
CentOS 7에서 YUM 패키지 매니저를 사용하여 MySQL을 설치하는 방법 (0) | 2021.10.20 |
[리눅스] Git SSL Certificate Problem: Certificate has expired 에러 해결 (0) | 2021.10.01 |