loading

Raspberry Pi Torrent, Samba and DLNA with 3+ hard drives

Picture of Raspberry Pi Torrent, Samba and DLNA with 3+ hard drives
There are many Raspberry Pi guides out there that helps you to transform your Pi into a server supporting downloading torrents and sharing files via Samba and DLNA. However, they all have a major flaw: supporting only ONE hard drive. In this instructables, I will help you to setup Transmission, Samba and miniDLNA on your Raspberry Pi to support as many hard drives as you like (as long as there is enough power)

List of required components:
1. Raspberry Pi Model B for internet access
2. Powered USB hub
----- http://www.ebay.com.au/itm/Brand-new-USB-2-0-HUB-Powered-7-Port-High-speed-AC-Adapter-Cable-/251280391263?pt=AU_Laptop_Accessories&hash=item3a817a7c5f&_uhb=1
3. Power supply with 3-4A
----- http://www.ebay.com.au/itm/5V-AC-Power-Supply-Charger-Adapter-for-D-Link-DUBH7-DUB-H7-Hub-5V-3A-5-5-2-5-/181291153550?pt=AU_Laptop_Accessories&hash=item2a35cb788e&_uhb=1
4. (Optional) USB Wi-Fi dongle. Guides on setting up the Wi-Fi dongle are plentiful. You can do it with command line via SSH or from the GUI.
 
Remove these adsRemove these ads by Signing Up

Step 1: Hooking up the Raspberry Pi

Picture of Hooking up the Raspberry Pi
IMG_1024.JPG
USB Hub.jpg
5vau-2B.jpg
On the software side, I'm using the default Raspbian image, then install the bits and pieces I need later on. There are plenty of guides on installing the image and setting up the Pi.

Hardware wise,
Step 1.
Discard the power adapter that comes with the powered USB Hub if it supplies less than 3A. You need 700mA for the Pi and 500mA for each hard drive you connected.

Step 2.
Connect the USB Wi-Fi dongle to the Raspberry Pi.

Step 3.
Connect the USB output cable from the hub to the Pi. This should also power the Pi, so no need for a mini USB cable.

Step 4.
Connect the hard drives to the hub,

Step 5.
Power on the Pi. Powering Pi before plugging in USB components may restart Raspberry Pi.

Step 2: Setting up hard drives

Step 0.
Plug in your USB Hard Drives. If you are using NTFS, install ntfs-3g.
sudo apt-get install ntfs-3g
Step 1.
Execute
ls -l /dev/disk/by-uuid
Write down drives UUID and drive paths (sda*, sdb*, sdc*...).

Step 2.

Execute
ls -l /dev/disk/by-name
Write down name and drive paths.

Step 3.
Match drive paths, names and UUID

Step 4.
Create locations for mount points for each hard drive. Replace DRIVE_NAME_* with names you like, I chose to use the same name as my disks' name as obtained from Step 2.
sudo mkdir /media/DRIVE_NAME_*

Step 5.
Mount the USB drives
sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/sdxx /media/DRIVE_NAME*
Note:
ntfs-3g for NTFS drives
vfat for FAT32 drives
ext4 for ext4 drives
Replace sdxx and DRIVE_NAME_* from the list you have compiled in step 3 and 4.

Step 6.
Now we will configure the Raspberry Pi to mount these drives after every reboot.
Make a backup for your current fstab
sudo cp /etc/fstab /etc/backup_fstab

Add mount information to the fstab file
UUID=xxxxxxxxxxxxxx /media/DRIVE_NAME_* ntfs-3g rw,defaults 0 0
Replace with the correct UUID, mount point and drive type

Step 7.
Turn off GUI mode by using sudo raspi-config
Restart Raspberry Pi with sudo reboot

At this point, your USB drives should be mounted properly.

Step 3: Installing Transmission / rTorrent (updated 18.03.2014)

Picture of Installing Transmission / rTorrent (updated 18.03.2014)
Because this is a headless server, we are accessing the command lines through SSH. Fortunately, SSH is enabled out of the box for Raspbian.

Step 0.
Let's update and upgrade the repositories and distribution by using:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Step 1. You can either install Transmission or rTorrent or both. Skip to Step 2.2 for rTorrent installation.
Install Transmission
sudo apt-get install transmission-daemon
In order to download torrents, we need to access Transmission's WebUI. This can be done by running Transmission daemon (started after installation) and accessing the Pi's internal IP address and Transmission's designated port.

