Raspberry Pi

RPi – Turn of external hard drive when not in use

If you have a Raspberry Pi connected to an external hard drive and you keep it on all the time then you may find that the external hard drive continues to stay spinning, even though you aren’t reading anything from it. I have two problems with that:
1) Waste of energy (negligible but still)
2) Noise

The noise part annoys me the most because I like a little peace and quiet around the home 🙂

Anyway, I’m using a Seagate Expansion External Hard drive (3Tb) and it never stopped spinning…I found a solution! Follow these steps:

1) Run this command

sudo nano /etc/hdparm.conf

This will open the hdparm.conf file for editing.

2) Look for the line “# -B apm setting” and observe the line that follows. My one looked like this:
# apm = x
where x = some value.

3) Remove the # from the start of the line, and change the 127 to 1.

4) Hit Ctrl+X and press Y to save the file.

5) Reboot your RPi

That’s it!

In Linux, the hdparam program is used to get/set hard drive parameter, see http://linux.die.net/man/8/hdparm. You can achieve the above by entering this:

sudo hdparm -B 1 /dev/sda2


/dev/sda2 is the hard drive’s device path

1 means highest power management (254 is lowest power management)

The bad part is that you have to run that command each time you reboot your RPi. However, by editing the /etc/hdparm.conf file, it is automatically applied at boot time and it becomes the default setting for all hard drives.



If you’re like me and:
1) want to keep using Linux commands on Windows
2) want to learn/remember more Linux commands
3) hate using DOS commands

then install Cygwin! So what is Cygwin?? Quoting from their website “a collection of tools which provide a Linux look and feel environment for Windows“.

Yep it feels good to use “ls” on Windows 🙂


RPi Streaming

I got the webcam streaming from the RPi! Woo hoo! Here’s what I did, I set up the following in /etc/avserver.conf:

Port 80
MaxClients 5
MaxBandwidth 50000
<Feed webcam.ffm>
file /tmp/webcam.ffm
FileMaxSize 5M
<Stream mystream>
Feed webcam.ffm
Format mjpeg
PreRoll 0
<Stream status.html>
Format status
ACL allow localhost
ACL allow

Then, I ran the command:

avserver & avconv -v verbose -s 320x240 -input_format mjpeg -f video4linux2 -i /dev/video0 http://localhost/webcam.ffm

And voila! Yes, the stream does lag quite a bit (about 3 seconds) but it’s a step in the right direction 🙂


Logitech C200 on RPi

I received my Logitech C200 yesterday and it was as small as I thought. I just plugged it in and installed the uvccapture software:

sudo apt-get install uvccapture

Then, I was able to take a snapshot with the following command:

uvccapture -S80 -B80 -C80 -G80 -x640 -y480

To take a video:

ffmpeg -f video4linux2 -input_format mjpeg -i /dev/video0 out.mpeg

NOTE: the names of the “ff” programs have changed

ffmpeg is now avconv.
ffserver is now avserver.
ffprobe is now avprobe.
ffplay is now avplay.