RPi Configuring Watchdog and Hard Drive Auto-Sleep

  • rpi 3b watchdog
  • 硬盘闲置自动休眠

请依据CPU型号修改watchdog设备


hdparm


安装hdparm(略)

测试hdparm

hdparm链接

1
sudo hdparm -y /dev/sda1

如果没有报错就支持

1
sudo hdparm -I /dev/sda1|grep cache

如果看到有”*“就支持缓存

编辑hdparm

1
sudo nano /etc/hdparm.conf

加入

1
2
3
4
/dev/sda1 {
write_cache = on
spindown_time = 120
}

如果不支持缓存就不要加入write_cache那行

下面延时计算是 无操作休眠时间(分钟)*60/5

watchdog


安装watchdog(略)

载入watchdog

1
2
3
sudo modprobe bcm2835_wdt
sudo nano /etc/modules
bcm2835_wdt

编辑配置

1
sudo /etc/watchdog.conf

修改

1
2
3
4
5
max-load-1=24
watchdog-device = /dev/watchdog
watchdog-timeout=20
temperature-sensor = /sys/class/thermal/thermal_zone0/temp
max-temperature = 85000

启动

1
2
sudo systemctl enable watchdog.service
sudo chkconfig watchdog on

附赠一个fork bomb

1
:(){ :|: & };:
  • rpi 3b watchdog
  • Hard drive idle auto-sleep

Please modify the watchdog device according to your CPU model


hdparm


Install hdparm (omitted)

Test hdparm

hdparm link

1
sudo hdparm -y /dev/sda1

If there is no error, it is supported.

1
sudo hdparm -I /dev/sda1|grep cache

If you see “*“, cache is supported.

Edit hdparm

1
sudo nano /etc/hdparm.conf

Add

1
2
3
4
/dev/sda1 {
write_cache = on
spindown_time = 120
}

If cache is not supported, do not add the write_cache line.

The delay calculation below is: idle sleep time (minutes) * 60 / 5

watchdog


Install watchdog (omitted)

Load watchdog

1
2
3
sudo modprobe bcm2835_wdt
sudo nano /etc/modules
bcm2835_wdt

Edit configuration

1
sudo /etc/watchdog.conf

Modify

1
2
3
4
5
max-load-1=24
watchdog-device = /dev/watchdog
watchdog-timeout=20
temperature-sensor = /sys/class/thermal/thermal_zone0/temp
max-temperature = 85000

Start

1
2
sudo systemctl enable watchdog.service
sudo chkconfig watchdog on

Bonus: A fork bomb

1
:(){ :|: & };:

RPi Configuring Watchdog and Hard Drive Auto-Sleep
https://tokisaki.top/blog/rpi-watchdog-config/
作者
Tokisaki Galaxy
发布于
2019年11月5日
许可协议