Raspberry Pi Media Server - MiniDLNA

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

Recommendations

  • Metalworking Contest

    Metalworking Contest
  • Fix It! Contest

    Fix It! Contest
  • Tiny Home Contest

    Tiny Home Contest

65 Discussions

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 .

1 reply

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

2 replies

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?

1 reply

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

Worked a treat, thanks for sharing

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

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

1 reply

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.

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

1 reply

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

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".

Also does this work with Jessie or is it only Wheezy

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

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?