New upstream version 1.21

This commit is contained in:
root
2025-08-06 15:37:55 +02:00
parent 0343893f09
commit 0ef82355c6
40 changed files with 3389 additions and 1136 deletions

226
debian/changelog vendored
View File

@@ -1,70 +1,214 @@
hd-idle (1.05) unstable; urgency=low
hd-idle (1.21) unstable; urgency=medium
* Allow SCSI device names with more than one character (e.g. sdaa) in case
there are more than 26 SCSI targets.
[ Gray Xu ]
* Use GivenName instead of Name in the log
-- Christian Mueller <cm1@mumac.de> Sun, 6 Apr 2014 22:02:00 +0200
[ Andoni del Olmo ]
* Support Jmicron USB Bridge Controller for ATA command
hd-idle (1.04) unstable; urgency=low
-- Andoni del Olmo <andoni.delolmo@gmail.com> Sun, 22 Oct 2023 09:55:29 +0200
* Make hd-idle's build environment compatible to Debian package management;
this effort is meant to allow hd-idle to become an official Debian package
* Man page for hd-idle
hd-idle (1.20) unstable; urgency=medium
-- Christian Mueller <cm1@mumac.de> Fri, 30 Sep 2011 22:35:12 +0200
* Fix force hd-idle into background in init script
* Fix missing man page
hd-idle (1.03) unstable; urgency=low
* Use %u in dprintf() when reporting number of reads and writes (the
corresponding variable is an unsigned int).
* Fix example in README where the parameter "-a" was written as "-n".
-- Andoni del Olmo <andoni.delolmo@gmail.com> Fri, 17 Feb 2023 16:54:38 +0100
-- Christian Mueller <cm1@mumac.de> Sun, 5 Dec 2010 19:25:51 +0100
hd-idle (1.19) unstable; urgency=medium
hd-idle (1.02) unstable; urgency=low
[ Benjamin Engele ]
* Support more than 26 disks.
* In case the SCSI stop unit command fails with "check condition", print a
hex dump of the sense buffer to stderr. This is supposed to help
debugging.
[ Paul Webster ]
* Use explicit uint64
-- Christian Mueller <cm1@mumac.de> Sat, 6 Nov 2010 15:47:00 +0100
[ Benjamin Engele ]
* Use standby instead of stop command.
* Support configuring power condition.
* Add and describe -p parameter usage.
* Adjusted documentation of power condition.
hd-idle (1.01) unstable; urgency=low
[ Martin Oemus ]
* fixed poolInterval calculation when using idle intervals of 0
[ Andoni del Olmo ]
* fixed Use UNIX time to calculate skew interval
-- Andoni del Olmo <andoni.delolmo@gmail.com> Thu, 09 Feb 2023 11:55:12 +0100
hd-idle (1.18) unstable; urgency=medium
* fix cross platform compilation
* simplify package generation in rules file
* Complete the list of targets for the service restart
-- Andoni del Olmo <andoni.delolmo@gmail.com> Wed, 17 Aug 2022 13:02:42 +0200
hd-idle (1.17) unstable; urgency=medium
[ Alexander Raab ]
* Readme cosmetics
[ Andoni del Olmo ]
* restart service after suspend
* go mod tidy
* Update readme with instructions to build with golang 17 or higher
* Add Makefile
* build debian package compiling with Makefile
* document usage of LUKS encrypted devices
* Redo explanation of how the log file works. Thanks to rabelux.
* restart service after hibernate
[ Sylvain Pasche ]
* Get statistics from device mapper devices
[ Andoni del Olmo ]
* use /sys/class/block/%s/holders for holderGetter + add test
* add test for statsForDisk
-- Andoni del Olmo <andoni.delolmo@gmail.com> Thu, 28 Jul 2022 18:12:46 +0200
hd-idle (1.16) unstable; urgency=medium
[ Maximilian Bichel ]
* Update help and man page to inform that "i" parameter with value zero never spins down disks.
[ Zhenyu Wu ]
* Try both ATA standby commands before fail.
-- Andoni del Olmo <andoni.delolmo@gmail.com> Sun, 05 Sep 2021 19:45:17 +0200
hd-idle (1.15) unstable; urgency=medium
* Handle disks with no partitions.
Encrypted disks do not have any partitions. In this case, the disk level activity has to be taken into
consideration.
-- Andoni del Olmo <andoni.delolmo@gmail.com> Mon, 05 Apr 2021 09:39:11 +0200
hd-idle (1.14) unstable; urgency=medium
* Add logrotate for log file /var/log/hd-idle.log
* Use partitions read/write to calculate disk activity:
It changes the method to calculate disk activity. Now the disk activity is calculated by watching read/write
changes on partition level instead of disk level.
-- Andoni del Olmo <andoni.delolmo@gmail.com> Sun, 28 Mar 2021 14:34:51 +0200
hd-idle (1.13) unstable; urgency=medium
* Fix crash when required arguments are not given. Now it will fail
gracefully when required arguments are missing.
* Add SystemV init script.
-- Andoni del Olmo <andoni.delolmo@gmail.com> Thu, 04 Mar 2021 20:33:26 +0100
hd-idle (1.12) unstable; urgency=medium
* Fix inconsistent spin down log. The release v1.11 changed the log output on spin down to
"/dev/sda spindown". Now is back to the format "sda spindown".
* Fix typo in help -h flag. This bug prevented showing the help on cli.
-- Andoni del Olmo <andoni.delolmo@gmail.com> Sat, 05 Dec 2020 15:43:05 +0100
hd-idle (1.11) unstable; urgency=medium
* Ignore sense response data for ata command to prevent error on arm64.
* Allow set command type in combination with -t option.
* Remove go-co-op dependency.
* Clean control and man page.
* Add copyright.
* Update readme. No need for GOPATH anymore.
-- Andoni del Olmo <andoni.delolmo@gmail.com> Sat, 31 Oct 2020 21:43:04 +0100
hd-idle (1.10) unstable; urgency=medium
* Check sectors read/write to determine disk activity
* Package. Move debian files to debian dir
* Package. Simplify rules and delete config handle system
* Update readme. Explain logs
* Update readme. Entry to response not ok error
-- Andoni del Olmo <andoni.delolmo@gmail.com> Sun, 09 Aug 2020 10:26:32 +0200
hd-idle (1.9) unstable; urgency=medium
* Improve log on start up and ATA error reporting.
-- Andoni del Olmo <andoni.delolmo@gmail.com> Wed, 11 Mar 2020 10:25:00 +0200
hd-idle (1.8) unstable; urgency=medium
* Allow usage of symlinks that point to partitions. Like: by-label, by-partlabel,
by-partuuid and by-uuid.
* Improve error handling when spin down fails.
-- Andoni del Olmo <andoni.delolmo@gmail.com> Wed, 23 Oct 2019 21:15:00 +0200
hd-idle (1.7) unstable; urgency=medium
* Change package section to admin and priority to optional.
* Fix man page format error.
* Move man page to section 8 (System administration commands and daemons).
* Sign package.
-- Andoni del Olmo <andoni.delolmo@gmail.com> Sun, 8 Sep 2019 08:47:00 +0200
hd-idle (1.6) unstable; urgency=low
* The parameter "-s" allows to resolve symlinks for disk names also in runtime.
It is disable by default, because resolving symlinks causes an overhead.
That means that disk symlinks only get resolved on start up by default.
If the parameter "-s" is set to 1, disk symlinks will be also resolve during
execution until the symlink is resolved.
-- Andoni del Olmo <andoni.delolmo@gmail.com> Wed, 28 Aug 2019 19:33:00 +0100
hd-idle (1.5) unstable; urgency=low
* Monitor the skew between monitoring cycles, on discovery of clock skew
reset the drive spin_down status to "spun up" and reset the time to current
in order to capture potential high loading or (more likely) recovery from
suspend or sleep
-- Andoni del Olmo <andoni.delolmo@gmail.com> Sat, 13 Aug 2019 21:15:00 +0100
hd-idle (1.4) unstable; urgency=low
* The parameter "-a" now also supports symlinks for disk names. Thus, disks
can be specified using something like /dev/disk/by-uuid/... Use "-d" to
verify that the resulting disk name is what you want.
Please note that disk names are resolved to device nodes at startup. Also,
since many entries in /dev/disk/by-xxx are actually partitions, partition
numbers are automatically removed from the resulting device node.
* Not really a bug, but the disk name comparison used strstr which is a bit
useless because only disks starting with "sd" and a single letter after
that are currently considered. Replaced the comparison with strcmp()
* Simply log spinup.
-- Christian Mueller <cm1@mumac.de> Fri, 26 Feb 2010 14:03:44 +0100
-- Andoni del Olmo <andoni.delolmo@gmail.com> Sat, 5 Jan 2019 18:42:00 +0100
hd-idle (1.00) unstable; urgency=low
hd-idle (1.3) unstable; urgency=low
* New parameter "-a" to allow selecting idle timeouts for individual disks;
compatibility to previous releases is maintained by having an implicit
default which matches all SCSI disks
* Set sleep time to 1/10th of the shortest idle time.
* Changed comparison operator for idle periods from '>' to '>=' to prevent
adding one polling interval to idle time
-- Andoni del Olmo <andoni.delolmo@gmail.com> Fri, 5 Oct 2018 20:47:10 +0100
* Changed sleep time before calling sync after updating the log file to 1s
(from 3s) to accumulate fewer dirty blocks before synching. It's still
a compromize but the log file is for debugging purposes, anyway. A test
with fsync() was unsuccessful because the next bdflush-initiated sync
still caused spin-ups.
hd-idle (1.2) unstable; urgency=low
-- Christian Mueller <cm1@mumac.de> Wed, 18 Nov 2009 20:53:17 +0100
* Persist user's config across package upgrades.
hd-idle (0.99) unstable; urgency=low
-- Andoni del Olmo <andoni.delolmo@gmail.com> Mon, 17 Sep 2018 22:03:10 +0100
* Initial Release.
hd-idle (1.1) unstable; urgency=low
-- Christian Mueller <cm1@mumac.de> Mon, 23 Apr 2007 22:03:10 +0100
* Add missing feature to spin-down the specified disk immediately.
-- Andoni del Olmo <andoni.delolmo@gmail.com> Sun, 16 Sep 2018 18:13:10 +0100
hd-idle (1.0) unstable; urgency=low
* Add "ata" api call to stop devices on top of the original functionality.
-- Andoni del Olmo <andoni.delolmo@gmail.com> Sun, 16 Sep 2018 10:01:10 +0100

2
debian/compat vendored
View File

@@ -1 +1 @@
7
9

28
debian/control vendored
View File

@@ -1,17 +1,16 @@
Source: hd-idle
Section: utils
Priority: extra
Maintainer: Christian Mueller <cm1@mumac.de>
Build-Depends: debhelper (>= 7.0.50~), libc6-dev
Standards-Version: 3.8.4
Homepage: http://hd-idle.sf.net
#Vcs-Git: git://git.debian.org/collab-maint/hd-idle.git
#Vcs-Browser: http://git.debian.org/?p=collab-maint/hd-idle.git;a=summary
Section: admin
Priority: optional
Maintainer: Andoni del Olmo <andoni.delolmo@gmail.com>
Build-Depends: debhelper (>=9), golang-go:native (>= 1.3.3), dh-golang
Standards-Version: 4.3.0
Vcs-Browser: https://github.com/adelolmo/hd-idle
Vcs-Git: https://github.com/adelolmo/hd-idle.git
Homepage: https://github.com/adelolmo/hd-idle
Package: hd-idle
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Spin down idle [USB] hard disks
Description: Spin down idle hard disks
hd-idle is a utility program for spinning-down external disks after a period
of idle time. Since most external IDE disk enclosures don't support setting
the IDE idle timer, a program like hd-idle is required to spin down idle disks
@@ -23,12 +22,3 @@ Description: Spin down idle [USB] hard disks
stress the spin-up causes on the spindle motor and bearings. It seems that
manufacturers recommend a minimum idle time of 3-5 minutes, the default in
hd-idle is 10 minutes.
.
One more word of caution: hd-idle will spin down any disk accessible via the
SCSI layer (USB, IEEE1394, ...) but it will not work with real SCSI disks
because they don't spin up automatically. Thus it's not called scsi-idle and
I don't recommend using it on a real SCSI system unless you have a kernel
patch that automatically starts the SCSI disks after receiving a sense buffer
indicating the disk has been stopped. Without such a patch, real SCSI disks
won't start again and you can as well pull the plug.

