Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 334435 - app-laptop/hdapsd-20090401-r1 add support of removable disk to init script
Summary: app-laptop/hdapsd-20090401-r1 add support of removable disk to init script
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Christoph Junghans (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-25 13:06 UTC by Uwe Sauter
Modified: 2013-05-28 16:32 UTC (History)
0 users

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


Attachments
The new config file for monitoring multiple disks (hdapsd.conf,395 bytes, text/plain)
2010-09-19 14:03 UTC, Weihua Zhou
Details
The initial script for hdapsd services (hdapsd.init,1.42 KB, text/plain)
2010-09-19 14:04 UTC, Weihua Zhou
Details
fixed init.d/hdapsd (hdapsd.diff,314 bytes, patch)
2011-12-21 21:20 UTC, roo
Details | Diff
diff agains files/hdapsd.init (hdaps.init.diff,1.22 KB, patch)
2011-12-22 13:53 UTC, Henning Schild
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Uwe Sauter 2010-08-25 13:06:17 UTC
I have a Lenovo Thinkpad T400 with additional SATA harddrive instead of the DVD drive in it's Ultrabay.

After installing tp_smapi and hdapsd and editing /etc/conf.d/hdapsd I wanted to start the deamon which didn't work.

The init script only allows monitoring of one drive while the deamon itself can monitor several drives (see man page, option "-d").

Reproducible: Always

Steps to Reproduce:
1. Get your hands on a laptop with HDAPS and a second HDD
2. Install hdapsd and dependencies, especially the external tp_smapi package instead of the kernel-internal hdaps interface.
3. Add second drive to DISK in /etc/conf.d/hdapsd:
Chang DISK="sda" to DISK="sda sdb" or something similar.
4. Execute /etc/init.d/hdapsd start

Actual Results:  
Starting the service fails as the init script can't handle multiple disks.

/etc/init.d/hdapsd: line 15: [: /dev/sda: binary operator expected
 * No protect entry for sda sdb!
 * Make sure your kernel is patched with the blk_freeze patch

Expected Results:  
Init script should handle multiple disks.
Comment 1 Uwe Sauter 2010-08-25 13:11:08 UTC
A workaround would be to change /etc/conf.d/hdapsd:

Change
OPTIONS="-a"
to
OPTIONS="-a -d sdb"
Comment 2 Weihua Zhou 2010-09-19 14:03:08 UTC
Created attachment 247998 [details]
The new config file for monitoring multiple disks

I just change the DISK option to DISKLIST option.
Comment 3 Weihua Zhou 2010-09-19 14:04:25 UTC
Created attachment 247999 [details]
The initial script for hdapsd services

With this script and the new config file, hdapsd can monitor multiple disks.
Comment 4 Weihua Zhou 2010-09-19 14:06:05 UTC
(In reply to comment #1)
> A workaround would be to change /etc/conf.d/hdapsd:
> 
> Change
> OPTIONS="-a"
> to
> OPTIONS="-a -d sdb"
> 

I just thought this might be a little ugly. It might be better that someone change the script file and config file in the portage tree.
Comment 5 Uwe Sauter 2010-09-20 16:11:07 UTC
(In reply to comment #2 & #3)

DISKLIST works for me. I can choose either disk or both. Only the chosen one gets monitored.

Can you put this into the portage tree?


(In reply to comment #4)
> I just thought this might be a little ugly.
Yeah. That was just quick & dirty.
Comment 6 Uwe Sauter 2010-09-20 16:12:04 UTC
(In reply to comment #2 & #3)

DISKLIST works for me. I can choose either disk or both. Only the chosen one gets monitored.

Can someone put this into the portage tree and close the bug?


(In reply to comment #4)
> I just thought this might be a little ugly.
Yeah. That was just quick & dirty.
Comment 7 Christoph Junghans (RETIRED) gentoo-dev 2011-12-21 04:53:08 UTC
Added in hdapsd-20090401-r1, please test!
Comment 8 roo 2011-12-21 21:20:14 UTC
Created attachment 296605 [details, diff]
fixed init.d/hdapsd

the initscript included with the hdapsd-20090401-r1.ebuild passes only the last device in the DISKLIST to hdapsd
Comment 9 Christoph Junghans (RETIRED) gentoo-dev 2011-12-22 04:32:37 UTC
Fixed, thanks!
Comment 10 Henning Schild 2011-12-22 13:51:38 UTC
I am using a modified version of the init script for a long time now. I also wanted it to support more than one disk. Yesterday i got -r1 which added this feature which i never reported. But the new init script is missing one important point. The second disk is usually sitting in the ultrabay and is removeable, meaning it is not always around. I hotswap the DVD drive and the disk.
Whenever i insert a new device udev will restart hdapsd.
My version of the init script will not fail if one of the disks on the list does not exist or does not support the unload feature. It will generate a warning and skip that disk. That way i can have both disks on the list and the init script will start hdapsd even if only one of the two is present.

I will attach the script i am using. I did not report this bug because i thought not a lot of gentoo users would actually have a disk in the ultrabay, or care about it being monitored by hdapsd.
Comment 11 Henning Schild 2011-12-22 13:53:15 UTC
Created attachment 296659 [details, diff]
diff agains files/hdapsd.init

in the conf file DISK is simply a list, i did not rename it to DISKLIST
DISK="sda sdb"
Comment 12 Henning Schild 2011-12-22 13:54:28 UTC
please reopen and let us get the new init script right so that it will not fail when one of the disks is not present
Comment 13 Henning Schild 2011-12-22 14:05:27 UTC
Thinking about it more carefully the list does not have to be there at all, because one could just look for the unload_heads file in all the the block device directories. If the script did that by default hdapsd would monitor all possible devices by default. Having a disklist conf variable might still be usefull for people that want to exclude devices for some reason.
Comment 14 Christoph Junghans (RETIRED) gentoo-dev 2011-12-22 15:28:20 UTC
Good point, I thought more about 2 disks in the laptop itself.
Comment 15 Christoph Junghans (RETIRED) gentoo-dev 2011-12-22 15:40:08 UTC
Henning, can you create a diff against hdapsd.init.2?
Is there something else needed to make udev trigger a restart of hdapsd?
Comment 16 Florian Eitel 2012-05-15 09:55:16 UTC
If no -d option is given hdapsd try to auto-detect devices. It looks for all devices in /sys/block/ for a device/unload_heads or queue/protect file. Additionally it checks if the file is removable or not and don't watch any removable devices. I think this would be a good default option. So no DISK variable and no selection in initscript is needed.
Comment 17 Christoph Junghans (RETIRED) gentoo-dev 2012-11-18 20:41:35 UTC
Incorporated auto-detecting support in hdapsd-20090401-r2.
Comment 18 Christoph Junghans (RETIRED) gentoo-dev 2012-11-18 20:43:59 UTC
We still need to trigger restart of hdapsd by udev if a disk was removed/added.
Comment 19 Christoph Junghans (RETIRED) gentoo-dev 2013-05-28 16:32:48 UTC
No response after 1 year, I changed to a different thinkpad with a ssd, so I don't use hdapsd anymore. Feel free to re-open if needed.