OpenWrt

52 views
Skip to first unread message

Michael Mahr

unread,
Nov 23, 2009, 5:59:02 PM11/23/09
to Spindown Support
Hello.

I am currently porting your spindown application to OpenWrt. (A Linux
distribution for WLAN-Routers - mostly MIPS)
Many people build their own network-attached storage system by
attaching an external harddisk-enclosure via USB.

And since those devices consume very little power they are usually on
24/7, which leaves the harddisks spinning unused most of the time.

Your software is working flawlessly on the routers. However there are
two "corners" which I would need to patch away.
(Live-applying the patches isn't a problem - however if you like the
two ideas and add them in the next release, I won't have to create
patches for them)

--

1) In /Makefile two two variables should be renamed, so that the
framework can inject the correct values for the cross-compiler:

Line 6-7:
-CC = g++
-CFLAGS =-O1
should be replaced by:
+CXX = g++
+CXXFLAGS =-O1

Line 63:
- g++ $(CFLAGS) -o spindownd $(OBJS)
should be replaced by:
- $(CXX) $(LDFLAGS) -o spindownd $(OBJS)

Line 63:
- g++ $(CFLAGS) -o spindownd $(OBJS)
should be replaced by:
- $(CXX) $(LDFLAGS) -o spindownd $(OBJS)

And in Line 66,69,71,75,78,81,87 and 90
- g++ $(CFLAGS)
should be replaced by
+ $(CXX) $(CXXFLAGS)

(You should probably also declare LDFLAGS at the beginning of the file
(they might differ from the compile-flags))
If you are curious: When compiling for broadcom chipsets, "mipsel-
openwrt-linux-uclibc-g++" is injected into CXX.

--

2)
The other "corner" concerns the config-file.
With openwrt the users usually want to idle ALL media. (The flash-
memory off which it boots doesn't appear as /dev/sd* anyway. And USB-
Sticks simply refuse to idle.)

I found out that the program does not allow specifying the parameters
"command = ..." and "spindown = 1" in the global section of the config
file.
This however would be very helpful if the user wants to idle any
connected media. (If your software has the ability to enumerate all
devices on the system that is.)

--

Oh yes, another small thing... "sg_start --stop --pc=2" (in
combination) works on almost all devices. You might want to make that
the default.

--

Your software is very nice. Thanks.
(By the way: you won't get any init-script problems from the OpenWrt
side, because in OpenWrt they are very slim and standardized)

yours, Michael Mahr

Dimitri Michaux

unread,
Nov 24, 2009, 5:52:58 PM11/24/09
to spindown...@googlegroups.com
Hi Michael,

It's great to hear that you find my program useful :D

I'm familiar with OpenWrt, I wanted to try it myself, but this was after I
bought the new WRT45G :(

I will try to do the Makefile and the default settings tomorrow.

Getting it to spin down every drive is going to be some more work, because I
currently only spin the drives down that are specified. This would mean I have
to find a way of detecting all disk drives. I guess all sd- and hd-devices
should be ok. It might take a couple of days, but I'll gladly do it :)

The init files are nothing but trouble. I have no idea how to manage all these
different types of init script for all those distributions. Maybe I should
write it more generic one? And to make things worse there's also upstart now.
I know it probably won't apply to OpenWrt, but do you maybe have an idea?

I'll let you know how it comes along.

Regards,
Dimitri
> --
>
> You received this message because you are subscribed to the Google Groups
> "Spindown Support" group. To post to this group, send email to
> spindown...@googlegroups.com. To unsubscribe from this group, send
> email to spindown-suppo...@googlegroups.com. For more options,
> visit this group at http://groups.google.com/group/spindown-support?hl=.
>

Michael Mahr

unread,
Nov 26, 2009, 2:06:24 AM11/26/09
to Spindown Support
Hi there.

Thanks. I am glad to hear that. I will of course test it.

--

If you implement iterating through devices, you probably should not
use the /dev/disk directory. Udev is not present on some platforms -
including openwrt (per default).
(In this case you currently cannot configure the discs via id in
spindown.conf, but specifying devices works)

In order not to increase dependencies you could go through proc
diskstats and do it for every device which matches "sd?" or "hd?".
I think hardcoding it to these two would be ok, since your software
won't with non-linux unixes anyway. (The others don't have /proc/
diskstats.)

--

Concerning init-scripts:

Well, you could consider not supporting a fancy init-script...
Every distribution has its own convention here.
Most distributions have a skeleton init-script which simply is a
template. (/etc/init.d/skeleton)
In a perfect world your software is ready-packaged for the
distributions by the package maintainers and they would create and
integrate the script for the users.

But in the meantime you can search the web for a very basic posix
compliant init-script (without all status-stuff). This should work for
all distributions.
You can even avoid all shell and path quirks by simply doing:

at start)
killall spindownd > /dev/null 2> /dev/null
spindownd --daemon

at stop)
killall spindownd

It is not supposed to run twice anyway...
This should be sufficient for most users.

--

Regards, Michael


On Nov 24, 11:52 pm, Dimitri Michaux <dimitri.mich...@gmail.com>
wrote:

Dimitri

unread,
Nov 26, 2009, 4:48:39 PM11/26/09
to Spindown Support
Hi Michael,

Thank you for your suggestions.

I think I'm going to add a new configuration option called [Default
Disk] or something like that. In that disk you can then specify the
defaults for the exact same parameters that you find for a normal disk
(excluding id and name).

Changing the code can take a couple of days because the program
depends heavily on /dev/disk/by-id. So I have to make that code
optional and then let you specify if you want it or not at compile
time.

I actually had an ini file like that in the beginning, but I changed
it because I didn't think the output was nice enough. I guess I'll
better put it back :D

Michael Mahr

unread,
Nov 27, 2009, 7:09:32 PM11/27/09
to Spindown Support
Hi again,

I think you got me wrong about the /dev/disk/by-id/ part.
The current version of Spindown works without it, by specifying
device-nodes like /dev/sda directly. The user only needs /dev/disk/by-
id/ if he wants to specify devices over their ID in spindown.conf.
I think this behaviour is perfectly ok.

I just ment that when walking through all attached devices (for
spinning down any attached device), you should not depend on the
directory.

No, please don't go back to ini-files. :)
It is a linux tool, not a generic unix tool. There is nothing wrong
with that.

-

You could even simplify the code and let the user specify the device
in the config-file on his own. ("device = /dev/sda" or "device =
/dev/disk/by-id/Samsung-0123456789abcdef")
(And mention this possibility in the example config-script.)
If users are missing the /dev/disk folder it will be pretty obvious
for them why it doesn't work... :)

From the user perspective: My fist attempt to enable spindown on all
drives was to put "spindown = 1" in the global section of the config-
file.

However it is your software. Please don't feel pushed. I'm just
posting my opinion in form of suggestions.
Please don't overthrow your software because of me.


lg, Michael Mahr

PS.: By the way... The choice of the name "spindown" for your software
is pretty clever. Everyone searching the web for something like this
will find your software first.

Dimitri Michaux

unread,
Dec 1, 2009, 5:29:17 PM12/1/09
to spindown...@googlegroups.com
Hi,

Here's what I have now: when you start the daemon it will apply the default
settings to all hard drives that it detects. You can then use the config file
like before and customize per drive if you want that.

> You could even simplify the code and let the user specify the device
> in the config-file on his own. ("device = /dev/sda" or "device =
> /dev/disk/by-id/Samsung-0123456789abcdef")

That's actually a very good idea, this would make thing much easier for me and
the users. Thank you :D

I'm going to stick with the ini file, but I could make a version that doesn't
use a configuration file if you're looking for something simpler?
> visit this group at http://groups.google.com/group/spindown-support?hl=en.
>

Dimitri

unread,
Dec 6, 2009, 5:08:26 PM12/6/09
to Spindown Support
Hi again,

If you're still interested I have uploaded a version of spindown that
does what you want into the trunk.

The following configuration will do what you want:

[Spindown]
cycle-time = 3
syslog = 0

[Default Disk]
idle-time = 1800
spindown = 1
command = sg_start --stop --pc=2
repeat = 0

This will spindown all the disks with the settings as specified in
"Default Disk".

I have tested the code, but it is very likely that there are still
bugs. If you find some, please tell me.

Regards,
Dimitri
> ...
>
> read more »

Michael Mahr

unread,
Dec 9, 2009, 8:27:21 PM12/9/09
to Spindown Support
Thanks, I'll try it.
Could take a few days however...

lg, Michael
> ...
>
> read more »

Dimitri

unread,
Dec 10, 2009, 7:14:31 AM12/10/09
to Spindown Support
Ok, take your time. I hope it works for you.

Bey,
Dimitri
> > > > > > > > connected media. (If...
>
> read more »
Reply all
Reply to author
Forward
0 new messages