42
debian/copyright vendored
View File

@@ -1,34 +1,12 @@
This work was written and packaged by Christian Mueller <cm1@mumac.de>
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: hd-idle
Source: https://github.com/adelolmo/hd-idle
It was downloaded from: <http://hd-idle.sf.net>
Upstream Author(s): Christian Mueller <cm1@mumac.de>
Copyright:
<Copyright (C) 2007 Christian Mueller>
License:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
The Debian packaging is:
Copyright (C) 2011 Christian Mueller <cm1@mumac.de>
and is licensed under the GPL version 3, see above.
Files: *
Copyright: 2018 Andoni del Olmo <andoni.delolmo@gmail.com>
Author: Andoni del Olmo <andoni.delolmo@gmail.com>
License: GPL-3
Files: debian/hd-idle.8 debian/hd-idle.default debian/control
Copyright: 2007 Christian Mueller <cm1@mumac.de>
License: GPL-3

1
debian/docs vendored
View File

@@ -1 +0,0 @@
README

127
debian/hd-idle.8 vendored Normal file
View File

@@ -0,0 +1,127 @@
.\" Hey, EMACS: -*- nroff -*-
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH HD-IDLE 8 "September 8, 2019"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
.\" .nh disable hyphenation
.\" .hy enable hyphenation
.\" .ad l left justify
.\" .ad b justify to both left and right margins
.\" .nf disable filling
.\" .fi enable filling
.\" .br insert line break
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
hd-idle \- spin down idle hard disks
.SH SYNOPSIS
.B hd-idle
.RI [ options ]
.P
.SH DESCRIPTION
hd-idle is a utility program for spinning down external disks after a period
of idle time. Since most external IDE disk enclosures don't support setting
the IDE idle timer, a program like hd-idle is required to spin down idle
disks automatically.
.P
A word of caution: hard disks don't like spinning up too often. Laptop disks
are more robust in this respect than desktop disks but if you set your disks
to spin down after a few seconds you may damage the disk over time due to the
stress the spin-up causes on the spindle motor and bearings. It seems that
manufacturers recommend a minimum idle time of 3-5 minutes, the default in
hd-idle is 10 minutes.
.SH OPTIONS
.TP
.B \-a name
Set device name of disks for subsequent idle-time parameters
.B (-i).
This parameter is optional in the sense that there's a default entry for
all disks which are not named otherwise by using this parameter. This can
also be a symlink (e.g. /dev/disk/by-uuid/...)
.TP
.B \-i idle_time
Idle time in seconds for the currently named disk(s) (-a <name>) or for
all disks.
Setting this value to "0" will never spin down the disk(s).
.TP
.B \-c command_type
Api call to stop the device. Possible values are "scsi" (default value)
and "ata".
.TP
.B \-p power_condition
Power condition to send with the issued SCSI START STOP UNIT command.
Possible values are "0-15" (inclusive). The default value of "0" works fine
for disks accessible via the SCSI layer (USB, IEEE1394, ...), but it will
*NOT* work as intended with real SCSI / SAS disks. A stopped SAS disk will
not start up automatically on access, but requires a startup command for
reactivation. Useful values for SAS disks are "2" for idle and "3" for standby.
.TP
.B \-s symlink_policy
Set the policy to resolve symlinks for devices. If set to "0", symlinks
are resolve only on start. If set to "1", symlinks are also resolved on
runtime until success. By default symlinks are only resolve on start.
If the symlink doesn't resolve to a device, the default configuration
will be applied.
.TP
.B \-l logfile
Name of logfile (written only after a disk has spun up). Please note that
this option might cause the disk which holds the logfile to spin up just
because another disk had some activity. This option should not be used on
systems with more than one disk except for tuning purposes. On single-disk
systems, this option should not cause any additional spinups.
.TP
.B \-t disk
Spin-down the specified disk immediately and exit. It can be used in combination
with
.B \-c
to specify the command type.
.TP
.B \-d
Debug mode. It will print debugging info to stdout/stderr (/var/log/syslog
if started as with systemctl)
.TP
.B \-h
Print usage information.
.SH "DISK SELECTION"
The parameter
.B \-a
can be used to set a filter on the disk's device name (omit /dev/) for
subsequent idle-time settings. The default is all disks:
.P
.TP
.B \1)
A
.B \-i
option before the first
.B \-a
option will set the default idle time.
.TP
.B \2)
In order to disable spin-down of disks per default, and then re-enable
spin-down on selected disks, set the default idle time to 0.
.SH EXAMPLE
hd-idle -i 0 -a sda -i 300 -a sdb -i 1200
.P
This example sets the default idle time to 0 (meaning hd-idle will never
try to spin down a disk) and default "scsi" api command, then sets explicit
idle times for disks which have the string "sda" or "sdb" in their device name.
.SH EXAMPLE
hd-idle -i 0 -c ata -a sda -i 300 -a sdb -i 1200 -c scsi
.P
This example sets the default idle time to 0 (meaning hd-idle will never
try to spin down a disk) and default "ata" api command, then sets explicit
idle times for disks which have the string "sda" or "sdb" in their device name
and sets "sdb" to use "ata" api command.
.P
The option -c allows to set the api call that sends the spindown command.
Possible values are "scsi" (the default value) or "ata".
.SH AUTHOR
hd-idle was written by Andoni del Olmo <andoni.delolmo@gmail> based on Chistian Mueller's <chris@mumac.de> work.
.PP
This manual page was written by Christian Mueller <chris@mumac.de>, for the Debian
project (and may be used by others).
.PP
Modified by Andoni del Olmo <andoni.delolmo@gmail.com>.

