Introduction: Creating a ReadyMedia (formerly MiniDLNA) Media Server With a Raspberry Pi

Picture of Creating a ReadyMedia (formerly MiniDLNA) Media Server With a Raspberry Pi

The Raspberry Pi is an amazing minicomputer, capable of doing all sorts of things and costing as much as a really nice restaurant meal! I learned that one could be used as a DLNA media server and found some instructions elsewhere and also here on Instructables. Unfortunately, none was as thorough as I needed and I spent a lot of hours trolling around the 'net, looking for answers to issues that weren't addressed in any other online instructions.

This Instructable - my first - is the result of all of that work.

Step 1: What You Will Need

Picture of What You Will Need

First off, many thanks to The Server Guy, who created the original Instructable on this subject. Unfortunately, there were a few frustrating "holes" in his description that I had to fill myself through lots of research and trial and error. So, I thought I'd make my first Instructable as an update to his. In doing so, I have blatantly stolen all of his images, for which I give him full credit!

I have a little home network that connects computers - both desktop and mobile - that my wife and I regularly use, as well as an LG blu-ray DVD player that is "smart" and can function with a DNLA media server, located elsewhere on the network. Such a thing should allow me to store movies and other video, music, and pictures in a place where they're accessible to the DVD player and the large TV screen and stereo speakers that are attached to it. Unfortunately, finding the optimal media server has been a long quest for me. Along the way I have attempted to host in on a Windows PC on my network and an NAS device (a D-Link DNS-320L). Neither has worked very well, with the latter device often crashing and sometimes taking dozens of minutes just to load a few music files! Fortunately, my experience with using the Raspberry PI and MiniDLNA software has been almost perfect, with only the occasional hiccup - which I suspect is probably more the fault of the LG smart DVD player.

As with The Server Guy's Instructable, I am not going to show you how to set up your Rasperry Pi and its operating system - just how to turn an already-functioning Pi into a lovely little local media server for your home network. I assume that you know how to get to the command prompt of the Raspian OS on your Pi, via the Terminal program that comes as part of the OS.

What you'll need is pictured here (thanks again, The Server Guy!). Know that your USB hard drive can be of any size (the bigger its capacity, the more stuff you're going to be able to store on it) and that you don't necessarily need a USB Wi-Fi dongle. Your Pi could be reliably interfaced to your network via Ethernet because the Pi has a built-in port for this purpose.

Most modern USB hard drives are powered through the USB port, hence the requirement for a powered USB hub. I used an older USB hard drive that has its own AC power supply and this negated the need for the powered hub! Even though they're a bit slower than more recent drives, mine will easily stream an HD movie.

Step 2: Updating and Installing

When executing the next few steps you can do them one of two ways: via a direct connection to your Pi, or via a network connection, with control coming from a Windows, or other, computer. I used the f direct connection method, which requires a USB hub, HDMI monitor and cable, USB mouse and keyboard. Of course, once I finished doing all of this configuring I no longer needed most of these peripherals and my media server is now running well with one USB port occupied by a Wi-Fi dongle and the other one connected to the USB hard drive. That is, no USB hub required.

If you want to access your Pi via a network connection you'll need to use a remote access program like PuTTY. (You'll have to figure out how to install and use PuTTY yourself.)

It makes good sense to ensure that you've got the latest OS for your Pi, so execute the following at the system prompt:

sudo apt-get update

sudo apt-get upgrade

Your Pi will go out and obtain and upgrade itself to the latest OS version.

Once you've done that, run this command:

sudo apt-get install minidlna

This will find and install the MiniDLNA (ReadyMedia) software onto your Pi.

Step 3: Connect the Hard Drive

Picture of Connect the Hard Drive

We need to ensure that our USB hard drive is mounted automatically upon startup, so first run this command:

sudo fdisk -l

Note that the last character in the command above is a lower-case letter L (not the number one!).

The resulting screen of information will indicate which drives are currently attached to your Pi. Of course, in addition to the USB hard drive, you've also got the SD card that holds the OS and some other stuff, so info regarding at least two drives is going to be shown. What you need to discover and note is the name given to your USB hard drive - "sda1" being the most typical. You'll also need to know and record what file system format your USB hard drive has.

Step 4: Mounting the Drive on Startup

Picture of Mounting the Drive on Startup

Obviously, the hard drive is going to need to be mounted whenever the Pi is rebooted in order that we can access its contents. To do this, you're first going to have to execute this command:

sudo mkdir /media/HDD

This creates a subdirectory (folder) named "HDD" in the media directory of the hard drive. To give it read/write permissions, execute this command:

sudo chmod 777 /media/HDD

Next, we need to edit the fstab file, which is what the OS refers to when your Pi boots up. This line we'll be adding to this configuration file essentially mounts our media drive on startup. Execute this command:

sudo nano /etc/fstab

This will run a little text editor that's built into your Pi and will load the fstab file into it. Use your arrow keys to navigate through the file to the bottom, where you're going to add a line.

It's here that The Server Guy let me down in his Instructable. His USB hard drive had the file system type indicated as "FAT32" which required the parameter "VFAT" to be placed on this last line of the fstab config file. My USB hard drive reported its file system type as "HPFS/NTFS/exFAT" and using the parameter VFAT on this line did very bad things to my Pi! (It went into Emergency Mode.)

After a lot of research and trial and error I discovered a page on the web (that I apologize for not noting) that led me to discover that the parameter "ntfs-3g" was the one required for my USB drive's file system type.

The other thing I didn't understand about this command line is whether there were tab characters embedded in it; there aren't. Just spaces.

To summarize (finally!) if your USB hard drive's file system type is FAT32 and its name is sda1, then place this line at the end of the fstab file:

/dev/sda1 /media/HDD vfat defaults 0 2

If it's of the HPFS/NTFS/exFAT type and its name is sda1, then put this line at the end of the fstab file:

/dev/sda1 /media/HDD ntfs-3g defaults 0 2

I'd suggest that you simply "cut and paste" these lines into the text editor so that the appropriate number of spaces between the parameters are entered properly.

To save the file in the editor press Ctrl-X and then approve the saving of the file and buffer, as necessary.

After you've saved the updated stab file, reboot the Pi:

sudo reboot

and then navigate into the directory /media/HDD:

cd /media/HDD

and run the command:

ls

(That's a lower-case L followed by a little S.)

You should be able to see a list of subdirectories off of the /media/HDD directory - if there are any.

Step 5: Configuring the MiniDLNA/ReadyMedia Server

Picture of Configuring the MiniDLNA/ReadyMedia Server

You will now have to edit the configuration file associated with your media server. Once again you're going to do this via the text editor that's part of your Pi's installation. Execute the following command:

sudo nano /etc/minidlna.conf

which should load the minidlna.conf file into the editor.

Search through the file and look for the part where you see this:

# * "A" for audio (eg. media_dir=A,/var/lib/minidlna/music)
# * "P" for pictures (eg. media_dir=P,/var/lib/minidlna/pictures)
# * "V" for video (eg. media_dir=V,/var/lib/minidlna/videos)

Edit that part so that it ends up like this:

media_dir=A,/media/HDD/Music
media_dir=P,/media/HDD/Pictures
media_dir=V,/media/HDD/Movies

Then look for this part:

# Name that the DLNA server presents to clients.
#friendly_name=

and change it to:

# Name that the DLNA server presents to clients.
friendly_name=RASPI MINIDLNA

Know that you can use whatever name you want here. I'm not sure if there's a requirement for the name being in upper-case letters, nor if any punctuation (other than the space character) is allowed. I'd err on the side of caution here!

Once again, press Ctrl-X to close the editor and choose to save the file (and buffers) when prompted.

Now that we've rewritten the configuration file for the media server, we have to refresh it. To do this you can run the following commands:

sudo service minidlna

restart sudo service minidlna force-reload

At this point, your Pi has rebooted, mounted the attached USB hard drive, and run the media server software. Because it's part of your home network - either through an Ethernet or Wi-Fi connection - it should now show up in the Network area when you're in Windows' File Manager. It'll be called RASPI MINIDLNA (or whatever you name it) and may be in the media devices section.

Step 6: Ongoing Maintenance and Editing of the Media Server

Picture of Ongoing Maintenance and Editing of the Media Server

This part wasn't made clear to me in any of the documentation regarding the MiniDLNA/ReadyMedia server literature, nor the other Instructable. That is, how does one get new pictures, videos, and music onto the USB hard drive that's connected to your Pi? You sure wouldn't want to have to detach the USB hard drive from the Pi and reattach it to a PC every time you wanted to add some media! But initially I was thinking this was the way it was gonna be...

I thought that access to my media server was going to be extremely limited because, once I'd done all of the configuring indicated in this Instructable, I could see the media server in the Network category of File Manager on my Windows 10 computer. However, when I double-clicked the icon, I'd be immediately taken to my browser and presented with the screen shown at the top of this page. This is interesting information, but I obviously wasn't going to be able to add a new movie to the media server this way!

Fortunately, sometime later (I suspect it was after the media server had found and catalogued all of the media files on the USB hard drive) a nice new icon magically appeared in the "This PC" section of File Manager, indicating the presence of the media server in Network locations. (See screenshot above.) When I double-click on this icon, I can now navigate through the directory structure of the media server from my Windows PC, doing whatever editing is required to the files contained on that server.

Comments

Hazozuki (author)2016-05-04

Hello, your tutorial works fantastically however two changes that are needed in order for it to work properly are as follows:

When you talk about using ntfs-3g for an NTFS file system is correct, however you first need to install the ntfs-3g package by using the command 'sudo apt-get install ntfs-3g' for it to properly work. And secondly you said made a typing error when putting in these commands for people to use

sudo service minidlna
restart sudo service minidlna force-reload

It's a simple fix and to you and I we may understand that it is just an error, but to people new to Linux they may not know what's going on. (Being that the commands are 'sudo service minidlna restart' and 'sudo service minidlna force-reload')

But other than those two details, great first instructable!

DIY Hacks and How Tos (author)2015-12-24

Great first Instructable. Thanks for sharing.

About This Instructable

8,175views

48favorites

License:

More by ibowden:Creating a ReadyMedia (formerly MiniDLNA) Media Server With a Raspberry Pi
Add instructable to: