Introduction: Raspberry Pi Media Server - MiniDLNA

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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.

Comments

SanL3 (author)2016-11-05

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 .

sfitsos (author)SanL32017-10-09

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.

TomN48 (author)2016-03-18

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

SanushenG (author)TomN482017-06-02

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.

TomN48 (author)TomN482016-03-18

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

drdischord. (author)2017-04-09

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.

duke503 (author)2015-04-06

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?

drdischord. (author)duke5032017-04-09

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.

SanL3 (author)2016-09-13

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

jbooij (author)2016-09-07

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!!

DaveH151 (author)2016-08-01

Worked a treat, thanks for sharing

tmdelia (author)2016-06-03

I'm serving my media to a Roku box using Roku Media Server. When I go to Videos, Music, or Pictures, I would prefer that it goes directly into the respective folder on my Pi. However, when I go to any of the 3, Video, Music, or Pictures, I am presented with all 3 folders. How can I get the Roku to go directly to the Video folder when I choose Video from the Roku Media Server? Here's what my minidlna.conf file looks like:

# This is the configuration file for the MiniDLNA daemon, a DLNA/UPnP-AV media
# server.
#
# Unless otherwise noted, the commented out options show their default value.
#
# On Debian, you can also refer to the minidlna.conf(5) man page for
# documentation about this file.

# Specify the user name or uid to run as.
#user=minidlna


# Path to the directory you want scanned for media files.
#
# This option can be specified more than once if you want multiple directories
# scanned.
#
# If you want to restrict a media_dir to a specific content type, you can
# prepend the directory name with a letter representing the type (A, P or V),
# followed by a comma, as so:
media_dir=A,/media/HDD/Music
media_dir=P,/media/HDD/Pictures
media_dir=V,/media/HDD/Video
#media_dir=/media/HDD

# Path to the directory that should hold the database and album art cache.
db_dir=/media/HDD/minidlna

# Path to the directory that should hold the log file.
log_dir=/media/HDD/log

# Type and minimum level of importance of messages to be logged.
#
# The types are "artwork", "database", "general", "http", "inotify",
# "metadata", "scanner", "ssdp" and "tivo".
#
# The levels are "off", "fatal", "error", "warn", "info" or "debug".
# "off" turns of logging entirely, "fatal" is the highest level of importance
# and "debug" the lowest.
#
# The types are comma-separated, followed by an equal sign ("="), followed by a
# level that applies to the preceding types. This can be repeated, separating
# each of these constructs with a comma.
#
# The default is to log all types of messages at the "warn" level.
#log_level=general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn

# Use a different container as the root of the directory tree presented to
# clients. The possible values are:
# * "." - standard container
# * "B" - "Browse Directory"
# * "M" - "Music"
# * "P" - "Pictures"
# * "V" - "Video"
# If you specify "B" and the client device is audio-only then "Music/Folders"
# will be used as root.
#root_container=.
root_container=B

# Network interface(s) to bind to (e.g. eth0), comma delimited.
# This option can be specified more than once.
#network_interface=

# IPv4 address to listen on (e.g. 192.0.2.1/24).
# If omitted, the mask defaults to 24. The IPs are added to those determined
# from the network_interface option above.
# This option can be specified more than once.
#listening_ip=

# Port number for HTTP traffic (descriptions, SOAP, media transfer).
# This option is mandatory (or it must be specified on the command-line using
# "-p").
port=8200

# URL presented to clients (e.g. http://example.com:80).
#presentation_url=/

# Name that the DLNA server presents to clients.
# Defaults to "hostname: username".
friendly_name=RasPi

# Serial number the server reports to clients.
# Defaults to 00000000.
serial=681019810597110

# Model name the server reports to clients.
#model_name=Windows Media Connect compatible (MiniDLNA)

# Model number the server reports to clients.
# Defaults to the version number of minidlna.
#model_number=

# Automatic discovery of new files in the media_dir directory.
inotify=yes

# List of file names to look for when searching for album art.
# Names should be delimited with a forward slash ("/").
# This option can be specified more than once.
album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg
album_art_names=AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg
album_art_names=Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg

# Strictly adhere to DLNA standards.
# This allows server-side downscaling of very large JPEG images, which may
# decrease JPEG serving performance on (at least) Sony DLNA products.
#strict_dlna=no

# Support for streaming .jpg and .mp3 files to a TiVo supporting HMO.
#enable_tivo=no

# Notify interval, in seconds.
notify_interval=300

# Path to the MiniSSDPd socket, for MiniSSDPd support.
#minissdpdsocket=/run/minissdpd.sock

edgypyro1 (author)2016-03-15

How is your 1000gb hard drive formatted to fat32 which has a limit of 32gb

ScottC134 (author)edgypyro12016-05-16

The fat32 partition format on the drive is not limited to 32GB. It has a single file limitation of 32GB. The partition size can be whatever you need, but if you have a boot image file or something that is larger than 32GB it wont work. Since we are not using this disk to boot from, we won't have problems, unless some of your media files are larger than 32GB. You can also format the drive with Linux style drive formatting, or the system will support NTFS formatting as well.

edgypyro1 (author)2016-03-21

Seriously how? How is you 1000Gb hard drive setup as fat32 when fat32 is restricted to 32Gb?

FilipP11 (author)edgypyro12016-04-06

You can format even 2tb drive like fat32, you need just sofrware to do it, partitionmagic or freeware version... I have 3 hdd formated as fat 32, 800gb, 750gb and 1tb usb drives due to playback movies via ps3

LouisB20 (author)2016-03-18

Hi and thanks - seems to be working great serving up to my Samsung DVD player.

1 item to improve on would be the case where user could have more than 1 USB drive connected and mounted. In this case, you should refer to the UUID of the drives as the sda/sdb names are somewhat random.

All you need to do is to add this in the fstab file instead:

UUID=<your drive uuid> /media/<your media> vfat nofail,user,umask=0000 0 0

setting umask above will mount with the correct permission 0777 also so you can skip that step in your tutorial.

Then redirect minidlna to the path above using in config to /media/<your media>

Find the uuid by running "sudo blkid".

edgypyro1 (author)2016-03-15

Also does this work with Jessie or is it only Wheezy

ChuckS35 (author)2016-01-27

In order to get the files to show up on DLNA client I had to also the change following paths in minidlna.conf:

media_dir=/var/lib/minidlna

#db_dir=/var/lib/minidlna

Change to:

media_dir=/media/HDD

db_dir=/media/HDD

wes_Pi (author)2016-01-22

Thanks for the clear tutorial. I followed all the steps and received no errors, but RASPI MINIDLNA does not show up on my windows 7 computer. I also have a laptop running Linux Mint and it does not show up there either. Can you help?

ibowden (author)2015-12-16

I'm further along than I was when I wrote that last post, but am still not totally at the finish line...

After doing a lot of searching and experimenting, I've discovered that I can get myself out of emergency mode by editing the fstab file and then rebooting. After some further reading on the 'net and experimentation, I've found that when I identify my file system as "ntfs-3g" in fstab and do the other config file editing in the subsequent steps, I can boot up properly and I can even see the media server from my smart DVD player and any PC on my network! Almost there! However...

Despite having hundreds of media files on the USB hard drive that's attached to the Pi, none are visible via the DVD player's interface. They presumably need to be reorganized somewhat into specific directories where they'll be found. No explanation was provided in your instructions regarding doing this. Perhaps it has something to do with identifying these directories with the letters A, P, and V.

The best interface to do this expected reorganization of the USB hard drive is from is my Windows 10 PC which, as I stated, shows the DLNA server in its list of Media Devices in the Network category. However, when I try to actually access the media server by double-clicking - as I would access any other PC or storage device on my network - I'm immediately transported to my browser and a Mini DLNA status screen. This screen, BTW and as expected, indicates exactly zero available audio, video, and image files!

Ongoing, it would seem rather silly to have to disengage the USB hard drive from the Pi and attach it to my Windows PC every time I wanted to add some media files to my library! I'm figuring there's got to be a way via Windows File Manager to simply copy media files over to the MiniDLNA server rather than via this cumbersome detach/attach procedure.