View File

@@ -12,6 +12,20 @@ START_HD_IDLE=false
# parameter. This can also be a symlink
# (e.g. /dev/disk/by-uuid/...)
# -i <idle_time> Idle time in seconds.
# -c <command_type> Api call to stop the device. Possible values are "scsi"
# (default value) and "ata".
# -p <power_condition>
# Power condition to send with the issued SCSI START STOP UNIT command. Possible values
# are `0-15` (inclusive). The default value of `0` works fine for disks accessible via the
# SCSI layer (USB, IEEE1394, ...), but it will *NOT* work as intended with real SCSI / SAS disks.
# A stopped SAS disk will not start up automatically on access, but requires a startup command for reactivation.
# Useful values for SAS disks are `2` for idle and `3` for standby.
# -s symlink_policy Set the policy to resolve symlinks for devices.
# If set to "0", symlinks are resolve only on start.
# If set to "1", symlinks are also resolved on runtime
# until success. By default symlinks are only resolve on start.
# If the symlink doesn't resolve to a device, the default
# configuration will be applied.
# -l <logfile> Name of logfile (written only after a disk has spun
# up). Please note that this option might cause the
# disk which holds the logfile to spin up just because
@@ -21,10 +35,8 @@ START_HD_IDLE=false
# this option should not cause any additional spinups.
#
# Options not exactly useful here:
# -t <disk> Spin-down the specfified disk immediately and exit.
# -d Debug mode. This will prevent hd-idle from
# becoming a daemon and print debugging info to
# stdout/stderr
# -t <disk> Spin-down the specified disk immediately and exit.
# -d Debug mode. It will print debugging info to
# stdout/stderr (/var/log/syslog if started as with systemctl)
# -h Print usage information.
#HD_IDLE_OPTS="-i 180 -l /var/log/hd-idle.log"
#HD_IDLE_OPTS="-i 180 -l /var/log/hd-idle.log"

