New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

B3 | USB-laptop cooler & autostart script / HDD temp

Got problems with your B2 or B3? Share and get helped!
su_root
Posts: 38
Joined: 29 Nov 2011, 06:27

B3 | USB-laptop cooler & autostart script / HDD temp

Post by su_root »

Hi,

I have not yet bought my B3 (waiting for 3TB drives) but I was thinking that it could be useful to add some cooling to the device
1) in the summer when it is hot
2) when HDD or system temperature > X degrees

Needed hardware:
A fan:
(google usb fan)
or laptop cooler:
(google laptop cooler)

Does anybody know howto monitor the temperature with hddtemp & lm_sensors and "activate" USB-port (where the cooling device is plugged in) when a value of X is met?

BR,
Chris
su_root
Posts: 38
Joined: 29 Nov 2011, 06:27

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by su_root »

Hi,

Thank You for Your reply!

But I do not want to modify it like this :) Also, I do want to turn on the fans only when the temperature is "too hot".

The first problem is howto control the power to USB port/s. The following did not work:

Code: Select all

echo suspend > /sys/bus/usb/devices/usb1/power/level
An alternative would be to use a X10 module etc. but it would be much better to just be able to turn off and on USB-port with a script.

BR,
Chris
Last edited by su_root on 29 Nov 2011, 14:45, edited 1 time in total.
su_root
Posts: 38
Joined: 29 Nov 2011, 06:27

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by su_root »

Hmm, I can as an example turn off my USB-mouse with:

Code: Select all

echo auto > 7-1/power/level
and turn in back on with:

Code: Select all

echo on > 7-1/power/level
Need to buy a USB-cooler and test with real hardware :)
su_root
Posts: 38
Joined: 29 Nov 2011, 06:27

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by su_root »

This should work for getting the HDD temperature (run it as a cron job every ~2 hours?)

edit: running in crontab is not a good idea if we want to have less HDD reads/writes. Better start script at boot and add loop to the script with sleep?

Code: Select all


#!/bin/bash

#set the max temperature, a value above maxtemp executes the cooling
maxtemp=40
#where is the cooling device plugged in? Look up your USB-port with lsusb
usbport=/sys/bus/usb/devices/7-1

#lines below should not be edited
startfan=$(echo on > $usbport/power/level)
stopfan=$(echo auto > $usbport/power/level)

currenttemp=$(hddtemp -n)

if [ $currenttemp -gt $maxtemp ]; then
#	echo " warning ";
        $startfan
else
#	echo " OK ";
        $stopfan
fi


Last edited by su_root on 30 Nov 2011, 16:25, edited 1 time in total.
su_root
Posts: 38
Joined: 29 Nov 2011, 06:27

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by su_root »

I noticed that hddtemp can be run in daemon mode (hddtemp -d).

Perhaps Excito could display on the admin page HDD temp (and why not also CPU)?

BTW, is the admin interface OpenSource, is it ok to make changes to the functions etc.?
6feet5
Posts: 269
Joined: 13 Apr 2007, 17:32
Location: Gnesta, Sweden
Contact:

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by 6feet5 »

Search the wiki, I think there is a post showing how to do this (or perhaps it was a forum post, can't remember).

/Johan
su_root
Posts: 38
Joined: 29 Nov 2011, 06:27

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by su_root »

Yes, found it, thanx!

Display the HDD temperature in the web portal [patch]:
viewtopic.php?f=8&t=2662

Power Save Mode B3 (interesting topic, was thinking of Wake On LAN etc. for B3..):
viewtopic.php?f=10&t=3289&p=16515

External temperature sensors?:
viewtopic.php?f=9&t=1943&p=9221

lm_sensors:
viewtopic.php?f=9&t=1844&p=8667

Conclusion: I'll forget about the CPU temperature and continue with HDD temp & cooling (and perhaps a schedule script to put B3 into standby when there aren't any vital processes running on it, ie suspend from 01:00 - 12:00 on week days and 02:00 - 09:00 on weekends). Possible a bad idea, need to think about it (=how much power/money is saved this way, EUR ~20/yearly..?).
johannes
Posts: 1470
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by johannes »

Interesting project! A few random comments:

- yes, almost all of B3 is open source, but in any case you are free to edit whatever you like
- there is no way (in hardware) to control the power to the USB ports. You need support from the USB devices in order to shut them down or control speed.
- There is no way to check CPU temperature
- Spinning down the drive may or may not be a good idea, depending on what you are using yoru B3 for. There has been several previous discussions on thsi, but bottom line is spinning down/up too often causes wear. Spinning down the disk would save ~4W compared to having it in idle state. There are additional concenrs as well, you would need to redirect logging etc etc.
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)
su_root
Posts: 38
Joined: 29 Nov 2011, 06:27

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by su_root »

johannes wrote:Interesting project! A few random comments:

