강좌/RaspberryPI 활용

Raspberry pi watchdog auto reboot 설정

acidpop 2015. 7. 15. 09:27
반응형

원격 SSH로 라즈베리파이를 접속해서 사용하다 보니 프로그램을 잘못 만들었거나 어떤 하드웨어 오류로 인해

 

라즈베리파이가 먹통이 되는 경우가 있다.

 

그럴때마다 사람이 직접 리셋을 하거나 전원을 껏다 켜야 되는 상황이 발생하는데

 

시스템이 멈춘걸 감지 해서 자동으로 리셋을 하는 역할을 맡은것이 watchdog 이라는 것이다.

 

watchdog 에 대한 원리나 설명은 구글링을 하면 많이 보이니 여기서는 라즈베리파이에 watchdog 을 설정 하는 방법을 기술한다.

 

 

1. 커널에 라즈베리리파이 칩셋 모듈을 추가한다.

 

sudo modprobe bcm2708_wdog 

 Raspbian 4.14.34-v7+ 버전 기준에는 bcm2708_wdog 가 아닌 bcm2835_wdt 로 변경


sudo modprobe bcm2835_wdt

 

2. modules 파일에 칩셋 모듈 이름을 등록한다.

echo "bcm2708_wdog" >> /etc/modules

Raspbian 4.14.34-v7+ 버전 기준

echo "bcm2835_wdt" >> /etc/modules 


또는 vi 나 nano 에디터로 /etc/modules 파일을 열어 끝 라인에 "bcm2708_wdog" 를 추가 한다.

 

 

 

3. watchdog, chkconfig 를 설치하고 watchdog 을 부팅시 시작 하도록 등록한다.

sudo apt-get install watchdog chkconfig
chkconfig watchdog on

 

 

4. watchdog 환경 설정 파일을 수정한다.

 

sudo nano /etc/watchdog.conf
#ping			= 172.31.14.1
#ping			= 172.26.1.255
#interface		= eth0
#file			= /var/log/messages
#change			= 1407

# Uncomment to enable test. Setting one of these values to '0' disables it.
# These values will hopefully never reboot your machine during normal use
# (if your machine is really hung, the loadavg will go much higher than 25)
max-load-1		= 24
#max-load-5		= 18
#max-load-15		= 12

# Note that this is the number of pages!
# To get the real size, check how large the pagesize is on your machine.
#min-memory		= 1

#repair-binary		= /usr/sbin/repair
#repair-timeout		= 
#test-binary		= 
#test-timeout		= 

watchdog-device	= /dev/watchdog

# Defaults compiled into the binary
#temperature-device	=
#max-temperature	= 120

# Defaults compiled into the binary
#admin			= root
#interval		= 1
#logtick                = 1
#log-dir		= /var/log/watchdog

# This greatly decreases the chance that watchdog won't be scheduled before
# your machine is really loaded
realtime		= yes
priority		= 1

# Check if syslogd is still running by enabling the following line
#pidfile		= /var/run/syslogd.pid

 

 

 

max-load-1 = 24

watchdog-device = /dev/watchdog

 

이 두곳의 # 주석 문자를 삭제 한다.

 

5. watchdog 을 실행한다.

 

sudo service watchdog start

 

 

 

 

이렇게 하면 라즈베리파이에 watchdog 설정이 끝난다.

 

실험 해본 결과 왠만한 freez 현상에는 리셋이 되는게 확인된다.

 

반응형