Symbolic Links: Easily Increase Your NAS’ uPNP Library

Many full-features Linux-based Networked Attached Storage (NAS) devices support a plethora of multimedia features.  Many have native support as an iTunes server, web server, ftp server, photo share, and Universal Plug n Play (UPNP) server.  UPNP allows devices such as the Playstation 3, Xbox 360, Squeezebox, and many other streaming clients to play your music and videos in different rooms throughout your house (or office).

There are some limitations to the NAS servers that prevent easily exanding your UPNP library without upgrading your entire storage system.  The Synology and QNAP NAS devices we’ve tested have a special system-created share (e.g. “video” and “music”) that you must put your media files in order for the uPNP server to see them, and this share is usually on the first volume.


UPNP only sees what’s in the system-created “video”, “music” and “photo” shares.  How do we make it use the external “satashare”?

In order to increase the capacity of your UPNP library then you normally have to just upgrade your entire array, which can be rather costly with NASes using 4 disks or more.  Although hard drives are cheaper today (you can get a 1.5TB drive for cheap check prices here), you have to buy at least four of them at once.

If you don’t have money flowing out of your wallet, then you can purchase a single hard drive, slap it in an enclosure, and connect it to the USB or eSATA port of your NAS.  But then the problem arises about how to get the UPNP server to see your video and music files.  The answer lies with the use of Symbolic Links!

Symbolic Links to the Rescue!
A symbolic link (or “symlink”)  is a special file that contains a reference to another file (or even directory) as an absolute path.  The operating system transparently translates this file to any program looking at it (such as a UPNP server).  If you create a symlink reference to another volume within your special “video” directory, then the UPNP server will start indexing all of the files on your external hard drive.   You can create multiple symbolic links for multiple drives and directories, so you could have one drive for TV shows, one for Movies, and another for music.

Other uses for symlinks
Another creative use of the symbolic link is organizing your media.  Some music (and movies) fit into more than one genre, so it can be helpful to create a symlink to find your media better.  For example, we have some music folders that contain kids music (“Kids”).  I also have some sountracks of Disney movies in the “Soundtracks” folder, but I would like them to show up in the “Kids” directory.   Instead of having duplicate files, I can merely create a symbolic link, and can then find my Disney soundtracks in both the “Kids” and “Soundtracks” directories.

On the next page we show you what you need to get the job done…


NOTE: Before attempting this, you must already physically install your external hard drive in an enclosure (check prices) and attach them to your NAS.  Please format the drive using your NAS in the EXT3 or EXT4 format! Don’t think you’re saving time by formatting your drive in Windows and then copying the files over locally! Some NASes can read and write to NTFS volumes, but they are not native.  Seriously, I’ve had a 1.5TB drive perform as slowly as 1MB/s because it was in NTFS format on eSATA.  The same drive formatted in EXT4 got 45MB/second (which is extremely good for a modest NAS device). Also note that this drive should forever be connected to your NAS (or another Linux system) because connecting it to Windows will totally screw it up (Windows will write to the drive, making it unusable).  Only connect to Windows if you are in a last-ditch data recovery scenario. Again, the example below is using a Synology Diskstation DS 409.


Format your drive from your NAS using the EXT3 or EXT4 file system

To format your external drive, go to Control Panel, External Devices.  Click on your drive and then click the “Format” button.  You’ll be presented with EXT3 and EXT4 options.  EXT4 is recommended as it supports more features and general concensus is that it’s faster.

In order to implement a symbolic link on a Linux device, you need to use a terminal emulator.  Before you use a terminal emulator, you must enable “SSH” access on your Linux device.  In Synology’s DSM 3.0, you simply navigate to Control Panel, then Terminal, and then click “Enable SSH Access”.  If your NAS is public then you’ll want to turn this off after you’re done implementing your symlinks.


SSH must be enabled before you can connect with a Terminal Emulator

The most popular Windows-based one is called PuTTY and can be downloaded here.  Just open up PuTTY and type in the hostname (or IP address) of your NAS box.  In most cases, you should leave the port to 22.  You are then presented with a black text screen and asked to login.  Type in “root” and you’ll then be asked for the root password, which should have been set when you first configured your NAS (it is usually “admin”).  If you don’t know it, then you’ll have to contact the manufacturer of your NAS for the default password.

On the next page we walk you through actually implmenting the symbolic links…


Once you’re logged in then you’ll have to navigate using the command prompt.   Simple navigation is similar to DOS, but remember that there are no “drive letters” in Linux as there are in DOS or Windows…   The example below is based on the Synology Diskstation DS409.

In order to create a link, we have to know the full path of the objects we’re linking to.  To see the root shares, type cd / and press Enter.

