Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 448334 - sys-apps/hdparm: add support for disk id in /etc/init.d/hdparm
Summary: sys-apps/hdparm: add support for disk id in /etc/init.d/hdparm
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal enhancement with 4 votes (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-23 22:15 UTC by Axel
Modified: 2017-12-28 12:04 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch for sys-apps/hdparm-9.39 (hdparm-conf-disk-id.patch,801 bytes, patch)
2012-12-23 23:36 UTC, Axel
Details | Diff
Updated version hdparm-init.patch (hdparm-init.patch,849 bytes, patch)
2016-05-27 22:33 UTC, Torsten Kurbad
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Axel 2012-12-23 22:15:02 UTC
The config file /etc/conf.d/hdparm missed a way to specify hdparms arguments to a disk identifier in a safe manner (if disks or drivers changes it won't need a configuration need).

The patch allows a new type of lines in the config file: disk_id_args="args" where the disk_id is found in /dev/disk/by-id. The only problem is that shell scripts don't allow variable names with dash so it is replaced with underscores.

Here is a sample of my config file, comments included:

# or, you can set hdparm for a drive according to its disk id (as dashed are
# replaced by underscores)
ata_ST31000340AS_5QJ09CXD_args="-S241"
ata_ST31500341AS_9VS2LDYD_args="-S60"
ata_ST3750640AS_3QD01H97_args="-S60"


Reproducible: Always

Steps to Reproduce:
This is a patch



patch content:

--- a/etc/init.d/hdparm	2012-12-23 21:53:15.423446657 +0100
+++ b/etc/init.d/hdparm	2012-12-23 23:00:44.519375160 +0100
@@ -123,8 +123,21 @@
 		if [ -b "${device}" ] && [ "${status}" = "0" -o "${nomed}" = "0" ] ; then
 			local conf_var="${device##*/}_args"
 			eval args=\$${conf_var}
-			do_hdparm
 		fi
+
+		# allows a disk to be configured using its id (override above)
+		# we replace all dashes by underscores
+		for alias in /dev/disk/by-id/* ; do
+			if [ "${alias}" -ef "${device}" ] ; then
+				eval args_tmp=\$"$(basename "${alias}" | sed 's/-/_/')"_args
+				if [ -n "${args_tmp}" ]; then
+					args="${args_tmp}"
+				fi
+				break
+			fi
+		done
+
+		do_hdparm
 	done
 }
Comment 1 Axel 2012-12-23 23:36:00 UTC
Created attachment 333172 [details, diff]
patch for sys-apps/hdparm-9.39

Improved patch (fix hdparm was called when args was not set) and works against sys-apps/hdparm-9.39 (tested).
Comment 2 Kaoru Esashika 2015-08-06 06:56:59 UTC
Thank you for the nice patch!
This patch should be accepted, I think.
Comment 3 Torsten Kurbad 2016-05-27 22:33:44 UTC
Created attachment 435586 [details, diff]
Updated version hdparm-init.patch

Nice patch - works very well for me.

Two things, however:

1) To install a version of hdparm that includes the patch, it should be against sys-apps/hdparm/files/hdparm-init-8, not against /etc/init.d/hdparm

2) You have to mask not only '-', but ':' (and probably other special characters), too. Replacing colons by underscores is included in this updated patch. USB sticks tend to have colons in their ids...

Would very much like to see that included in the official hdparm ebuild.

Best,
Torsten