Skip to content

Instantly share code, notes, and snippets.

@rmi1974
Created January 25, 2023 12:55
Show Gist options
  • Save rmi1974/a641a57ee513aa8aab99250626f07c6b to your computer and use it in GitHub Desktop.
Save rmi1974/a641a57ee513aa8aab99250626f07c6b to your computer and use it in GitHub Desktop.
How to spin-down hard drives with hd-idle #commandlinefu #hd-idle #hdidle

How to spin-down hard drives with hd-idle

Courtesy of github.com adelolmo hd-idle

Prerequisite:

$ sudo dnf install golang

Download and build:

$ git clone https://github.com/adelolmo/hd-idle

$ hd-idle/

$ make

$ sudo make install

$ sudo cp hd-idle.service /usr/lib/systemd/system

Modify /usr/lib/systemd/system/hd-idle.service to adjust to default install path in /usr/local/sbin/:

[Unit]
Description=hd-idle - spin down idle hard disks
Documentation=man:hd-idle(8)
After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

[Service]
Type=simple
EnvironmentFile=/etc/default/hd-idle
ExecStart=/usr/local/sbin/hd-idle $HD_IDLE_OPTS
Restart=always

[Install]
WantedBy=multi-user.target

Create and modify '/etc/default/hd-idle'

HD_IDLE_OPTS="-i 1200 -l /var/log/hd-idle.log"

Enable and start:

$ sudo systemctl enable hd-idle
Created symlink /etc/systemd/system/multi-user.target.wants/hd-idle.service → /usr/lib/systemd/system/hd-idle.service.

$ sudo systemctl start hd-idle
$ sudo systemctl status hd-idle
● hd-idle.service - hd-idle - spin down idle hard disks
     Loaded: loaded (/usr/lib/systemd/system/hd-idle.service; enabled; preset: disabled)
     Active: active (running) since Wed 2023-01-25 13:45:57 CET; 6s ago
       Docs: man:hd-idle(8)
   Main PID: 1026425 (hd-idle)
      Tasks: 5 (limit: 18744)
     Memory: 1.0M
        CPU: 3ms
     CGroup: /system.slice/hd-idle.service
             └─1026425 /usr/local/sbin/hd-idle -i 1200 -l /var/log/hd-idle.log

Jan 25 13:45:57 zotac systemd[1]: Started hd-idle.service - hd-idle - spin down idle hard disks.
Jan 25 13:45:57 zotac hd-idle[1026425]: symlinkPolicy=0, defaultIdle=1200, defaultCommand=scsi, debug=false, logFile=/var/log/hd-idle.log, devices=

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment