Basically, you can build a DLNA server just using Raspberry Pi and external hard drive which contains your multimedia contents (movies, music, and pictures). Just plug the external hard drive to the Pi’s USB port, and you can just use Raspbmc OS or install other package which support DLNA server like minidlna.
My previous setup was using Raspberry Pi + Raspbian + minidlna + external USB hard drive, it’s working great. But there is some limitation when I use this setup:
- Raspberry Pi does not use gigabit ethernet, it uses 100Mbps ethernet. So theoritically, the maximum transfer speed is around 12.5 MB/s when you’re copying content from your PC to Raspberry Pi and vice versa.
- Raspbian use ext4 filesystem natively. So when you use other filesystem such as NTFS for your external hard drive, the read/write performance is degraded significantly. Based on my experience, when I use ext4 partition I can achieve transfer speed up to around 9 MB/s when copying large file from my Mac to Raspberry Pi. The speed drops to around 3 MB/s when I use NTFS filesystem.
- I use Mac and I need my external hard drive also accessible when I plug it directly into my Mac. So for this reason, if I use ext4 for my external hard drive, it will be inaccessible by my Mac (there are several third party software such as Paragon ExtFS which support read/write operation to ext4 filesystem. But just imagine somehow your external hard drive failed working. It will be a nightmare to rescue your data while your Mac does not support ext4 natively)
- I intend to use my external hard drive to store not only my multimedia collection, but other documents and data as well. So the data transfer operation between my Mac and Raspberry will be done quite frequently. Considering the Raspberry Pi’s maximum transfer rate is only around 9MB/s, it’s not suitable for day-to-day operation.
I decided to use my Time Capsule to store my documents and multimedia collections. I can plug my external hard drive to my Time Capsule’s USB port to give me additional storage. There’s some advantages when I use this setup:
- I take benefit from Time Capsule’s gigabit ethernet for faster transfer rate, and Raspberry Pi’s capability to provide DLNA server from Time Capsule internal and external storage. Transfer rate is much faster compared to Raspberry Pi. Based on my experience, I can transfer file to Time Capsule’s internal hard drive with speed up to 45 MB/s, where copying file to external hard drive (plugged into Time Capsule’s USB port) only get speed around 30 MB/s (I guess it’s because Time Capsule use USB 2.0 port).
- Time Capsule uses HFS+ filesystem, so the external hard drive need to be formatted into HFS+ filesystem to be recognized by Time Capsule. However, HFS+ is used and supported by Mac natively. Therefore, I can directly plug my external hard drive to my Mac without any dependency to Time Capsule (Consider if I use ext4 filesystem on my hard drive, I have dependency to my Raspberry Pi for transferring file, or to third party software such as Paragon ExtFS)
Setup & Installation
For my setup, I use Raspbian for my Raspberry Pi and minidlna as DLNA media server. I assume you are already familiar with Raspbian and how to install and configure packages.
~ step 1: hardware setup ~
- Ensure your Mac and Raspberry Pi are connected to your Time Capsule. Connect your external hard drive to Time Capsule via its USB port (if any).
- Ensure you have already known your Time Capsule and Raspberry Pi IP address. To determine Time Capsule’s IP address, you can use AirPort Utility tools (accessible via Applications->Utilities->Airport Utility). In this case, my Time Capsule IP address is: 192.168.130.1, while my Raspberry Pi is 192.168.130.8.
~ step 2: minidlna installation ~
- Make sure your package repositories are up to date by running following command:
- Install minidlna package using following command:
~ step 3: other package installation ~
To be able to read Time Capsule storage from Raspberry Pi, you need to install cifs-utils package using following command:
Basically, Time Capsule support both CIFS and AFP protocol. You can install afpfs-ng and afpfs-ng-utils package if you choose to connect to Time Capsule via AFP protocol. But based on my experience, this packages is still buggy and unstable on my Raspberry Pi. I recommend to use CIFS instead.
~ step 4: create mount point ~
- Create a directory as a mount point for your Time Capsule storage. In this example I create a new directory under /home/pi/media
- Time Capsule creates a mount point with the same name when you add new user. It also has /Data/ mount point which is shared to all Time Capsule user. In this example, my Time Capsule user name is amphie, and I store my Movie collection on /Data/Movies (yes, all Time Capsule users can access this directory).
To mount this folder to /home/pi/media, run following command:
To check whether it’s already mounted, run following command:
You will see the result like this:
- To make Time Capsule storage automatically mounted to your Raspberry Pi, edit /etc/fstab file using following command:
and add following lines:
save and exit vi.
When you connect external USB hard drive to Time Capsule, it will create a new mount point with the same name as its partition label. So for example, if you have two partition with label: Documents and Music, Time Capsule will create two mount points: /Documents/ and /Music/ which are accessible by all Time Capsule users (besides their own private folder and /Data/ mount point).
Each mount point is linked to /Shared/ folder on each partition. So don’t get surprised if you open any mount point and found nothing there. Any folders and files outside /Shared/ folder on your partition will not be accessible via Time Capsule. It’s only accessible when you plug it directly via your Mac.
You can mount other Time Capsule mount points to your Raspberry Pi using the steps above as well.
~ step 5: minidlna configuration ~
- Open minidlna configuration file which is located on /etc/minidlna.conf:
and add/update following lines to add /home/pi/media directory to minidlna library:
- Open sysctl.conf for editing using following command:
and add following lines at the bottom of the file:
- Rebuild minidlna database and restart the minidlna application:
That's it. Now you should be able to stream your multimedia content via your favourite DLNA client.