Page 1 of 1

Combine QNAP shared folders into one share for easy access

Combine QNAP shared folders into one share for easy access
   27

Those of us who use a NAS like those awesome QNAP devices possibly recognize this situation:

You have a lot of shared folders, but as an Admin you’d like to access them all from one single share, so instead of mounting an X number of “drives”, you mount just one.

When looking at the directory structure on your QNAP, this could be the “root” of all your shares, but opening this as a shared folder comes with it’s own set of little issues. Using the QTS 4.x function called “Shared Folder Aggregation” doesn’t work all that well either, and even worse: it’s limited so Samba shares.

Instead I’ll show you a way to do QNAP Shared folder aggregation with symbolic links

Note : This makes moving files between shares also significantly faster … no matter how big the file!




Combine QNAP Shared Folders into one Share

The goal of this article is to combine QNAP Shared folders into one share, so we end up with an additional shared folder on your QNAP, which provides access to all or some of your existing shares. Your existing shares will not be changed, we just add one single entry point.

The main purpose (for me anyway) is that I, as Admin, only have to mount one share on my Mac, or in Windows terms that I only have to map one drive, providing access to all shares on my QNAP. Yet at the same time keep the existing shares in-tact, so that other users still can be limited in what shares they can access if needed.

To accomplish this we will use symbolic links …

QTS build-in QNAP Shared Folder Aggregation

If you payed attention to the details of your QNAP setup, then your first response will be: “But what about the build-in Shared Folder Aggregation?”.

I’ve played with this function and even though it adds some great futures, including adding shares on different servers, it does come with it’s limitations as well. For example: it only works for SMB (Samba) shares.

A great option of this function however, is the ability to combine with shares on different servers.

For our purposes the use of symbolic links just works easier …

Creating the Combined Shared Folder

Step 1 – Create a new Share

First we need to create a share that will hold the other shares.

On your QNAP, go to the web-interface and open “Control Panel“.

Go to “Privilege Settings Shared Folders Create Shared Folder“.

Complete the field “Folder Name” (I used “AllShares”) and optionally the field “Description” (I entered “Share with Symbolic Links to the other shares”, up to you what you want to write here, or leave it blank).

I called my new share “AllShares”, but you can of course use another name if you’d like. I’d avoid spaces and special characters though. Keep in mind that in the rest of the article I’ll be using the name “AllShares”, replace this name in the examples with your share name.

QNAP - Create a new Share

QNAP – Create a new Share

User Privileges of your shares … 

Please keep in mind that the user(s) that have access to this new share (AllShares) should also have access rights to the shares we will soft link to this new share.

Optionally change the “Configure access privileges for users“, for example if you want to add another user to have access besides the admin. By default only the admin has read/write access, and access for all other users is denied.

Als optional is changing the settings under “Advanced Settings” where the default settings are:

  • Deny Guest access
  • Folder not hidden for Windows networks
  • Oplocks enabled
  • Automatic selection of the path of this shared folder

 

Once you’ve entered all settings, click the “Create” button.

Step 2 – Creating Symbolic Links

This step is where we link the other shares into our new share.

  I called my share “AllShares”, replace this name with the name you used if needed.

To create symbolic links to our other shares, we will need to use SSH to get access to the shell of your QNAP. Read our SSH article on how to do this, just make sure SSH is enabled on your QNAP (“Control Panel Network Services Telnet / SSH“, check “Allow SSH Connection” and optionally check “Enable SFTP” – don’t forget to click the “Apply” button).

What is a Symbolic Link? 

A symbolic link, also called “Soft Link”, is much like a Shortcut in Windows or an Alias under MacOS X.

Unlike a “Hard link”, a symbolic link does not contain the actual data, but instead just points to the location where the actual data is. When you delete te file or directory a symbolic link points to, then the symbolic link will no longer work.

When you have a symbolic link to a directory, changes to the contents of the original directory will immediately be reflected when you open the symbolic link, since it points to the original.

See also: Symbolic Link Wiki

A symbolic link for a file, under Linux, is created with the following statement:


ln -s source_file new_link_file

This works the same for a symbolic link to a directory, where “source_file” is the original file or directory and “new_link_file” is the symbolic link you just created (which can be anywhere on your filesystem).

I wanted to have a link to all shares, but you can of course limit your selection to the shares you care for.

First thing is to get into an SSH connection to your QNAP, which is typically done (Linux/MacOS X) from a shell using   ssh admin@192.168.1.100  where 192.168.1.100 should be the IP address of your QNAP. Windows users can use an application like “PuTTY“.

On most QNAP’s the shares will be found in   /share/.

The shares (you’ll recognize the names) here however are already symbolic links, and we’d rather link to the original files. To find the original files, use:


1
2
cd /share
ls -l

You will see a pretty wide out put, so you might need to make your window wider to see all the details. An example output (shortened: i removed a few lines to keep things readable) can be found below.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
lrwxrwxrwx    1 admin    administ        18 May 26 07:48 AllShares -> MD0_DATA/AllShares/
lrwxrwxrwx    1 admin    administ        21 May 26 07:48 Applications -> MD0_DATA/Applications/
lrwxrwxrwx    1 admin    administ        20 May 26 07:48 Development -> MD0_DATA/Development/
lrwxrwxrwx    1 admin    administ        18 May 26 07:48 Documents -> MD0_DATA/Documents/
lrwxrwxrwx    1 admin    administ        17 May 26 07:48 Download -> MD0_DATA/Download/
drwxrwxrwx    2 admin    administ      1024 Sep 18  2005 HDA_DATA/
drwxrwxrwx    2 admin    administ      1024 Dec  7  2005 HDB_DATA/
...
drwxrwxrwx    2 admin    administ      1024 Dec  7  2005 HDY_DATA/
drwxrwxrwx    2 admin    administ      1024 Dec  7  2005 HDZ_DATA/
drwxrwxrwx   41 admin    administ      4096 May 26 07:48 MD0_DATA/
lrwxrwxrwx    1 admin    administ        19 May 26 07:48 Multimedia -> MD0_DATA/Multimedia/
lrwxrwxrwx    1 admin    administ        28 May 26 07:48 Network Recycle Bin 1 -> MD0_DATA/Network Recycle Bin/
lrwxrwxrwx    1 admin    administ        15 May 26 07:48 Public -> MD0_DATA/Public/
drwxr-xr-x    2 admin    administ      1024 May 24 09:59 Qsync/
lrwxrwxrwx    1 admin    administ        19 May 26 07:48 Recordings -> MD0_DATA/Recordings/
lrwxrwxrwx    1 admin    administ        18 May 26 07:48 USBDisk1 -> external/DEV3406_1/
lrwxrwxrwx    1 admin    administ        12 May 26 07:48 Usb -> MD0_DATA/Usb/
drwxrwxr-x   30 admin    administ      1024 May 24 03:56 external/

In this example you will see the actual locations. For example the share “Download” is displayed as located in  MD0_DATA/Download/ . This is however relative to the /share/ directory, so the path to the Download share is actually:  /share/MD0_DATA/Download/ .

When looking at all the output, we now see that all shares on this QNAP reside in  /share/MDO-DATA/ . This is good to know, as we will need it to create the symbolic links.

In this list we can also see what shares exist, but you can also see them in the QNAP web-interface (“Control Panel Privilege Settings Shared Folders“):

QNAP - List of shares in the web-interface

QNAP – Shares in the web-interface

Now that we know all this, time to create the symbolic links for the shares we’d like to aggregate into one folder.

First, go to the new share we just create, it’s actually the first one in the previous “ls -l” output: /share/MD0_DATA/AllShares .

Use the following statement to go there (change the path if yours was different):


cd /share/MD0_DATA/AllShares/

Next we need to execute the symbolic link statement for each share we’d like to create a symbolic link. For example:


1
2
3
4
5
6
7
ln -s /share/MD0_DATA/Applications Applications
ln -s /share/MD0_DATA/Development Development
ln -s /share/MD0_DATA/Documents Documents
ln -s /share/MD0_DATA/Download Download
ln -s /share/MD0_DATA/GoogleDrive GoogleDrive
ln -s /share/MD0_DATA/Multimedia Multimedia
ln -s /share/MD0_DATA/Projects Projects

After executing this, you’d see something like this after doing an “ls -l”:


1
2
3
4
5
6
7
8
ls -l
lrwxrwxrwx    1 admin    administ        28 May 26 08:40 Applications -> /share/MD0_DATA/Applications/
lrwxrwxrwx    1 admin    administ        27 May 26 09:15 Development -> /share/MD0_DATA/Development/
lrwxrwxrwx    1 admin    administ        25 May 26 09:17 Documents -> /share/MD0_DATA/Documents/
lrwxrwxrwx    1 admin    administ        24 May 26 09:17 Download -> /share/MD0_DATA/Download/
lrwxrwxrwx    1 admin    administ        27 May 26 09:18 GoogleDrive -> /share/MD0_DATA/GoogleDrive/
lrwxrwxrwx    1 admin    administ        26 May 26 09:18 Multimedia -> /share/MD0_DATA/Multimedia/
lrwxrwxrwx    1 admin    administ        24 May 26 09:18 Projects -> /share/MD0_DATA/Projects/

Rinse and repeat for all the share you’d like to see in you aggregated directory.

After completing these steps, open the share on your Windows, MacOS X or Linux machine and you’ll see that the directories in this share go straight to the content of the shares you created a symbolic link for.

 

Special thanks to Don at the QNAP Forums.

Donation options


Donations are very much appreciated, but not required. Donations will be used for web-hosting expenses, project hardware or a motivational boost (a drink or snack). Thank you very much for those have donated already! It's truly AwEsOmE to see that folks like our articles and small applications.

Comments