- yes, almost all of B3 is open source, but in any case you are free to edit whatever you like
Good :)
- there is no way (in hardware) to control the power to the USB ports. You need support from the USB devices in order to shut them down or control speed.
Yes, I know that it isn't hardware supported but on the software side (OS) it should be possible. As an example the way I turned off my USB mouse works and in theory I could also turn off a USB-fan with the same command.
- There is no way to check CPU temperature
Yes, I figured that out when I was reading an other thread (CPU @ full speed = ~2W is really nice)
- Spinning down the drive may or may not be a good idea, depending on what you are using yoru B3 for. There has been several previous discussions on thsi, but bottom line is spinning down/up too often causes wear.

A 3.5" HDD spin down/up cycle is "designed to last" about 50K when a 2.5" HDD about 300K so yes, you're right that one needs to be careful when playing with this. Configured wrong (=spin down every 10 minutes) and the HDD is dead in a year (~250 days = 50K cycles @ 10 minute spin down/up).
Spinning down the disk would save ~4W compared to having it in idle state.

That doesn't sound like much but when the total consuption is @ 8W (according to the propaganda on the homepage), spinning it down would save you 50% :) Call me cheap all day but every penny is calculated over here and the energy prices aint going down in the near future. Also, it saves the environment which is a good thing obviously.

I'm going to use B3 as VPN gateway, file sharing, backup and I roughly estimate that it will be idle ~90% of the time.
There are additional concenrs as well, you would need to redirect logging etc etc.
This is actually the hard part, lots of smallish things that constantly wants to do something. As an example the stupid syslog with the -MARK- every 20min.

I guess the B3 can be RAM upgraded (?) so I was thinking of making a RAM disk and redirect /var/log (& /tmp ?) to the RAM disk (yes, copy *.RAM disk to /home/log every 6h). But I bet this is not enough and I can't say for sure what needs to be done exactly, this needs to be tested live on B3. I was also thinking about enable laptop_mode (/proc/sys/vm/laptop_mode) as the system should behave differently when running in this mode (=better cache handling I guess, need to investigate.)

Powertop should also be a very handy tool when figuring out what wakes the system. There are also other tools, btw how do I link to other sites here?

My other option is to schedule suspend for B3 over nights when there is no "need" for it to be powered on this needs to be supported under BIOS and I have no idea if it is at the moment (ie, suspend with a script and resume from BIOS?) I estimate that it could be in suspend mode about 50% of the time which saves the same amount of power as HDD spin down if HDD spin down = disabled when B3 is powered on.

The benefit from suspend:
- HDD spin down/up cycle should last a life time (about 70 years :) )
- Saves power
- Much easier, no need for RAM disks etc.

The draw downs:
- IF I needed to access B3 from work etc., it is not powered on (Wake On LAN for this, don't know yet does B3 support magic packages..?)

The whole thing may seem like waste of time but in a strange way I like to tweak things (perhaps I should get a life..)

EDIT: I came to think of another way; running OS from a USB memory as USB memory sticks are really cheap these days. Also if redirecting /var/log & /tmp to RAM disk it should save the USB memory. Benefits, OS and files on different storage and easy to clone the USB memory stick where OS is installed. The 3TB HDD could be idle ~90% of the time (=spin down and save that ~4W).

Shall we start a competition and see on how low W the B3 can be run average 24h? :)

EDIT2: A fast google showed that newer USB memories have "wear leveling". Also, there are USB memories with a write protection switch. Imagine running the OS from USB memory write protected (redirect logs and tmp to the RAM disk), this should mean that the OS is more safe from root kits and shite. To update the system, reboot B3 (or power off to clear RAM), put USB in write mode and run updates. After update is done, enable write protection on USB memory.
johannes
Posts: 1470
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by johannes »

- there is no way (in hardware) to control the power to the USB ports. You need support from the USB devices in order to shut them down or control speed.
Yes, I know that it isn't hardware supported but on the software side (OS) it should be possible. As an example the way I turned off my USB mouse works and in theory I could also turn off a USB-fan with the same command.
Well, to clarify, it is impossible in hardware to kill the 5V supply to the USB ports. Hence it would require a fan with a USB controller that can control the fan, which I have never seen. (The fans I have seen, along with cup warmers, aquariums and other usb crap are very simple, only using the USB power and not having any control logic at all).
I guess the B3 can be RAM upgraded (?)
Sorry, but no..
EDIT: I came to think of another way; running OS from a USB memory as USB memory sticks are really cheap these days.
This is a nice idea! Actually the USB installer is a full Linux booting from USB, with a bash install script running to do the installation. So telling the boot loader to boot from USB is just a button press away.


Interesting project! :)
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)
su_root
Posts: 38
Joined: 29 Nov 2011, 06:27

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by su_root »

Well, to clarify, it is impossible in hardware to kill the 5V supply to the USB ports. Hence it would require a fan with a USB controller that can control the fan, which I have never seen. (The fans I have seen, along with cup warmers, aquariums and other usb crap are very simple, only using the USB power and not having any control logic at all).
Hmm, well hmm.. I guess I have to believe you but I hope to prove you wrong :) I guess I have to put shoes on and go buy this for further testing:
clasohlson.fi/Product/Product.aspx?id=162693446
I guess the B3 can be RAM upgraded (?)
Sorry, but no..
Bummer, integrated on MoBo..
This is a nice idea! Actually the USB installer is a full Linux booting from USB, with a bash install script running to do the installation. So telling the boot loader to boot from USB is just a button press away.
Good, then this should be quite easy. And also another USB memory stick with the same configuration for "OS backup" when all the settings are done (or just push system backup to the cloud, Dropbox or similar).

edit: here some good reading about laptop mode:
samwel.tk/laptop_mode/faq

HOWTO: Using tmpfs for /tmp, /var/{log,run,lock...}
http://forums.debian.net/viewtopic.php?t=16450

Move your logs and temp files to RAM and watch your portable fly!
http://www.fewt.com/2010/07/move-your-l ... o-ram.html

Move /tmp, /var/tmp, /var/log and /var/log/apt into RAM (!! /var/tmp into RAM doesn't sound too good in my ears..?)
http://wiki.geteasypeasy.com/How_to:_Re ... lash_Drive

A transient /var/log
http://www.debian-administration.org/articles/661

RAMLOG
http://www.tremende.com/ramlog/index.htm


#####################################################################################
TODO: [thinking out loud so others can comment if the road I'll take is dangerous or if there is a better approach]
1) Ramlog seems like the obvious way to go
2) edit FSTAB, add

Code: Select all

tmpfs /tmp     tmpfs defaults,noatime,mode=1777 0 0
  • i) need to note that B3 only has 512mb RAM => need script to clear RAM if > x mb & files older than day > y
3) enable laptop mode
  • i) how does this handle HDD spin down,
    ii) are WD HDD's capable of doing this at their own?
4) Figure out howto monitor HDD spin down/up
  • i) with hdparm?
5) boot kernel with noatime?
6) use ext2 filesystem for OS and ext4 for data? (hmm, mixed feelings..)
7) hdparm -S240 /dev/hda [add as startup script, setting standby after 20minutes]

-----------------------------------------------------------------------------------

A) forget the above and run OS from USB memory stick
  • i) howto approach the HDD for safely maximizing power saving?
B) Need to test the theory of killing USB power by script
  • i) if it doesn't work, what is the best solution (X10, thermal controlled fan)?
    ii) turn off the system if HDD temperature exceeds x degrees [safety switch for protecting data]
C) Hardware modifications on B3
  • i) drill small holes into B3 chassi [under HDD] and at the sides
    ii) mount a fan under chassi => push air through B3 [note that the fan needs a dust filter]
#####################################################################################
su_root
Posts: 38
Joined: 29 Nov 2011, 06:27

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by su_root »

After some testing regarding HDD spin down/standby I'm beginning to think that it is not a very good idea, at least not to implement on B3 out-of-the-box.

It is one thing to get it working on a clean system but most of us install 3rd party programs and it is much work to monitor all possible changes. Johannes was onto this in another thread and I feel Excito was spot on about this.

I've decided that it is much better to get the OS running on a USB memory stick with wear leveling and use the HDD for storage only. When I get my B3 I'll do this and start with hdparm -S240 for the HDD.

Perhaps B4 will have somekind of internal flash storage for the OS and +1gb RAM (for /var/log & /tmp in ramdisk). And the more ram, the better (possible to run more stuff in ramdisk).
RandomUsername
Posts: 904
Joined: 09 Oct 2009, 18:49

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by RandomUsername »

F you were that concerned, why didn't you get your B3 with a SSD?
su_root
Posts: 38
Joined: 29 Nov 2011, 06:27

Re: B3 | USB-laptop cooler & autostart script / HDD temp

Post by su_root »

RandomUsername wrote:F you were that concerned, why didn't you get your B3 with a SSD?
I need my B3 for backup and media sharing. I need a big HDD, 3TB is the biggest I can get. I don't know if there is such big SSD disks but if there was, I could not afford it. The HDD spin down/sleep is interesting because it would save power (close or below SSD), it would not necessary get a longer life (most likely shorter).

Also, I could use an external 3.5" USB disk etc. but I want an all-in-all solution. I would have chosen Fit-PC2/3 or similar if the external storage was an option.

Btw, SSD is not a device that lasts a life time although there are no moving parts. SSD is faster and consumes less power than a traditional HDD but does it last longer than a high quality "normal" HDD?

That is why I wasn't so keen on running OS from USB memory because of the limitations of flash memory. USB memories are cheap these days (8gb for 10 EUR) and if I can run logs and tmp in ramdisk, I bet the USB memory will last for > 5 years quite easily.

Yes, I will try to run OS from the USB memory read-only and push ramdisk logs on reboot to the HDD (or just let them logs go with the wind..) but I have no idea how this will work in reality yet. It should work as long as there are no changes made but I guess there will come problems that I can not think of right now.

I could always let sql and B3 admin site run on HDD etc. but it is hard to say yet as I don't have the device to fool around with :)

There is no such device that is perfect out-of-the-box and besides, what would be fun with such a device, how would one learn new things if there is nothing to improve?

edit: this would be nice to see in a future version of B4/B5:
http://www.engadget.com/2011/12/01/sams ... -pure-ssd/
Post Reply