Tag Archives: Windows

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 https://www.virtualbox.org/wiki/Downloads and installed it.
(version 4.1.8 in my case)

Next I downloaded Ubuntu (which is free) from http://www.ubuntu.com/download/ubuntu/download
(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:

[music]
	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.

Advertisements

Windows: Symbolic links, junction points, whatever you want to call them, how to and why #windows

Ever run out of disk space in Windows and want to move things to a different disk, but Windows (or the application) will break?
Yes, in Linux/Unix based systems you’ve got wonderfully simple symbolic links, I’ve always wanted windows to have some of that power. Junction points in the NTFS file system are a way to achieve something close to symbolic links.
First off you need to be an administrator, if you’re user has restricted access then you are doomed. It is also worth pointing out that this isn’t for beginners, care must be taken otherwise you could break your applications or even Windows.

If you have a directory already, move the contents to the other drive. For me let’s call this “C:\dir1\bigdir”, I’ll move that to my drive that has space, “F:\”. It is worth noting that bigdir will remain empty and will be turned into the junction point. Here’s the create junction point syntax (run cmd.exe a.k.a. command prompt with administrative privileges):

CD "C:\dir1"
MOUNTVOL "bigdir" \\?\Volume{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}\

What is XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ?
Run MOUNTVOL with no arguments and you will get the list of volumes.

You can also use MOUNTVOL to remove a junction point (/D option), the directory you created will remain and appear as before (empty).

So you end up with something that conceptually I’d write as “C:\dir1\bigdir” -> “F:\”.

The limitation of this is you can only link to drives.
If you want to link to a subfolder e.g. “F:\mounted_folders\bigdir” then you will need to download the Windows SDK and use a program called linkd.

For more information see How to create and manipulate NTFS junction points and Microsoft Windows Software Development Kit

Shell32 Interop DLL Generation

As far as I’m aware you’ve got two choices when you want to call non .NET assemblies, DllImport or Interop.

For DllImport you’ll want to consult pinvoke.net.

But that DllImport syntax isn’t for everyone, some like to pretend we are working with .NET assemblies and want to use an Interop DLL, but how?

First you need to generate one using Tlbimp.exe (Type Library Importer)
For example
c:\Windows\System32>tlbimp shell32.dll /out:me.dll
Microsoft (R) .NET Framework Type Library to Assembly Converter 3.5.30729.1
Copyright (C) Microsoft Corporation. All rights reserved.
Type library imported to c:\Windows\System32\me.dll

Now just include the me.dll in your project (as a normal .NET assembly reference), stick a “using Shell32 = me;” / “Import Shell32 = me” in your source code and voila, Shell32.Folder etc is at your disposal.

Note: retrospectively thinking, don’t generate the dll into System32, you’re just asking for trouble.

I’ve been putting it off, but the time to delve into PowerShell is upon me

I’ve been putting it off, but the time to delve into PowerShell is upon me (again).
Yes, I’ve of course looked at and used some very basic PowerShell before, but I ultimately ended up with a .vbs script as I found something similar to what I wanted and it was easy enough to change.
This time I have to start from scratch and PowerShell it is…

Fortunately there are lots of free resources online to help, I found this one:
http://powershell.com/cs/blogs/ebook/default.aspx
And it looks promising.

First impressions are positive, but I still want to write C#, oh well.

Windows 8 HP printer no install option – Troubleshoot compatibility

I tried to install my HP printer and the installation screen had no install button:

So I tried the compatibility tool that comes with Windows 8, right click the installation file and select Troubleshoot compatibility:

This then opens the Program Compatibility Troubleshooter:

I then clicked Troubleshoot Program:

And of course this worked before, so I selected that option

It was Windows 7, so I selected that option

Then the Start program button to see it work!

Of course there is no guarantee it will work, but this is a step in the right direction.

Windows 8 Developer Preview – More on keyboard shortcuts

In my Windows 8 Developer Preview Walkthrough post I mentioned a few shortcuts, there are lots of shortcuts, but I thought I’d summarise some useful ones here:

To search for an application: WinKey then just start typing
Press WinKey then release then type COM (in upper or lower case) to get a list of apps containing words beginning with COM, first in my list is Command Prompt. I could also type PROM, but notice that ROM doesn’t show anything. Which might be annoying if the app is about cycling but called bicycling then you wouldn’t find it.

To search for settings: WinKey + W
Press and hold WinKey then press W once and release the WinKey, then just start typing, so type POW and you will see Power Options in the list. I fail to remember (every time) that Control Panel is an app, so when searching on settings I don’t find it, but thankfully the search is clever enough to show there is an item in Apps by marking that icon with the matching number too, so I see, hmm, Settings 0, Apps 1, let me click Apps and voila, there it is.

To search files: WinKey + F
Press and hold WinKey then press F once and release the WinKey, then just start typing. This one is nothing new, but if you can’t remember the other two shortcuts, then use this old faithful and click on the Apps/Settings or whatever.

To show the desktop: WinKey + D
Again, nothing new and indeed a shortcut I rarely used, until now. This one really comes into it’s own, can’t find the Desktop tile, can’t be bothered to reach for the mouse, then this one is your new friend.

To bring in the settings bar: WinKey + I
Oh look, the power button!

And my classic favourites…

Active application switch: ALT + TAB

Task Manager: CTRL + SHIFT + ESC

Lest not forget ALT + F4 to close the current window.
Tip: Getting out of Windows 8 (a.k.a. shutting down) is a bit of a pain to get (via the settings screen), but this shortcut gets you there the old way. So WinKey + D to show desktop (if required), then ALT + F4 and there is the old style Log Off / Shutdown / Restart box.

To lock the screen: WinKey + L
Tip: Rather than sliding the lock screen upwards to reveal the logon prompt, just hit Enter.

To open the run dialog: WinKey + R
Also remembering useful apps like mstsc etc

To open Windows Explorer: WinKey + E

Lesser known (more recent) is the numbers…

To open a pinned application: WinKey + 1/2/3/…
Press and hold WinKey then press 1 once and release the WinKey.
I have pinned Google Chrome pinned to my taskbar in the third place, so WinKey + 3 gets me there, even from the start screen!

I will try and add more when I remember, but also if you know of any please comment and I will add them.

Windows XP needed a reinstall, so I thought I’d try Windows 8 Developer Preview instead

It’s that time of year when Windows is slowing down, dragging its feet, bogged down with Windows updates and patches and a registry that’s filled with more old junk than my parents’ garage. I couldn’t stand it anymore, boot up time was more than it takes to make a cup of tea and shutdown time often involved Comodo Firewall crashing and holding things up too. So it was time for a reinstall.
I kept meaning to upgrade my PC (add more RAM at the very least) and buy and install Windows 7, but until now my Windows XP Professional has served me well and I’ve run virtual machines (including Windows 8 Developer Preview) in it recently without any problems (once Windows is loaded it’s not that bad).
So I thought, what the heck, I’ll just install Windows 8 Developer Preview as my main Operating System, see how it runs with only 2GB of RAM, I can upgrade if I need to later. I’m not running anything major, no intensive games, just normal desktop and internet applications, but Windows 8 is running fine, Internet Explorer 10 seems good too. Naturally only time (plus updates) will degrade the performance 🙂
Feeling like I should show something, here’s a screenshot of Task Manager whilst I’ve been writing this post:

You can see my weeny Pentium Dual-Core E2180 (2GHz) processor is speedstepped down to only 1.2GHz and it’s not using much memory, so Windows 8 is looking to be a lean Operating System thus far and I’m starting to wonder if I need to upgrade?

Right, now to give some details of how I got up and running:

1: Download Windows 8 Developer Preview from Microsoft. I chose to go for the smaller 32bit version because I wanted to install it in a Virtual Machine inside 32bit Windows XP first – see my other post about those first impressions after install here

2: Burn to a DVD using Imgburn (it’s free)

3: Shutdown and turn off

4: Swap main hard drive for a spare (admittedly only a tiny 80GB drive just to try it out)

5: Insert the DVD, turn on, boot from DVD and follow the instructions

Windows created a 350MB partition for it’s own purposes, whatever they are, so I wouldn’t want to install on top of an install of a different version of windows because you may lose everything in the repartitioning (that’s why I used a spare drive).

6: Installed ZoneAlarm Firewall (Free)

7: Installed Google Chrome (free) – not that the included Internet Explorer 10 Developer Preview isn’t working fine other than I can’t upload to WordPress using it (could be a security setting, who cares anyway, either will do)

I might install Antivirus software sometime soon too, but I haven’t see a virus recently, but still, better to be safe than the victim of crime. If pictures of willies start appearing in my blog posts you’ll know what happened.

If you have spare hard drive and a blank DVD give it a try, it’s free, you have nothing to lose and it might lead to that motivation needed to buy the latest Windows (7 or 8 when it comes out). If I get stuck or it stops working I’ll just swap my drives back and I’m in Windows XP again (after several cups of tea).