17
debian/hd-idle.init vendored Executable file → Normal file
View File

@@ -1,4 +1,5 @@
#!/bin/sh
set -e
### BEGIN INIT INFO
# Provides: hd-idle
@@ -6,22 +7,16 @@
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start hd-idle daemon (spin down idle hard disks)
# Short-Description: Start hd-idle daemon
# Description: Start hd-idle daemon (spin down idle hard disks)
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/hd-idle
HD_IDLE_OPTS="-i 600"
START_HD_IDLE=false
[ -r /etc/default/hd-idle ] && . /etc/default/hd-idle
if [ "$START_HD_IDLE" != "true" ] ; then
exit 0
fi
# See if the daemon is there
test -x $DAEMON || exit 0
@@ -31,7 +26,7 @@ case "$1" in
start)
log_daemon_msg "Starting the hd-idle daemon" "hd-idle"
start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- $HD_IDLE_OPTS
start-stop-daemon --start --quiet --oknodo --background --exec $DAEMON -- $HD_IDLE_OPTS
log_end_msg $?
;;
@@ -45,7 +40,9 @@ case "$1" in
restart|force-reload)
$0 stop && sleep 2 && $0 start
;;
status)
status_of_proc $DAEMON hd-idle && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/hd-idle start/stop/restart/force-reload"
exit 1

6
debian/hd-idle.logrotate vendored Normal file
View File

@@ -0,0 +1,6 @@
/var/log/hd-idle.log {
missingok
notifempty
compress
delaycompress
}

13
debian/hd-idle.service vendored Normal file
View File

@@ -0,0 +1,13 @@
[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/sbin/hd-idle $HD_IDLE_OPTS
Restart=always
[Install]
WantedBy=multi-user.target

21
debian/rules vendored
View File

@@ -1,13 +1,14 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1
export DH_VERBOSE=1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%:
dh $@
dh $@
override_dh_auto_build:
override_dh_auto_install:
install -d $(CURDIR)/debian/hd-idle
make install DESTDIR=$(CURDIR)/debian/hd-idle ARCH=$(DEB_HOST_ARCH)
override_dh_strip: