Hot Serving of Pi – P4

Step 3: Samba & miniDLNA

[Introduction] [Step 1] [Step 2]

This is the last step in the process of making a cheap media server. We’re going to install and configure Samba and miniDLNA. Samba allows us to see files on the server from any machine on the network, and miniDLNA allows uPnP receiving devices, like the PS3, to easily access all the files on the server without any kind of hack or customisation.

First things first, either SSH into your Pi, or load up LXTerminal if you prefer to use the GUI.

To install Samba, we want to run the following commands:

sudo apt-get install samba

After a moment you’ll be asked if you want to continue, type ‘y’ and hit return.

This may take a few minutes, depending on your internet connection.

sudo apt-get install samba-common-bin

Once that’s done, we might as well go ahead and install miniDLNA while we’re installing stuff, so type:

sudo apt-get install minidlna

‘y’ at the prompt, and wait for it to finish.

Now that that’s all installed, we’re going to create an SMB user.

To do this we simply run:

sudo smbpasswd -a pi

It will ask you to create a password for this new user. Enter a new password and hit return. Confirm this new password by typing it again, and hit return again.

This has created a new SMB user, called ‘pi’, who can use the Samba service.

Next we’re going to edit the Samba configuration file, ‘smb.conf’. This is where I ran into trouble, as whatever I tried simply didn’t work. Eventually I just deleted everything in the file and filled it with new stuff. Before we do that though, we need to copy the file so we have a backup to fallback on.

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.copy

Remember kids, safety first.

Now we want to edit the .conf file with nano. smb.conf is a large file, and reading through it I found that Samba has print capabilities I didn’t know about which sound like they would be very useful in future; I’ve been looking for a way to hide the printer away somewhere. To edit the .conf file type:

sudo nano /etc/samba/smb.conf

Now we’re going to delete everything in the file. Don’t worry, we made a backup copy, so we’re not really going to lose anything.

We want to replace all the gumpf in that with the following lines:

workgroup = WORKGROUP
server string = raspnas server #here
netbios name = raspnas #and here, you can name your server.
dns proxy = no
### Logging
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
### Authentication
security = user
map to guest = pi
path = /media
guest ok = yes
guest account = ftp
browseable = yes
read only = no
create mask = 0777
directory mask = 0777
writeable = yes
admin users = everyone

Your finished .conf file should look like this:

Screen Shot 2013-06-18 at 18.30.42

If you’re happy with this file, hit ctrl-o, then ctrl-x to save and exit the file.

The last thing to do now is restart Samba. This is nice and easy:

sudo /etc/init.d/samba restart

Now, as far as Samba goes, that’s it. Samba is running, and it shares the directory ‘/media’, meaning that any drive we plug into it will appear as a network drive. This is useful because we can later add more and more drives without needing to do too much .conf fiddling.

If all you want to do is access files over a network, then you can stop here. Your Pi now shows up on the network as a NAS, such as in the image below:

Screen Shot 2013-06-18 at 18.50.15

You simply need to connect to it using the user name and address you created a few moments ago, and voilà:

Screen Shot 2013-06-18 at 18.51.40

If, however, you’re like me, and simply accessing it from another computer is not enough, we now need to configure miniDLNA to allow us to access the contents from uPnP devices.

We’ve already installed miniDLNA earlier, so now we just need to edit the .conf file. A quick ‘cd ~’ takes us back to the home folder to sake of simplicity, then:

sudo nano /etc/minidlna.conf

Relatively close to the top of that file is a section that starts with the word ‘WARNING’. Don’t fret, it’s all fine.

At the bottom of that block is ‘media_dir=’. We need to tell miniDLNA where our media is, so go ahead and type in the directory where your files are going to be stored. For example, my finished file looks like this:

Screen Shot 2013-06-18 at 19.02.19

ctrl-x to save and exit, then restart the miniDLNA service with:

sudo service minidlna restart

You may find it helps to also run the command below once the service has restarted:

sudo service minidlna force-reload

Depending on how much stuff you have in the directory that you’ve just told miniDLNA to read from, it may be a good idea to give it a few minutes to compile it’s database before you try to access it.

Once you’ve given it sufficient time to build its database, you should now be able to access the content from your uPnP device. The image below shows my PS3 accessing the media server:


And that, ladies and gentlemen, is it. You now have a very cheap media server.

You might find, as you’re using it, that the Pi is getting hot. To find out exactly how hot the Pi is you can run the following commands:

cd /var/log
/opt/vc/bin/vcgencmd measure_temp

This will give you some output something like this:

Screen Shot 2013-06-18 at 19.42.58

As far as I understand it, this is fine. The Pi won’t throttle the CPU until it reaches something like 85˚. To bring the Pi’s temperature down a bit you can open up some holes in its case if there aren’t any already, or you can mount it on its side, giving both the top and bottom some airflow. If that’s not good enough, you can purchase heat sinks cut to the Pi’s measurements, and if even that isn’t enough, you can go down the route of installing GPIO controlled fans. A heat sink should probably suffice though.

Heat sinks are quite a simple concept. They transfer heat generated from C/GPUs into the surrounding air. They can be as simple as a chuck of fin-like metal, or they can involve slightly more complex heat conduction and fan systems. Below are a series of images that show how a heat sink and fan combination work.

Image 1 shows an old White MacBook logic board with exposed processors. Note the grey-coloured heat paste present in the middle of the processors.

photo 1

The next image shows the underside of the heat sink and conduction device. Heat paste helps to transfer the heat from the processor cores to the heat sink itself.

photo 2

The next image shows the topside of the heat sink device as it would be installed normally. Heat is transferred from the heat sink surfaces, as shown in the previous image, and along the copper shaft.


The next image shows the fan as it would be installed normally. The fan blows the air that has been indirectly heated by the processor cores, out of the computer, thereby cooling the cores.

photo 3

Well, that’s it for the RPi Media Server Project. Looks like it’s back to Python for a bit.

Author: Dan

Share This Post On