Type dir and you’ll see all of the root drive objects:

name physical object
volume1 first volume of your NAS’s array
volumeSATA attached eSATA drive
volumeUSB1 drive attached to USB port 1
volumeUSB2 drive attached to USB port 2

 

In my example, I attached an eSATA drive, and I need to explore the folders I want to link to.  Type cd volumeSATA and press Enter.Type cd /volume1 and press Enter.  You’ll see there’s a “satashare” share.  Type cd satashare and press Enter.  You’ll now see all of the folders you have created.


Using PuTTY to create symbolic links in our system-created “video” share

Type dir and notice that you’ll see all of your default shares.  Note that there’s a “video” share.

Type cd video and press Enter.

Type dir and you’ll see the existing folders for your videos.

Now that we know the paths to the two directories we’re linking to, it’s time to create the symbolic link.  The syntax is as follows:

ln -s source_file link_name

To make “Movies” appear in the “videos” share (and thus be crawlable by the UPNP server), we type:

ln -s /volumeSATA/satashare/Movies /volume1/video/Movies and press Enter

To make “TV Shows” appear in the “videos” share we type:

ln -s /volumeSATA/satashare/”TV Shows” /volume1/video/”TV Shows” and press Enter (note that any objects with spaces must be enclosed with quotation marks)

If you type dir then you’ll see the symbolic link objects (e.g. Movies -> /volumeSATA/satashare/Movies)

Do the same thing if you want to cross-reference any video and music files.  This way you can have the same file appear in multiple genres without unnecessary file duplication.

You can now go to the UPNP section of your NAS and re-index your media.  It might take a while, but once it’s done you’ll see all of the media on your external drive on your UPNP client.


Symbolic links successfully created

There are a few caveats to this workaround, however.  If you navigate using Windows Explorer, then you’ll get an “access denied” if you click on a symbolic link object.  In order to move files to and from your additional drive, you must bypass the symlink and connect to the actual source of the files (map a drive to //diskstation/satashare).  Many NASes also automatically index any new files added to the “video” share.  If you plop a file directly to the external drive (and it doesn’t show up) then you may have to re-index your media files in order for it to appear on your client.

On the next page we discuss other options you might want to consider…


The method in this guide may not actually be for you.  If you have an extra $400 or so laying around then by all means go ahead and buy four new 1.5TB hard drives and upgrade volume1.  That way you won’t have to deal with any of the aforementioned caveats.  While the QNAP and Synology devices do support expansion of RAID5 arrays, it can be a long and tedious process.  It may actually be easier (and quicker) to back up your existing data, create a new array, and restore your data back.

Some people are even scared of RAID 5 arrays nowadays.  There is such as thing as an “unrecoverable read error” (URE) that could in theory make rebuilding a RAID 5 array impossible, losing all of the data in the array.  All hard drive manufactuers guarantee a certain amount of reliability of any data written, and this statistic is referred to as URE.  Once a bit is written, then one in every 1014 (100,000,000,000,000 or one hundred trillion) reads could be “unrecoverable”. Enterprise-class drives generally have a better URE rating, usually 1015 (one quadrillion) or better, thus their extra cost.


An inexpensive external drive can be a cheaper solution to expand your digital media library

The short of it is this: if a drive fails, a RAID 5 array will continue to function by calculating parity.  When you go to rebuild, one of your other drives could misread something and return invalid data (the drive may not be “bad” but just can’t read a particular part of your data).  If this happens during rebuilding then the entire build could halt.  The larger the hard drives in your array translates into longer rebuild times and more data that could be potentially corrupted.

I know some RAID Nazis that will never use RAID5 or terrabyte hard drives because of this phenomena, but if your NAS is just housing music and videos then it is really overkill to be worried about this.  This is the reason to have quality backups.  Not only do I backup everything to BluRay media before it goes on the NAS, but I back up the important stuff every night.  Even if I did encounter a URE then the worst thing that would happen is I would replace some hard drives, rebuild the array and restore my data.  Easy Peasy.

I hope this article has helped you get the most of your NAS device.  Linux-based appliances can be really flexible and powerful if you know how to use them, and getting the most out of external drives is a cost-effective means of expanding your NAS’s digital library.

Related posts

FSR 4.1 Black Flag Resynced | Driver Update Disaster

The Steam Leveling Trick Nobody Knows

This DualSense PC Controller Setup Replaces Steam Controller

1 Comment

Synology NAS April 28, 2012 - 2:14 pm

I've tried doing this but is messes up my Playstation. Now I have 2 "TV Shows" directories, and only one of them is live… the original one shows what USED to be there… like it was cached or something.

Add Comment