Please help me with these final steps.

The Server Guy (author)ibowden2015-12-17

Hi ibowden, I have replied to your comment.

The Server Guy (author)2015-12-17

That question mark at the end was supposed to be an emoji

The Server Guy (author)2015-12-17

Hi, I'm sorry that my instructions weren't clear enough. I will try to improve them when I get home. But anyway about your questions, I believe that the first problem was that none of the media files were showing up on your other devices? I think your problem is that you haven't defined the media directories which is the a, v, p part of the instructable that you were asking about (a, v, p stands for audio, video and photo). I suggest that you read over STEP 5: CONFIGURING MINIDLNA. And about your other question which I think you wanted to know if there was an easier was to transfer files to the server. You can setup a program called Samba on your raspberry Pi which will share the contents of the hard drive to all the pc's on your network and it will just show up as another hard drive. This means that you can easily transfer files to and from the hard drive remotely.

I hope this helped a bit. I'm sorry it isn't very clear or detailed. That is because I'm writing this on my phone. If you have any questions just leave another comment and I'll try and get back to you. When I get home I'll be able to write some more detailed instructions if you need them. Thanks heaps Alex ?

ibowden (author)2015-12-16

I'm a Windows guy, swimming through the murky depths of Raspbian, trying to get a little media server set up on my home network. After following your instructions to the nth degree, I find myself - for the second time - with the "Welcome to emergency mode!" prompt and have no idea of what to then do to extricate myself from it! So, once again, I am beginning from scratch by putting NOOBS onto an SD card and going through the process again from the beginning...

I trip when I come to the reboot just after editing the fstab file. In the previous step, the "sudo fdisk -l" command indicated what you stated I'd need to know about the USB hard drive I've attached to the Pi. Specifically, it told me that it was sda1 and that the file system was HPFS/NTFS/exFAT.

When explaining and illustrating that your Pi indicated the file type to be "FAT32", the resulting parameter you entered into the fstab file was "vfat." Presumably, there is an unexplained correlation between FAT32 and vfat which is not explained nor expanded upon, especially when faced with a different file system type - HPFS/NTFS/exFAT in my case.

I have also presumed, by the way, that there are tab characters to be inserted where large spaces exist in the line "/dev/sda1 /media/HDD vfat defaults 0 2" Am I correct in doing this? Large spaces made by multiple space characters are unheard of typically when formatting parameters for a command. Perhaps this is different in the Linux world.

So, when I go to edit fstab for the third time, what am I to put here? I have tried FAT32 and HPFS and tabs between parameters and ended up in emergency mode and fear I'll be there again if I put HPFS/NTFS/exFAT there. Please add some further information and clarity to your instructions so that I can make this seemingly-simple project come to a happy conclusion!

interkin3tic (author)2015-05-03

Thanks!

For the complete noobs like me, you might want to explain this last bit in step four:

"Now it you reboot and move into the directory /media/HDD and run the ls command. You will see that all the files from your hard drive are there."

I mean, I was able to google "how to reboot in terminal raspberry pi" and figure out the "CD" command, but it was a little discouraging since I'm learning to use terminal for the first time and it feels like EVERY step of the way I need to go back and learn how to do basic things.

JimS99 (author)interkin3tic2015-12-16

Welcome to Linux!

Is there any other parts in the tutorial that could use more detail?

Hi, thanks for the feedback! I will go over the instructions again and try to make it easier to understand.

kunalm13 (author)2015-11-07

I've installed VLC on my phone. I'm not able to play it.

Also, how can I access it out of my network.

The Server Guy (author)kunalm132015-11-07

You should be able to access your media through VLC on your phone and I am not sure why that isn't working, sorry. But in order to access your media outside your network you will need to port forward your MiniDLNA server. You can watch a tutorial on port forwarding here: https://www.youtube.com/watch?v=Kp-R-eHiQco

SanojK (author)2015-10-15

Great tutorial. Thanks

I can stream .mp4 files using minidlna, but it isn't detecting the .mkv and .vob files in my harddisk. Any ideas on how to fix this?

KunalM4 (author)2015-09-19

Marco Burgman (author)2015-09-01