Step 2.1. Transmission setup
Next, we need to setup who can access Transmission by setting up username, password and allowed IP addresses:
1. Stop Transmission service with
sudo service transmission-daemon stop
2. Start modifying the settings:
sudo nano /etc/transmission-daemon/settings.json
3. Find rpc-username and rpc-password, change the values to your liking.
4. Find rpc-whitelist and add the IP addresses of your other computers. You can use wildcard to include a range of IP addresses, for example, in my case, 10.1.1.* is added.
5. Setup the WebUI:
Transmission's default WebUI only allows you to download to 1 folder. In this instructable, you will find out how to load and use a custom WebUI
  1. Download the latest version of Transmission Web Control: https://transmission-control.googlecode.com/svn/r...
  2. Extract the downloaded archive. Navigate to /usr/share/transmission.
  3. Rename the existing web folder to backup_web.
  4. Copy the extracted web folder from archive into /usr/share/transmission.
  5. Set Transmission's web interface path:
export TRANSMISSION_WEB_HOME=/usr/share/transmission/web
6. Save and reload transmission service
sudo service transmission-daemon reload
Remember to use reload, as restart will revert your changes.
7. On other machines, navigate to http://server_ip_address:rpc_port/rpc_url
For example, in my case, it is 10.1.1.12:9091/transmission/web

Step 2.2. rTorrent setup
I recently discovered rTorrent and boy oh boy, it's much simpler than Transmission to download to multiple folders. ruTorrent, a rTorrent web GUI, even supports downloading to multiple folders out of the box! 

Thanks to Koper89 from xbian forum, the installation is as simple as running a script! http://forum.xbian.org/thread-2037.html

Change the parameters in the script as needed. 

Step 4: Installing Samba and miniDLNA

Picture of Installing Samba and miniDLNA
dlna.jpg
Now the important bits - mounting and setting up torrent downloading for 3 hard drives - are done. In this section, we will install Samba and miniDLNA. There are many quality guides on the internet showing you how to install Samba and miniDLNA and I recommend you to source and read them. However, for completion, steps I took to install these two services are written below.

Step 1.
Install Samba
sudo apt-get install samba samba-common-bin

Step 2.
Backup and modify Samba's configuration file
sudo cp /etc/samba/smb.conf /etc/samba/backup_smb.conf
sudo nano /etc/samba/smb.conf
  1. Find workgroup, and modify its value. This is the workgroup your Windows machine need to be a part of to view the files
  2. Remove irrelevant drives, printers if you don't need them
  3. Add your own drive:
[DRIVE_NAME_*]
comment = Some comment about this drive
path = /media/DRIVE_NAME_*
create mask = 0777
directory mask = 0777
read only = yes
read only option depends on whether you want your users to change files or not. In my case, I chose yes.

Step 3.
Restart Samba
sudo service samba restart

If you run into problems with Samba, consult online manuals and Raspberry Pi's forum as they know a lot more about setting up Samba than I do.

Step 4.
Install miniDLNA
sudo apt-get install minidlna

Step 5.
Backup and configure miniDLNA
sudo cp /etc/minidlna.conf /etc/backup_minidlna.conf
sudo nano /etc/minidlna.conf

In the configuration file, add
db_dir=/home/pi/.minidlna
so the database is saved across reboots

Change miniDLNA's media directory to point to mount points
media_dir=V,/media/<em>DRIVE_NAME_*
First parameter of media_dir is the types of files for miniDLNA to detect.
A for Audio
P for Photos
V for Videos
Add as many media directories as you need. Change names of drives as needed.

Step 5: Conclusion

Now, your Pi should be able to download torrents and access files via Samba and miniDLNA to and from 3 hard drives. The hardest part of this guide is setting up the webUI for Transmission. After that, everything should be smooth sailing.

Have fun and enjoy your server!
firecool12 months ago

Anybody can help with MiniDlna and .srt subtitles? It seems to me that it doesn't work. I have placed the .srt, named exactly the same as my .mp4 (or .mkv). - also case sensitive.

I have tried a lot of DLNA servers with no luck :(

My smart tv is capable of rendering .srt files, this works fine with I try with my PS3 Media Server on my windows desktop.

Thanks,

G.

ileocorp3 months ago

Thanks! I would try rTorrent the next time :D

zkubalyak1 year ago
What about the network speed? I managed to reach only 4MB/s with ext4 and 1MB/s with NTFS, while it is more than 50MB/s on my PC.
McAldo zkubalyak4 months ago

Old post, but just in case somebody runs into the same problem, consider that the raspberry Pi has a slow 100Mb/s and only USB 2.0.

Not sure what was your setup with the PC, but 50MB/s is 400Mb/s, so I am guessing you are testing over gigabit lan.

That kind of speed is unachievable with a raspberry Pi, including the very latest model. It makes for a pretty good server, media center and a number of other things, but if one wants high network speed a dedicated NAS or a router like the the Netgear r7000, which has usb3.0 and samba/dlna out of the box, are both a better solution.

And, admittedly, even if many reviewers say the netgear can do 57MB/s or so over lan, with mine and a usb 3.0 HD I never really managed more than 27MB/s.

rampadc (author)  zkubalyak1 year ago

I haven't got around to do a network speed test and I'm abroad right now, so can't do one. Before I left, I tested the network with 4 devices (2 Android's, an iPad and a Bravia TV) connecting to the DLNA server playing an AVI file, each was streaming at around 150KB/s-250KB/s, so that's a total of 600KB/s-1MB/s coming out of the Raspberry Pi reading 1 file on a NTFS hard drive.

