So you want a Media Server? Here’s how to… #music #video #images #linux #mediatomb #samba

Want to share photos, music and videos and not have to sync it to the sky or pay for the privilege?
Then read on…

I have two laptops, a tablet and a capable mobile phone in the house now, so the PC (Windows XP Pro) is sitting idle, “why not turn it into a media server?” I thought, but I didn’t want to shell out for any special software or a newer version of Windows.

It turns out all you need is Ubuntu (or Debian) Linux and nothing else!
It is also free and the recent versions contain MediaTomb; the key piece of software that’s needed.

Get the software

For proof of concept purposes I installed this within Oracle VM VirtualBox (which is free) so I could fiddle without actually destroying my Windows PC installation (yet). So I first downloaded this from and installed it.
(version 4.1.8 in my case)

Next I downloaded Ubuntu (which is free) from
(version 11.10 32bit in my case, get the 64bit version if you have more than 3.7GB of RAM)

If you want to install on the PC directly then you will need to burn the Ubuntu .ISO image file to a CD or DVD. For an install into VirtualBox I skipped this step.

Install Ubuntu

For PC install you boot from the CD/DVD you’ve burnt; install as you would any operating system.

For VirtualBox, create the VM ready for Ubuntu:

Then start it and select the .ISO image file:

Then follow the installation instructions (for either PC or VirtualBox).

Notes on installation

The only thing I would like to draw attention to is the MP3 plugin, I’d install that:

Configuration and service installation

OK, so MediaTomb isn’t installed as such, so you need to install it, fortunately this is easy.
Select the Ubuntu Software Centre:

Then search for MediaTomb by typing into the search box, it will dynamically search for it, select it like so, then click install:

Once installed you will need to make a couple of configuration changes. Open the Dash:

Then search for terminal:

Click on Terminal to open it.
Then to open the config file in a text editor, type

sudo gedit /etc/mediatomb/config.xml

Now enable the user interface, change the setting for <ui enabled=”no“…> to <ui enabled=”yes“…>.
Next change <virtual-layout type=”builtin“> to <virtual-layout type=”disabled“> otherwise you will get 5 of everything, this is something you can lookup if you want to.
If you want to stream to a PS3 then you will want to enable transcoding, I don’t have one, but the option to change is <transcoding enabled=”no“> to <transcoding enabled=”yes“>.

Save and close.

You can now either restart Ubuntu or restart the service from the command prompt:

sudo /etc/init.d/mediatomb restart

Configure content locations

First off you need somewhere to store the content, so create some new folders and give them appropriate security permissions, to do this open terminal again and type the following:

sudo mkdir /mymediaserver
sudo mkdir /mymediaserver/music
sudo mkdir /mymediaserver/video
sudo mkdir /mymediaserver/images
sudo chmod -R 775 /mymediaserver

The Linux gurus will want to get their filesystems in order, but the rest of us will have one filesystem and this will be fine.

Now register these locations in MediaTomb, search for MediaTomb from the Dash:

Open MediaTomb, it will open in FireFox most probably:

Click Filesystem then expand mymediaserver in the tree:

Now select each subfolder in turn then click the “add as autoscan dir” icon
You will want to choose appropriate settings, but I expect you will want to recursively scan the folder for changes every 30 minutes, like so:

Don’t forget to click Set each time.

Now disable the user interface again.
Open the config file in a text editor again via

sudo gedit /etc/mediatomb/config.xml

Change the setting for <ui enabled=”yes“…> to <ui enabled=”no“…>.

Save and close.

Samba (optional?)

We need some way to get new files into MediaTomb, a Windows File Share is perfect for seamless drag and drop of content, so I’ll go with that. Samba is the service to install, but there are a fair few steps, so keep with me, back in Ubuntu Software Centre search for samba and install the SMB server:

Once installed we add the users, search the Dash for User Accounts:

Open User Accounts:

Click the Unlock button before you start otherwise you won’t be able to make changes.
Click the + (Create a user) button, make it a standard user:

Then click Create. Unfortunately there’s more to do, we next need to enable the user, click on Account disabled:

Select Set a password now (if not already selected).
Enter a password and click Change.
Note: Unfortunately Microsoft have made some changes introduced in Windows 7 Home editions that make using a user name and password beyond the average user (i.e. there is no UI to change this setting), but if the user name and password you use for Windows are configured in Samba then you will be fine, so I will go for this approach for now.
Do this for every user you want, if two PCs have the same logon details then duplication is not required.
Linux is strict on security, so we need these users to be in the same group. To do this open Terminal again and type the following for each user:

sudo usermod -G sambashare <user>

Now to setup the security that Samba needs on the file locations via this sambashare group, type the following:

sudo chown -R :sambashare /mymediaserver

Now to configure Samba, open the config file via:

sudo gedit /etc/samba/smb.conf

Add the lines to the end of the file:

	path = /mymediaserver/music
	writeable = yes
	browseable = yes
	guest ok = no
	read only = no
	valid users = @sambashare
	force create mode = 0661
	force directory mode = 0775
	force group = sambashare

(repeat that for the other folders as required)

Save and close.

The final piece for Samba is to register the user with Samba via smbpasswd:

sudo smbpasswd -a <user>

Nearly there, just a quick note for VirtualBox, there is a network setting change required.
You will need “Bridged Adapter” and a Promiscuous Mode of “Allow All”:

Restart and verify

You can now either restart Ubuntu or restart the services from the command prompt:

sudo /etc/init.d/mediatomb restart
sudo /etc/init.d/smbd restart

You should be able to see the UPnP work its magic from a Windows machine under the Network part of Windows Explorer:

The MYMEDIASERVER (or indeed whatever you called your machine) – that is Samba working (assuming you configured it)
The MediaTomb – that is MediaTomb working

Add Media (requires Samba)

Open MYMEDIASERVER (or whatever you called it)
And drag and drop the files you want into music, video or images as required.
Note: Depending on settings chosen above it may take some time for the new content to be available through MediaTomb.

Stream it

Open MediaTomb from Windows Explorer / Windows Media player and enjoy

Security notes

The assumptions I’ve made are that you are behind a firewall in a nicely secure private LAN.
All the security settings above are my choice, you should review your security and choose your own options, if you are at all concerned then you need to seek professional help (or an IT professional). Remember to regularly backup your files and verify the backups too.


One response to “So you want a Media Server? Here’s how to… #music #video #images #linux #mediatomb #samba

  1. Pingback: So you want a Media Server? Here's how to… #music #video … | Pici's Ubuntu Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s