Raspberry Pi Media Server - MiniDLNA

356,352

212

67

Posted

Introduction: Raspberry Pi Media Server - MiniDLNA

Hey. In this instructable I will be showing you how to make a raspberry pi media server using MiniDLNA. This will allow you to stream your photos, videos and music around your network. This is my first instructable so sorry if it isn't very good.

In this instructable I will not be showing you how to setup a Raspberry Pi and install the OS I will just be showing you how to setup the media server. But if anyone wants a tutorial on how to setup a Raspberry Pi I will try and make one.

Step 1: What You Will Need

For this instructable you will need:

  • Raspberry pi (I'm using a model B)
  • Another computer if you want to SSH into your pi
  • Hard drive with your media
  • SD card for the raspberry pi operating system
  • Raspberry pi wifi dongle (you can also use Ethernet)\
  • A power supply for the raspberry pi (a minimum of 1 AMP and 5 Volts for the Raspberry Pi model B)
  • A powered USB hub

Step 2: Updating and Installing

To begin we can SSH into our raspberry pi by using a program like putty. After we have done this I recommend updating and upgrading your raspberry pi. You can do this by using the following commands.

sudo apt-get update

sudo apt-get upgrade

Once this is finished we can install the media server software. Use the next command to do this.

sudo apt-get install minidlna

After you enter this command you will probably be asking if you want to continue. Just press y and then enter. Once that has finished installing it is time for the next step.



Step 3: Connecting the Hard Drive

Before we can start our media server we need some media of course. So what we are going to do is make it so that our media hard drive is mounted on start-up.

To do this the first thing we need to do is plug in our media drive. Make sure you plug it into the powered USB hub and not directly into the raspberry pi because sometimes that can cause problems. Once you have done this we need to go back to putty or whatever SSH client you are using and type in:

sudo fdisk -l

What this does is it shows use important information about the drives that are connected to our raspberry pi. In the picture I have circled the name of my drive in white. In my case it was /dev/sda1. I know this because where I have circled in green says that the drive /dev/sda has 1000 GB which is the size of my drive. In red I have circled the format of the drive which we will need in the next step. You are going to need to know the name of your drive and the format of your drive in the following steps so it is probably a good idea to write them down somewhere.

Step 4: Mounting the Drive on Startup

We need to have our media drive to be mounted on startup so that we can access its contents. To do this we are going to need to make a folder to mount it to. You can do that by using this command:

sudo mkdir /media/HDD

What this command does is makes a folder called HDD in the media directory. So once we have made this folder we need to give it read write permissions. We can do this by using this command:

sudo chmod 777 /media/HDD

This command command tells the folder HDD that it has all permission. This means that it has read and write permissions which is what we wanted.

Now we need to edit the fstab file. This is the file that the raspberry pi operating system refers to when it is looking to see which dives to mount at startup so we need to put our media drive in that file. We can do that by using the command:

sudo nano /etc/fstab

Once in this file you will notice that it is not the same as Microsoft Word which you might be familiar to. You need to use the arrow keys to navigate around. So go to the bottom of this file and you are going to add this line:

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

Ok so the line that you just added might be a bit confusing so I will try to explain it. The first part where is says /dev/sda1 is the is the name of the hard drive that you want to add. Remember from the previous step. The next part is the place where you are going to mount it to. Then we have the format of the hard drive. In this case it is fat32. And finally the 0 and 2 at the end are permissions.

Now it you reboot the raspberry pi:

sudo reboot

and move into the directory /media/HDD

cd /media/HDD

And run this command:

ls

You should be able to see all the files on your hard drive.

Step 5: Configuring MiniDLNA

To start configuring MiniDLNA we need to edit the config file. This can be done by using this command:

sudo nano /etc/minidlna.conf

Once you have that file open we are going to need to change that part that looks like 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)

to this:

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

and this:

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

to this:

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

In the line above where I have put RASPI MINIDLNA can be whatever you want.

Then press control x to exit and press y if it asks if you want to "save modified buffers" then press enter to confirm.

Now that we have configured MiniDLNA we have to refresh it. To do this you can run the following commands:

sudo service minidlna restart
sudo service minidlna force-reload

Now if you hop back onto a windows computer or any Upnp compatible device you should be able to see your server. On window if you click on start then computer then on the left hand side click on network you should be able to see your raspberry pi Minidlna server called RASPI MINIDLNA under the media devices section.

Step 6: Your Done!

Congratulations you have successfully created a raspberry pi MiniDLNA server. I hope this instructable was helpful and that you learnt something along the way. If you thought this instructable was good please vote for me in the micro-controller or the tech contest it would be greatly appreciated. Thanks for reading this. I hope you learnt something.

P.S I do not own the first picture in this instructable and give all the credit to the owner. I am also not responsible if anything goes wrong in this instructable you are doing it at your own risk. Even though I have tested it about 4 times and it worked for me.

Share

  • great tut thank you-AshleeJ

    AshleeJ made it!

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • First Time Author Contest 2018

    First Time Author Contest 2018
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

65 Comments

my UPNP LG smart tv recognises the miniDLNA server running but folders Video, Pictures and Music folder are all empty. I don't know what has gone wrong, it used to work.

similar problem occurred with Plex as well. when I uninstalled it and installed minidlna, and now I am again stuck with similar problem .

I also had the same issue. Turns out that you need the user who runs the minidlna service must own the files in the folders.

This is good BUT, when i edit /etc/fstab with this

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

*i called my folder NASDrive*

save it then reboot the pi, it seems to corrupt's the sd card so i have to re build the pi, just a warning if some one tries this this is a possible issue

I also encountered the same issue. But you don't need to rebuild the Pi to resolve it, just edit the /etc/fstab and comment out the added line. Hope this helps others.

/dev/sda1 /media/NASDrive vfat defaults 0 2*

Thanks a million for this. Just what we needed!

Users may find "chmod 777 /media/HDD" mysterious. You could also say "sudo chmod a+rwx /media/HDD" to add (+) read, write, and execute permissions(rwx) for all(a) users. Try the command "man 1 chmod" on your Raspbian terminal for the traditional explanation. And thank the good folks at Free Software Foundation for giving us a manual entry for their chmod command.

You might also try the command "man 5 fstab" to find out what all that stuff in /etc/fstab is about. The number at the end of the line has to do with whether you want the file system inspector to look at that volume after a reboot. Say "0" if you want your media volume left alone. Say "2" if you want it inspected and repairs attempted. The other number is an instruction to the dump command. Say "0" so it leaves the volume alone too.

What do the permissions 0 and 2 mean? I went into /etc/fstab and the mounts were already there with permissions 0 and 0 on some and 0 and 1 on some. What is the difference between 0 1 2?

Please see my reply later in the thread. 0777 is a base eight representation of the binary number 000111111111. Unix files have permissions read, write, and execute. Each permission is tested three times, for the owner of the file, the members of the group that owns the file, and everyone else. User, group, others. ( The execute bit on a folder means you can list its contents.) So there are nine permission tests. owner-read, owner-write, owner-execute, group-read, group-write, etc.

Does minidlna support custom containers ? like for TV series I wan to have TV_Series !

Dutch guy is very happy with it. Learned how to use Putty (a
little), learned some bash commands and I have my music all over the
house from 1 usb-stick!

Thanks a lot!!