Friday, 5 September 2014

The 'Step up' NAS and Media Vault using a Raspberry Pi

I wanted to build my own NAS so that my music, pictures and movies could be backed up to a machine that could be tucked away somewhere in the house away from the main PC in the lounge. I figured that if someone broke in and nicked the main PC at least all my data would be safe. I also wanted it to stream music to the hifi (via DLAN) because I didn't want to have to turn my PC on in every time I want to play music.

So I built a NAS out of an old PC I was given plus two 3Tb drives and 'Open Media Vault' (OMV) to organise it all. This also supports miniDLNA for the music streaming part. All worked fine.

Except for the noise.

You see - the place I chose to put this beast was just outside my bedroom door on the landing - and this PC has three fans running when it is on. It's actually a very quiet PC but I could still hear it whirring away all night long and that bothered me. Too much electricity wasted just running this thing 24/7.

What I needed was a quiet, low-cost, cheap to run PC for the media streaming and then turn the OMV monster on only when I needed to back up something.

That's when I had the idea for a 'Step-Up' NAS.

The plan was to have a Raspberry Pi running 24/7 with a 64Gb memory stick holding all my music (I have about 20Gb of mp3's in all) which would be running miniDLNA. The Pi costs around £30 and the 64Gb stick can now be had for just £15. No moving parts, no fans, no noise, very low power consumption. Perfect.

The Pi would also be running an Apache Web Server and host a web page with an 'On/Off' button on it. When pressed this button would instruct the Pi to raise one of the GPIO pins for 0.5 seconds. This pin is connected to a transistor which will short out the on/off button on the front of the monster OMV PC thus turning it on or off.

The Raspberry Pi is actually mounted inside the other PC with wires running to the on/off switch. In addition the Pi is powered from the stand-by power provided by the main PC PSU so that I only have one mains plug.

Here is a picture of the Pi sitting inside the main PC:

And this is where the Pi gets its' power - the purple wire from the PSU carries a nice steady 5v even when the main PC is off. I wired this through to the 5v line on the GPIO port on the Pi:

So at the back of the PC there is only one power cable for both computers but two network cables - one for the Pi and one for the main NAS:

The green one is for the OMV NAS, the white one disappearing through the backplane is plugged into the Pi. I should come up with a better socket/plug thing for this... but hey, it works.

The web page couldn't be simpler! :

There's a 'ping' script running in the php for the page so that I can make the button turn green when the OMV is up and running:

The OMV PC also runs 'OwnCloud' so that files can be served up to any device that connects to the PC over the network using a browser. By setting the port forwarding rules on my router I can now remotely access the on/off page on the Pi, switch on the OMV machine and then (after waiting 30 seconds for it to boot) log on to the OwnCloud service on the main PC and download anything from my main NAS. When I've got the album/picture/movie I wanted I then go back to the Pi's on/off page and switch the OMV NAS off again.

So if I want to listen to some music that I have at home I can now download anything from my library by firing up my own cloud server remotely.

And I can sleep at night because the Pi runs completely silently....