There are 27 comments. You can read them below.
You can post your own comments by using the form below, or reply to existing comments by using the "Reply" button.

  • Jun 30, 2014 - 10:15 AM - Chris Comment Link

    Thank you for this hands-on manual!

    Reply

    Chris

    • Jun 30, 2014 - 8:46 PM - hans - Author: Comment Link

      Thanks Chris! 

      Always nice to hear when someone appreciates one of my articles, and I’m glad it proved helpful for you!

      Reply

      hans

  • Sep 4, 2014 - 12:33 PM - A Whittall Comment Link

    Don,

    Thank you this is perfect, exactly what I need.

    I presume it is working because when I access my Share via SMB (Mac OS X 10.9.4), everything traverses normally. However, the same share via AFP shows a link/alias in Mac Finder.

    I’m sure there is a setting that I can change to force the Mac/AFP shares to recognise/follow symlinks: any suggestions? I have the correct ownership/permissions on the symlink, that is the limit of my guessing.

    Thanks again,

    Andrew

    Reply

    A Whittall

    • Sep 8, 2014 - 5:05 AM - hans - Author: Comment Link

      Hi Andrew,

      I’ll honestly admit that I abandoned AFP – I don’t like seeing 2 shares (SMB and AFP) of the same thing in the Finder. I also understand that in the next generation(s) Apple will abandon AFP as well. Although I’m curious how they resolve issues with Time Machine when they do so.

      I just tried using AFP, and I had no issues following the links. However: I’ve used AFP with these shares in the past where I indicate “login as” (so it wouldn’t use “guest” as the default users for these shares). I see on my Mac (MacOS X 10.10 beta 5) that it instantly mounts this share. Again not something I’d like. So I stick with SMB. Spotlight searches do not seem to work on either anyway and I can’t really say that one is faster than the other 

      Reply

      hans

  • Jul 1, 2015 - 9:28 AM - Johnny Comment Link

    This looks a bit complicate and not sure if it fits what I want.

    I have 2 website, namely a.com and b.com. I can setup the virtual host in qnapT219 successfully.

    Their folders are /qweb/a and /qweb/b.

    However, there is a folder /qweb/pic that both websites’ php program need to retrieve pictures from.

    The “../..” in php is not working as both of them reach their “root/home” directories already, and not allow to go one level up.

    Can someone please help me? Thank you very much.

    Reply

    Johnny

    • Jul 2, 2015 - 2:03 AM - hans - Author: Comment Link

      Hi Johnny,

      I have to get back on this one – if I recall correctly, qweb is only used for the “small” webserver, where as Apache would use a different folder (and work better). But I could be wrong, I have to unpack my QNAP first before I can confirm this. (I’m in the middle of moving from the US to Europe)

      Reply

      hans

    • Jul 6, 2015 - 2:58 AM - hans - Author: Comment Link

      It’s taking a little longer than expected … don’t think I forgot though …

      One thing I was wondering about though … why do they need a fixed (and shared) folder? Or is this done intentionally?
      You’re jumping outside of the virtual webserver to go to another one, so I can totally imagine that this will not work.

      3 thoughts:

      1) Make a symbolic link to the “/qweb/pic” directory in “/qweb/a” and “qweb/b” … not sure if this will work, but worth a try.

      In the commandline execute:

      ln -s /qweb/pic /qweb/a/pic
      ln -s /qweb/pic /qweb/b/pic

      This will make a symbolic link (aka reference) to the /qweb/pic directory in your /qweb/a and qweb/b directories. So whatever happens in /qweb/pic will be visible in /qweb/a/pic and /qweb/b/pic. In your PHP/HTML/Javascript you can now simply refer to the pic folder in /qweb/a or /qweb/b.

      2) Place the pic folder in (for example) /qweb/a and for website /qweb/b refer to website a.

      3) Duplicate the pic folder in both /qweb/a and /qweb/b – if the content is rather static.

      Reply

      hans

  • Aug 24, 2015 - 7:07 AM - hans - Author: Comment Link

    TIP:

    For easier working/toying with QPKG’s, you could add the QPKG directory to the AllShares as well.

    cd /share/MD0_DATA/AllShares/
    ln -s /share/MD0_DATA/.qpkg/ qpkg
    Reply

    hans

  • Mar 24, 2016 - 9:58 AM - Viktor Comment Link

    Hi

    Followed the steps but after in the mounted folder I dont see the symbolic links at all ( from Mac OS X or Windows side) however under ssh session the links seen inside the folder.

    Im on QTS 4.2.1 on TS-453A

    Anyone managed to make it work?

    Thanks

    Reply

    Viktor

    • Mar 24, 2016 - 10:06 AM - hans - Author: Comment Link

      Hi Viktor,

      I’m at QTS 4.2.0 and it works here.

      A few things I’d check;

      • Does the user, you use to login, have access to the other shares as well? If not, then that might be the culprit.
      • Refresh/reboot your computer – I noticed on my Mac that it sometimes caches a directory. I suspect that the symbolic links should still be visible (try adding an empty text file from SSH and see if that one shows).
      When reading this QNAP Forum topic, I’d say it works for others as well, so you might be overlooking something.

      Reply

      hans

  • Jul 7, 2016 - 3:45 PM - Jimmy Comment Link

    Hi!

    Thank you for this guide!=)

    I have a question:

    After creating the AllShare symbolic link i got infinite loop folders in every folder…everywhere.

    I’v looked around and so far the only solution i could find was to manually remove the symbolic links in terminal (osx), but i can’t figure out how to remove it….

    Any suggestions? =)

    Peace!

    Reply

    Jimmy

    • Jul 8, 2016 - 4:03 AM - hans - Author: Comment Link

      Hi Jimmy!

      I’m confused; did you create the symbolic link though SSH on the QNAP or through Terminal (not SSH) on the Mac?
      The symbolic links should be created with SSH on the QNAP, and if you’d want to remove that one, you’d have to do this through SSH as well.

      Please let me know how you created the symbolic link … 

      Reply

      hans

      • Jul 8, 2016 - 4:54 PM - Jimmy Comment Link

        Hey,

        Sorry for being unclear, i’m a noob of epic proportions;)

        Yeah, i created the symbolic links with SSH on the QNAP and then i kept on following all the steps in your guide.

        All was good.

        Then i removed a unwanted folder in the Qnap Shares page, which was included under the AllShares Symbolic Link, then the AllShares symbolic Link stopped working and my SMB started acting all weird.

        So i removed the AllShared symbolic link in the Qnap Shares page and followed your guide all over again, and that seems to have worked, although thats when the endless folder stuff appeared. To be clear, in every folder (when entering the AllShares folder via SMB in OSX Finder) have a “copy” of it self in itself.

        When opening that i get the endless loop cause it starts to open itself until i close the window. 

        I’m sure i messed something up and i’m very grateful for any advice in the matter=)

        Thanks!

        Reply

        Jimmy

        • Jul 8, 2016 - 4:57 PM - Jimmy Comment Link

          Here is a picture if that helps^^

          Infinityyyyy

          Reply

          Jimmy

        • Jul 9, 2016 - 5:11 AM - hans - Author: Comment Link

          Hi Jimmy,

          your screenshot looks “interesting” to say the least … so something went wrong there for sure.

          I can only guess, but it seems that your “AllShares” has a link to itself in it. Not sure if that is even possible.

          A few things we can check, with SSH to your QNAP:
          cd /share
          ls -l

          should show something like this:

          [/share] # ls -l
          lrwxrwxrwx 1 admin administ 18 Jun 8 17:22 AllShares -> MD0_DATA/AllShares/
          lrwxrwxrwx 1 admin administ 21 Jun 8 17:22 Applications -> MD0_DATA/Applications/
          lrwxrwxrwx 1 admin administ 20 Jun 8 17:22 Development -> MD0_DATA/Development/
          lrwxrwxrwx 1 admin administ 18 Jun 8 17:22 Documents -> MD0_DATA/Documents/
          lrwxrwxrwx 1 admin administ 17 Jun 8 17:22 Download -> MD0_DATA/Download/
          lrwxrwxrwx 1 admin administ 20 Jun 8 17:22 GoogleDrive -> MD0_DATA/GoogleDrive/
          drwxrwxrwx 2 admin administ 60 Jun 7 10:14 HDA_DATA/
          drwxrwxrwx 2 admin administ 40 Dec 7 2005 HDB_DATA/
          drwxrwxrwx 2 admin administ 40 Dec 7 2005 HDC_DATA/
          drwxrwxrwx 2 admin administ 40 Dec 7 2005 HDD_DATA/
          drwxrwxrwx 2 admin administ 40 Dec 7 2005 HDE_DATA/
          ... (etc)

          You should look at the AllShares directory which (in my case) points to “MD0_DATA/AllShares”.

          Next step is:

          cd AllShares
          ls -l

          Which should show something like this:

          [/share/AllShares] # ls -l
          lrwxrwxrwx 1 admin administ 28 May 26 2014 Applications -> /share/MD0_DATA/Applications/
          lrwxrwxrwx 1 admin administ 27 May 26 2014 Development -> /share/MD0_DATA/Development/
          lrwxrwxrwx 1 admin administ 25 May 26 2014 Documents -> /share/MD0_DATA/Documents/
          lrwxrwxrwx 1 admin administ 24 May 26 2014 Download -> /share/MD0_DATA/Download/
          lrwxrwxrwx 1 admin administ 27 May 26 2014 GoogleDrive -> /share/MD0_DATA/GoogleDrive/
          ... (etc)
          lrwxrwxrwx 1 admin administ 19 May 26 2014 Web -> /share/MD0_DATA/Web/
          lrwxrwxrwx 1 admin administ 27 May 26 2014 Web Archive -> /share/MD0_DATA/Web Archive/
          lrwxrwxrwx 1 admin administ 22 Aug 24 2015 qpkg -> /share/MD0_DATA/.qpkg/

          Make sure that none of these directories point to “/share/AllShares/” or  “MD0_DATA/AllShares”.
          If one of these DOES link to either of the 2 AllShares directories, then you should remove those.

          Let me know what you find or run into.

          p.s. we all started knowing little about this stuff, don’t feel bad about it. 

          Reply

          hans

  • Sep 3, 2016 - 10:06 AM - Colin Comment Link

    Hi,

    I have a TS-251+, 4.2.1. I am trying to add my USB device which I am using for pt download into Multimedia Management.

    I do as what you said.

    After that, I could find USBDisk1 folder under Allshare. But I still can’t use Music Station to play music files in USBDisk1.

    Could you provide me more help?

    Many thanks. 

    [/share] # cd /share/CACHEDEV1_DATA/Allshare
    [/share/CACHEDEV1_DATA/Allshare] # ln -s /share/external/DEV3301_1 USBDisk2
    [/share/CACHEDEV1_DATA/Allshare] # ls -l
    drwxrwxrwx    2 admin    administ      4096 Sep  3 15:47 @Recycle/
    lrwxrwxrwx    1 admin    administ        25 Sep  3 15:54 USBDisk2 -> /share/external/DEV3301_1/
    Reply

    Colin

    • Sep 4, 2016 - 10:34 AM - hans - Author: Comment Link

      Hi Colin,

      well, first thing I noticed with USB drives is that they do not always mount equally consistent. That aside, I do not use Music Station, so I actually had to Google it haha (sorry). As far as I can see (mind you: I’m traveling and do not have access to my QNAP), Music Station likes to use the “music” share. So what you could try is …

      cd /share/music
      ln -s /share/external/DEV3301_1 USBDisk2

      This way, Music Station might pick it up as a regular directory in the music share.

      Reply

      hans

  • Oct 19, 2016 - 6:09 PM - John Vance Comment Link

    This is clever and great for access from Finder/Explorer, but it seems this won’t work when doing rsync, at least to a FreeNAS box. It just rsyncs the symlink.

    Reply

    John Vance

    • Oct 20, 2016 - 8:40 AM - hans - Author: Comment Link

      Hi John,

      I have not played with FreeNAS (yet). 

      I would assume this cannot be used for rsync on QNAP either – like you said it would copy the symbolic link, but not the actually files. Unless you use the “-L” parameter with rsync, then it should follow the symbolic link – I have not tested this (see rsync man page).

      Reply

      hans

  • Nov 18, 2016 - 6:19 AM - Andras Kiss Comment Link

    Hi Dan,

    your step-by-step guide was very useful, and the result was almost perfect, but… :)

    I have folder names with space in it, and I think it made some trouble (maybe I had to use”_” insted of space in the folder names, when I generated the links). I don’t know linux at all, so I can just follow your instructions. Could you please help me, how to delete, or edit this existing links?

    Thanks for advance: Andras

    Reply

    Andras Kiss

    • Nov 18, 2016 - 7:37 AM - hans - Author: Comment Link

      Hi Andras,

      Thanks for the compliment! 

      As for spaces in file or directory names, you can use an escape sequence. This is done with a backslash (\).
      For example:

      Is the directory is called “My Directory” then you can either place quotes around the whole path, or type:

      My\ Directory

      So for removing the link to “My Directory” this would be:

      rm My\ Directory

      Hope this helps 

      Reply

      hans

      • Nov 18, 2016 - 7:39 AM - hans - Author: Comment Link

        p.s. an alternative would be:

        rm "/path/to/My Directory"

        or

        rm '/path/to/My Directory'

        (you can use single or double quotes, as long as the first and the last quote are of the same kind)

        Reply

        hans

  • Dec 21, 2016 - 2:21 PM Comment Link
    PingBack: hblok.net

    […] if using only Windows machines to connect to the shares, there is the option of combining multiple shares into one. However, if other OSes also connect, you probably want to skip […]

  • Dec 27, 2016 - 7:38 AM - VA- Comment Link

    Hi Don.

    when i create a link >  ln -s /share/MD0_DATA/…

    how can i unlink the specific folder?

    Reply

    VA-

    • Dec 27, 2016 - 8:04 AM - hans - Author: Comment Link

      Hi VA,

      say you created the links as such:

      ln -s source_file new_link_file

      Then with “rm” you can remove the linked file (new_link_file) as such:

      rm new_link_file

      Hope this helps!

      Reply

      hans

      • Dec 27, 2016 - 2:55 PM - VA- Comment Link

        Thank you very much Don !
        Everything works perfectly

        …greetings from Serbia.


        Reply

        VA-

        • Dec 27, 2016 - 3:37 PM - hans - Author: Comment Link

          Awesome!! 

          Greetings and best wishes for 2017 from a Dutch guy in Houston ….

          Reply

          hans



Your Comment …

Friendly request to not post large files here (like source codes, log files or config files). Please use the Forum for that purpose.

Please share:
*
*
Notify me about new comments (email).
       You can also use your RSS reader to track comments.


Tweaking4All uses the free Gravatar service for Avatar display.
Tweaking4All will never share your email address with others.