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 }
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).
Thank you for the nice patch! This patch should be accepted, I think.
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