Just for clarification, is your question referring to the NTFS read speed, DLNA speed or Samba speed?

EnricoG25 months ago

hi,

sometimes the minidlna service is working but my tv doesn't see it. So i have to stop it and restart it.... why?

ZoltanK8 months ago

Day 3 with my Raspi B+ and am still trying to wrap my head around a new programming language, (outside of Basic back when I was a teen in the 90's), and I have found this Instructable to be very informative but have come across some troubles when trying to identify my external (non powered 1Tb WD HDD) I fear that even the B+ does not have the "oompff" to get the drive up to speed. My concern being; is it me, or is it my Pi? I have been trying to figure out a way to stream my media to friends and thus far I have been unsuccessful and thought the Pi was the way to go as well as learn a few things along the way.

rampadc (author)  ZoltanK8 months ago
There's a setting somewhere in the Pi that lets you increase the total current supplied to its USB ports. Check the Pi forum. I haven't got the newer model so I can't help you here.
1Emerson11 year ago

How fast do your torrents download? I am using Openelec and my download speed jumps from 50kb/s to 700kb/s. My internet speed is 120Mb/s down and 20Mb/s up, is there some settings I can change around to increase my download speed. Thanks and cool Pi you got there :D

diy_bloke1 year ago

to get info on the harddrives can I suggest th eblkid tool?
sudo blkid
and it shows it very structured

diy_bloke1 year ago

OK, I think I succeeded. Allow me to share my experience here as it might help others:
Turns out it wasnt a 1TB hdd but a 2TB hdd, a seagate and a WD
As previously the raspberry didnt even recognize the WD, I decided to try that one again:
At first I did an upgrade with "sudo apt-get dist-upgrade" as you suggested. My OS is a raspian distro from Ghoulman. Update took about an hour so i guess a lot neded to be done :-)
Then I connected the 2TB WD hdd. I made sure that it was already powered up before I connected the USB. it went direct into the USB port so without a powered hub.
With webmin I could see that it was connected now and it was actually already mounted, but 'not in use' and it was labelled as an 'MSDOS' disk so I guessed it was vfat (wrong).
after fruitless attempts to get it properly mounted, resulting in bad fs, bad option bad superblock, I came across the

"parted -l" command.
Output was:
Model: WD Ext HDD 1021 (scsi) Disk /dev/sda: 2000GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 1049kB 2000GB 2000GB primary ntfs

and yes, there it was ntfs!! so indeed I had been using the wrong type.
a quick:
"sudo mount -t ntfs-3g /dev/sda1 /media/WD2TB" got it properly mounted
end a quick edit of the samba file made it accessible.
Now I only have to re-edit the fstab file to change "vfat" into "ntfs-3g"
and I am sure that boot will be ok then.
I presume my other disk wont give any problems either.

I am not sure where the earlier problems were, old distribution (I put it on there 3 mo ago)? did I perhaps connect the USB before it was properly powered? I dont know, but at least it works now

Thanks for yr suggestions, the upgrade was possibly the smartest i could do

diy_bloke1 year ago

come to think of it... my harddrives have a psu of their own, so they shldnt draw that much from the USB

diy_bloke1 year ago

Nice. any advice on the harddisks? till now I haven't been able to get some 1TB harddisks working on the raspberry.
Supposedly a bug in raspbian, but i see plenty of people adding one

rampadc (author)  diy_bloke1 year ago

One of my hard disks is a WD 1TB so it shouldn't be a bug. Upgrade your Pi's distro with "sudo apt-get dist-upgrade", it may solve the problem. My experience with hard drives not working with Pi is that there isn't enough power. So even if you are plugging only 1 hard drive, plug through a powered USB hub.

Thanks, I have a seagate 1TB.
There is a description of a bug for 1Tb disks, but I can use it in my ubuntu 13. but not in my raspbian.
So,, reading abt that big with 'fast, huge disks' I thought that must be the problem.
But.... I had not thought of your suggestion yet, that it could be powerfailure. I will try the powered hub suggestion
Will order one and report back. Thanks for yr help
joey561 year ago
Cool!!!!!! Pls follow me!!!!!!