Linux Programmer

리눅스 절전 모드 끄기 및 비활성화 systemd sleep 설정 본문

컴퓨터 관련/리눅스(유닉스) 일반

리눅스 절전 모드 끄기 및 비활성화 systemd sleep 설정

sunyzero 2025. 3. 21. 16:43

리눅스 워크스테이션이나 데스크탑 버전을 설치하면 절전 기능이 활성화 되어있다. 예를 들어 Fedora workstation을 설치했다면 기본으로 절전 기능이 활성화되어 직접 사용하지 않으면 일정 시간 후 절전 모드로 전환된다. ssh로 외부에서 접속해서 작업하면 직접 사용하는 것이 아니므로 아래와 같은 메시지와 함께 절전으로 전환(suspend) 될 수 있다. 이렇게 절전 모드로 빠지면 외부 접속은 모두 끊기게 된다.

$ Broadcast message from gdm@fedora on tty1:

The system will suspend now!

이런 문제를 겪지 않으려면 다음과 같이 설정하도록 한다. (관련 매뉴얼 페이지 : systemd-sleep.conf)

 

1. systemd/sleep.conf 설정 확인

먼저 현재 설정을 systemd-analyze cat-config systemd/sleep.conf 명령으로 확인해본다.

$ sudo systemd-analyze cat-config systemd/sleep.conf
# /etc/systemd/sleep.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. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the sleep.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# See systemd-sleep.conf(5) for details.

[Sleep]
#AllowSuspend=yes
#AllowHibernation=yes
#AllowSuspendThenHibernate=yes
#AllowHybridSleep=yes
#SuspendMode=
#SuspendState=mem standby freeze
#HibernateMode=platform shutdown
#HibernateState=disk
#HybridSleepMode=suspend platform shutdown
#HybridSleepState=disk
#HibernateDelaySec=
#SuspendEstimationSec=60min

위에 보면 모든 값들이 해시문자(#)로 막혀있는데, 이는 기본값을 의미한다. 그 중에 AllowSuspend=yes로 되어있는 부분이 바로 자동 절전 모드이다. 이를 no로 바꾸면 되는데, 편집을 직접하는게 아니라 overriding config를 만드는 방법을 사용하게 된다.

 

2. AllowSuspend=no 설정 방법

해당 설정은 관리자인 root 계정으로 명령해야 한다. 먼저 overriding config file을 저장할 디렉토리로 /etc/systemd/sleep.conf.d를 만들어야 한다. 그리고 해당 디렉토리에 넣을 설정 파일을 vi 같은 에디터로 만들어주면 된다. 즉 아래와 같이 명령한다.

mkdir /etc/systemd/sleep.conf.d
cd $!
vi nosuspend.conf

vi nosuspend.conf 명령어를 실행한 다음에는 아래의 내용을 넣는다. 핵심 설정 부분은 AllowSuspend=no 라는 부분이다.

[Sleep]
AllowSuspend=no
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no

설정이 제대로 되었는지 확인하기 위해 systemd-analyze cat-config systemd/sleep.conf 명령을 다시 내려본다. 만일 가장 하단에 /etc/systemd/sleep.conf.d/nosuspend.conf로부터 파일을 읽혀졌다면 제대로 설정된 것이다.

root user# systemd-analyze cat-config systemd/sleep.conf
...생략...

[Sleep]
#AllowSuspend=yes
#AllowHibernation=yes
#AllowSuspendThenHibernate=yes
#AllowHybridSleep=yes
#SuspendMode=
#SuspendState=mem standby freeze
#HibernateMode=platform shutdown
#HibernateState=disk
#HybridSleepMode=suspend platform shutdown
#HybridSleepState=disk
#HibernateDelaySec=
#SuspendEstimationSec=60min

# /etc/systemd/sleep.conf.d/nosuspend.conf
[Sleep]
AllowSuspend=no
...

해당 설정은 즉시 적용되므로 따로 restart나 reload해줘야 하는 것은 없다. 다만 정 불안하다면 systemctl daemon-reload 명령을 한번 해주면 될 것이다.

 

히스토리

2025-03-21 글 작성

 

반응형
Comments