• Home
  • |
  • Blog
  • |
  • How to Set up a Free Media Server on Raspberry Pi Using MiniDLNA?
How to set up a free media server on Raspberry Pi

Raspberry Pi is kept increasing its capabilities with its developing computing power with the passing of time. Its small size with less price makes it an awesome tool to use in many digital projects. We feel excited to share information about one such digital project. Yes, we are going to show you how you can set up a free media server on Raspberry Pi in this blog.

There are different ways to do this. And there are several third-party products available in the market to help you do this. Some of them are free, and some come for a price. But, our intentions are to show you how to set up a free media server on Raspberry Pi in a native way using DLNA protocol. Let’s get started right from the beginning.

What Is a Media Server? And, How It Is Different From a File Server?

File servers are some centralized places to store data in the form of files. For a typical file server, everything it stores is a file, no matter it is a text, picture, video, pdf, or script file. It just provides you to store the data in an organized way. You should need to navigate the data on your own to access it.

On the other hand, a media server is a layer above the file server. It indexes and catalogs the media files like pictures, audio, and video for you to play. On top of that, it allows you to play them over the network. You don’t have to bother about where the movie files are stored. You can just send your queries and get the results on your screen. As an example, Search all the songs by a singer or an artist. All these additional capabilities make the media server more user-friendly, easier to manage, and more attractive to the user.

What is DLNA?

Let’s give you a short description of the DLNA. First of all, DLNA stands for Digital Living Network Alliance. It is a media-sharing protocol standard developed by SONY and Intel with a joint association. It is mainly developed to create standards to share the media over the network. Most smart devices like smart TV, smartphones, smart set-top boxes, and any smart devices which have the capability to share media content supports DLNA. Moreover, computer media players, like windows media playerVLC, and Plex, will also support DLNA.

DLNA enabled computers to act as media servers. Two things are required to work DLNA, DLNA server & client. Media share always happens from one server to multiple clients. You can’t share the content between servers or clients alone. Your next question might be, what are these clients & servers? How do they look? DLNA client could be any device that supports DLNA. For example, all the so-called smart devices which can play media over the network. Don’t be scared that you need a big size server to set up a DLNA server. It’s a small application; any buddy can download it on their computers and build their own server. Just to tell you, your windows media player can act as a DLNA server. And most of the NAS devices are shipped with DLNA server applications to stream media stored on them. Let’s see how to set up a free media server on Raspberry Pi using miniDLNA.

See Also  OPatch- The Best Micropatching Solution

What Is Required to Build a Media Server on a Raspberry Pi?

  1. A running Raspberry Pi with Raspberry PI OS, and miniDLNA app installed on it. Please check out our posts “How to set up a Raspberry Pi for the first time?” and “Five easiest ways to connect Raspberry Pi remotely in 2021:” if you are working on the Pi for the first time.
  2. Your choice of clean formatted and partitioned storage drives is connected to Pi to store and stream media. Please check out our post “How to Partition and Format the Hard Drives on Raspberry Pi:” to learn more about adding a hard drive to a Raspberry Pi.
  3. We also recommend you read this post, “The ultimate guide to build a personal cross-platform file server on Raspberry Pi!” prior to starting this mini project. This post gives a background of our directory file structure on which we are going to build miniDLNA.

Thanks to nutfunny4u for creating this video.

Prerequisites for setting up a free media server on Raspberry Pi using MiniDLNA:

  1. Raspberry Pi device: You need a Raspberry Pi device with the Raspberry Pi OS installed. The post mentions you can use any Raspberry Pi model.
  2. Initial setup of Raspberry Pi: The Pi needs to be set up with remote access, storage drives formatted and partitioned, etc. The post links to other posts covering the initial setup steps.
  3. miniDLNA package: You need to have the miniDLNA server software package installed on the Raspberry Pi. This is the actual DLNA media server.
  4. Media storage: You need one or more storage drives connected to the Pi to store your media files that will be shared by the server. The drives need to be formatted and partitioned ahead of time.
  5. Media files: You need media files such as music, videos, photos stored on the drives connected to the Raspberry Pi that you want to share over the network.
  6. DLNA client devices: To access the media server, you need DLNA capable client devices on your network such as smart TVs, smartphones, media streamers that can discover and play content from the Pi media server.
  7. Network connectivity: The Raspberry Pi needs to be connected to your local network, ideally via Ethernet, so DLNA client devices can communicate with it.

Let me know if you need any clarification or have additional questions!

How to Setup MiniDLNA on the Raspberry PI?

Its lightweight nature allows you to run it on any version of Raspberry Pi. In this section, we are going to show you how to set up a miniDLNA server on Raspberry Pi and stream media files to other smart devices over the network.

We have divided this section into four major subsections, which would give you a better understanding of the complete setup process.

  1. Installation of miniDLNA on the Raspberry Pi.
  2. Create directories to store database and log files.
  3. Configuration of miniDLNA to pick up media files.
  4. Restart the miniDLNA service.

Time needed: 10 minutes

How to set up miniDLNA on the Raspberry PI?

  1. Installation of miniDLNA on the Raspberry Pi:

    It’s simple to install as other packages. Let’s install from apt repositories.
    $ sudo apt-get install minidlnaInstallation of miniDLNA on the Raspberry Pi

  2. Create a directory ‘minidlna’ to store its database and log files:

    We are creating all the directories under /mnt/data-ext4/ for demonstration purposes.
    $ cd /nmt/data-ext4
    $ sudo mkdir minidlna


    Create directory 'minidlna' to store its database and log files

  3. Changing the ownership of the ‘minidlna’ directory to the ‘minidlna’ user and ‘minidlna’ group:

    If you see the permissions for the minidlna directory, one can write to a directory other than root. It’s never the best idea to grant full permission to all. Instead, we create a new user, ‘minidlna,’ and a group, ‘minidlna,’ and change the ownership to the minidlna user and group. This allows the database and logs to be written in the directory.
    $ sudo chown minidlna:minidlna minidlna: chown is the command used to change the ownership of the file. The syntax looks like this, chown user: group directoryChanging the ownership of the 'minidlna' directory to the 'minidlna' user and 'minidlna' group

  4. Ensure the correct permissions on miniDLNA directories:

    Let’s take a look at the ownership of the minidlna directory after the chown command.the ownership of minidlna directory after chown command

  5. Create a directory to store the music files:

    Navigate inside the ‘public’ directory and create a new directory called ‘Music’ inside of it. This time you need not use the sudo command as the ‘public’ directory has full permissions to all users. Upon creating the ‘Music’ directory, see the permissions. This directory is under the user ‘user,’ and the group ‘pi’ and others don’t have write permission on it.
    $ cd public
    $ mkdir Music


    Create a directory to store the music files

  6. Fix the write permissions on the Music directory:

    Use the same ‘chown’ command to change the ownership of the Music directory to everyone and give written permission. User ‘noboddy’ and Group ‘nogroup’ eventually makes everyone the owner of the file/directory.Fix the write permissions on the Music directory

  7. Create a few more directories to organize the media content:

    Similarly, create whatever directories you want to organize your media files. We have created a few more directories for demonstration.
    Create a few more directories inside the public directory inside /mnt/ntfs. And copy some music and movie files into all these directories.

    Create other directories you want to organize your media files

  8. Configure miniDLNA config file:

    Now, it’s time to direct miniDLNA to pick up the media files from the place it stored. Use your choice of a text editor and edit the config file.
    $ sudo nano /etc/minidlna.confConfigure miniDLNA config file

  9. Configure the media directories:

    Scroll down to the line where you see ‘media_dir’ and create a list of additional directories that you have created to store media. After = sign, there is a letter, ‘,’ and the path where the files are stored.
    A: Audio files
    P: Picture files
    V: Video files
    PV: Picture and Video filesConfigure media directories in miniDLNA

  10. Configure directories to store the database and log files:

    Scroll down just below further and set the directories to store the database and log files. Save the changes and close the text editor.Configure directories to store the database and log files in miniDLNA

  11. Restart the minidlna service::

    After making all the required changes restart the minidlna service to write all the changes and it to take effect. Check the status, the service should be up and running if everything is correct.
    $ sudo service minidlna restartRestart the minidlna service

  12. Set max user watches limit temporarily:

    Make sure everything is correct by looking into the log file.
    $ cat /mnt/data-ext4/minidlna/log/minidlna.log
    Just pay attention to a warning log. It says that it can monitor up to 8192 directories and subdirectories for changes. If your collection is larger than this, then you can increase the value by editing /proc/sys/fs/inotify/max_user_watches. But this will not survive a reboot.Increase the limit of files and directories in miniDLNA

  13. Set max user watches limit permanently:

    To set the value forever. Edit the file /etc/sysctl.conf
    $ sudo nano /etc/sysctl.conf
    Scroll to the bottom and add this line: fs.inotify.max_user_watches = 65536Set max user watches limit

  14. Configure minidlna service to start on reboot:

    There are many ways to do this. One such simple way is here:
    $ sudo update.rc.d minidlna defaultsConfigure minidlna service to start on reboo

See Also  Learn Terminal

That’s all. But bear in mind large files would take a large time to index and catalog media files. Sometimes it may take a few hours to complete the catalog process.

Now, your Pi is ready to stream media files over the network. This is how you can set up a free media server on Raspberry Pi using miniDLNA.

Thank you for reading this article. Please visit the below links to read more such interesting articles. Please leave your comments here below and let us know your feedback. This helps us to bring more such articles.

Recommend Products for Raspberry Pi Users

We have some Raspberry Pi accessory recommendations that we think you’ll find useful. These are products we’ve personally selected that we believe are must-haves for any Raspberry Pi owner. Take a moment to look through the list – you can click on any item to view more details or purchase it directly from Amazon. Whether you’re just getting started with your Pi or looking to expand its capabilities, we’re confident you’ll find something helpful among our top picks. Let us know if you have any other questions!

Declaimer: The below products contain affiliate links. We may receive a small commission if you purchase through these links at no additional cost to you. You can read our full affiliate disclosure here.

Read More:

About the author

Arun KL

Arun KL is a cybersecurity professional with 15+ years of experience spanning IT infrastructure, cloud security, vulnerability management, Penetration Testing, security operations, and incident response. He is adept at designing and implementing robust security solutions to safeguard systems and data. Arun holds multiple industry certifications including CCNA, CCNA Security, RHCE, CEH, and AWS Security.

To know more about him, you can visit his profile on LinkedIn.

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Learn Something New with Free Email subscription

Email is also one of the ways to be in touch with us. Our free subscription plan offers you to receive post updates straight to your inbox.