I recently purchased a Raspberry Pi mini computer, and had to think of something to do with it. I decided I would offload the torrent downloading and media serving responsibility from my home PC to this tiny wonder. Here’s how I did it:
1) setup your raspberry pi. Here’s an intro tutorial. Basically you need a PC of some sort, an SD card, and a way to copy files to that card from the computer (eg a USB adapter for the SD card). I used a mini SD card with a ‘macro’ SD card holder, and plugged that into my pc with a multi-type card reader like this one. You’ll want to use the default Raspbian Wheezy image for your card, download it here. The Raspberry setup guide presumes you use a Windows PC, if not you’ll need other instructions on how to setup the SD card.
2) boot your pi for the first time. This is a bit of pain, because by default the Pi needs a video display connected to its hdmi port, and keyboard to its usb ports. I’d rather be able to just boot it and the ssh to the Pi, but to set that up you have to boot the standard way first. I connected to my TV with a hdmi cable and an old USB keyboard I had lying around.
3) setup ssh. You’ll want to do the rest of the setup from the comfort of your laptop or desktop, so the first thing we’ll do is setup ssh on the Pi so we can connect to it instead of using the TV. Here’s one way to do it.
4) install transmission. This will be our bittorrent client. Instructions here. You will want to change the rpc-whitelist (I just turned rpc-whitelist-enabled to false). Watch-dir is the location that transmission will monitor for uploaded torrent files; any files it finds there will automagically begin torrenting. Don’t forget to change the password, as we’ll be exposing this via web. Try it out by going to http://<yourPiIpAddress>:9091/ (that should be the default port configured in /etc/transmission-daemon/settings.json, under ‘rpc-port’). You can change some settings from the web gui if you like.
5) setup an external drive. You’ll want to add a usb drive to store your torrents and media on, so connect that up. It should be accessible on /media/usb0. Make sure your transmission settings say to save to that drive or some folder under it.
6) install serviio for media serving. I run Serviio on my Pi, which provides a DNLA server that other devices, including many modern TVs, can connect to and stream content from. To install Serviio you first need Java, so get the java distribution for ARM from Oracle Java. I didn’t find this version for ARM in their main lists, so you have to hunt for it. Download that, copy it to you pi, unpack it and install it in /opt/jdk1.8.0. Update your PATH env variable to include /opt/jdk1.8.0 in ~/.bashrc.
Once Java is installed, confirm it by running ‘java -verison’. Then proceed to install serviio. Download Serviio from http://www.serviio.org/download , get the linux version. You’ll also want to install some of the prerequisites, such as ffmpeg, by running:
- apt-get update
- apt-get install ffmpeg
- download serviio, unpack it, and install wherever you like. Run the server by running ‘bin/serviio.sh’ from the serviio directory. Hopefully, it will start up. It may take some time to start, due to the Raspberry Pi’s relatively slow cpu.
- Once you confirmed serviio is running ok, you need to configure it. This difficult because we’re not running our Pi with a display, so we want to run the serviio console on our laptop (or desktop), and have it connect to the serviio server on the Pi. This can be done with some java vm arguments. Simply start the serviio console from the command line with:
on the Pi:
in the bin/serviio.sh file, add -Dserviio.remoteHost=<server_IP_address> to the end of the JAVA_OPTS line
on the client machine:
in the bin/serviio-console.sh file, add -Dserviio.remoteHost=<server_IP_address> to the end of the JAVA_OPTS line
Then start the server on the pi with serviio.sh, and the client on your machine with serviio-console.sh. You should see the GUI console pop up, and hopefully connect to your Serviio running on the Pi. From here, you can set the media directory (choose your Transmission download directory from step 4), and whatever else you want. Be sure to refresh the library to get Serviio to pick up all your files.
Disconnect your console, and Serviio should still be running. At this point, you should be able to turn on your TV or DLNA device and see the Serviio registered there. You can browse to your content and play it back on your TV!
At this point, you will probably want to ensure that Serviio and transmission are started every time Pi boots, and if the process dies for some reason (fairly common with Java) to restart it. You can do this with some scripts in /etc/init.d:
I have to admit this isn’t entirely stable, and I need to reboot my Pi occasionally. I think it’s pushing the little Pi to its memory and cpu limits, especially running Serviio which requires Java and a considerable amount of memory. Still, it’s a fun project in a small package.
Feel free to contact me if you have trouble or any questions.