Is it also possible to make it so that I could see the files from everywhere not only my home network? I already portforwarded my router, and placed owncloud on it, so when I typ my domain/owncloud I get to see my server. Will this work the same with minidlna, when I input domain/(the name given in step 3 I thought?) will this work?

KunalM4 (author)2015-08-18

JohanK6 (author)2015-08-07

The Raspberry version is quite old: 1.0.24, whereas the newest version is 1.1.4:

http://sourceforge.net/projects/minidlna/files/min...

There are several pages elsewhere how to update it, but none that I have been able to get working. Do you have any suggestions?

The Server Guy (author)JohanK62015-08-08

Have you tried this guide?

http://www.htpcguides.com/install-readymedia-minidlna-1-1-4-raspberry-pi/

JohanK6 (author)The Server Guy2015-08-11

I'd tried it but ran into issues that made me try and revert (and that's not easy, let me tell you.) I've tried it again just now and no issues, so here's the steps I did exactly in order, for posterity (note that they are also on the page you linked, but last time I got some errors with the extra ones listed on the page which I think I may have done time before last):


sudo apt-get purge minidlna -y

sudo apt-get remove minidlna

sudo apt-get autoremove -y

echo "deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free" | sudo tee -a /etc/apt/sources.list

sudo apt-get update
sudo apt-get build-dep minidlna -y

wget http://sourceforge.net/projects/minidlna/files/mi...
tar -xvf minidlna-1.1.4.tar.gz
cd minidlna-1.1.4
./configure && make && sudo make install

sudo cp minidlna.conf /etc/
sudo cp linux/minidlna.init.d.script /etc/init.d/minidlna
sudo chmod +x /etc/init.d/minidlna
sudo update-rc.d minidlna defaults

sudo nano /etc/minidlna.conf

sudo service minidlna restart
sudo reboot

nmehrotra1 (author)2015-08-09

I have made this server the server is showing in xbmc on my laptop and there are the 3 file inside but there eis nothing inside those files although I ha ve almost 10 movies I'm flash drive

JamesB75 (author)2015-07-23

I am unable to locate package minidlna

Any ideas what I am doing wrong?

The Server Guy (author)JamesB752015-07-23

Try running these commands:

sudo apt-get update

sudo apt-get upgrade

Now try running the command again. I hope this helps :)

AshleeJ made it! (author)2015-07-13

great tut thank you

carlpoppa (author)2015-07-09

I am an avid Unix (FreeBSD) User but on my Pi run debian version. I didnt think the PI could handle it till I saw this post.. I installed it and it runs perfectly... Thanks for the post...

The Server Guy (author)carlpoppa2015-07-09

I'm glad you liked it :)

NickS31 (author)2015-06-27

I have everything working but when I restart the raspberry pi. Minidlna will come up with no files. I have to run a force-reload. Is there a way to fix this to load at boot up? Thank you for your time!

The Server Guy (author)NickS312015-06-27

Hi,

I would add these to lines to your minidlna config file.

inotify=yes
notify_interval=300

You can edit the config file by using this command:

sudo nano /etc/minidlna.conf

If this doesn't work just get back to me and we will try and figure it out.

Hope this helps.

jachol (author)2015-03-23

Hi,

All goes well until I try to install USB HDD ... fdisk -1 gets reported as invalid and also I see a list of fdisk options, I tried a few but results exactly as before.

I'd love to get this project functioning, any suggestions please.

Eric Brouwer (author)jachol2015-06-20

It is fdisk -l

it's a small letter "L", not a numerical "1"

The Server Guy (author)jachol2015-03-24

Hi, I think were you went wrong is the command. I think you typed:

sudo fdisk-1

With a one on the end. The command you were supposed to use was:

sudo fdisk-l

And that is a lower case L on the end not a one.

I hope this helps. I'm sorry that it looks like a one it is just the font used by this site.

jachol (author)The Server Guy2015-03-24

Hi, you got it, I should have seen that one I did switch between 1 and i, l was the next logical step.

Hope to make progress now without further hiccups. Many thanks. ... J

About This Instructable

345,704views

209favorites

License:

Add instructable to: