Creat a User Share Containing a Portion of Another User Share


Frank1940

Recommended Posts

Over the years, there have been inquiries about setting up a separate User Share which contains only a portion of another User Share.  In the past, the standard answer has been, "There is not a way to do that" or words to that effect.  Recently, in another thread, a query about doing this,  @tjb_altf4 suggested using a symbolic link.  The OP, @Prawcess, for that thread did some research, tried it, and said it did work.  

 

Since no details were provided, I decided to do some experimenting on my own.  I began by googling   Linux symbolic link directory     and found many articles about implementing a Symbolic Link that involved the use of the Linux  ln -s  command. I also got it to work without any real difficulty. While I am not Linux Guru, I realize that many Unraid users are very gun-shy to undertake command line operations without a step-by-step guide. 

   

First create a new share (named   SymLinkShare  in this case). You can use the GUI to do this under the SHARES tab. Set up the share for export and sharing.  (As a bit of disclosure, since I was working on my Test Bed server, I actually emptied out an old test share and renamed it.)

Then I used the following command line in the Unraid terminal window:

ln -s /mnt/user/RoseMediaTest/I /mnt/user/SymLinkShare

Where:

      /mnt/user/RoseMediaTest/I   -------> is the path to the directory (  I  ) within another User Share ( RoseMediaTest ) that is wanted as the root for the linked share.

     /mnt/user/SymLinkShare       -------> is the path to the newly created share

 

Everything that I have try to do on my linked share has worked--

  • Copy files to it.
  • Copy files from it.
  • Rename a file.
  • Delete a preexisting file.
  • Open a file using the default application.
  • Edit a file and save it back.   

 

One thing that is different is that the Symbolic Linked Share will only use the 'cache' if the original Share is setup to use the cache drive.  In fact, the directory tree created on the cache drive is for the original Share when the copy is being made to the Symbolic Linked Share.  Since it is standard, the Unraid Mover script worked normally.

 

What are the disadvantages to using a Symbolic Linked Share?  A Symbolic Linked Share is a 'Backdoor' to the inside of another Share.  It could easily be a security issue/problem. I verified that I could write to the Symbolic Linked Share via SMB even when that SMB user does not have any access privileges to the original Share that the Link is pointed to!  (I am not set up to test what happens with NFS...) Be very aware if you do this, the permissions you give to the various users can give those users permission to modify/rename/delete the original files in the other Share!!!!  Remember that there is only one physical set of files/directories and these files/directories can be changed from either Share. My suggestion would be to make only one of the Shares be 'read-write' and the other Share be 'read-only' but that decision is strictly up to the server administrator.  

 

You may be wondering why I am posting up this Guide. There have been inquires in the past for a way to be able to do what a Symbolic Linked Share will do and the response has been "it is not possible".   I hate to know that there is a way when someone asks how to configure their Unraid server to work the way they need it to and say "No, it is not possible".  My observation is that there are always going to be problems or issues with any workaround solution.  If you are comfortable with these, then use the workaround!

 

If you find something that is a problem or have a concern that I have overlooked, please post it up in this thread.  


At this point, I want to show the output of the Linux  ls -al   command when it displays a symbolic link depending on how the path to that link is specified.

root@Rose:~# ls -al /mnt/user/SymLinkShare
total 0
drwxrwxrwx 1 nobody users   6 Apr 10 12:32 ./
drwxrwxrwx 1 nobody users 116 Apr 10 12:58 ../
lrwxrwxrwx 1 root   root   25 Apr 10 12:32 I -> /mnt/user/RoseMediaTest/I/

 

root@Rose:~# ls -al /mnt/user/SymLinkShare/I
lrwxrwxrwx 1 root root 25 Apr 10 12:32 /mnt/user/SymLinkShare/I -> /mnt/user/RoseMediaTest/I/

 

root@Rose:~# ls -al /mnt/user/SymLinkShare/I/
total 87842328
drwxrwxrwx 1 smbuser users           6 Apr 10 13:23 ./
drwxrwxrwx 1 nobody  users          15 Dec  5  2021 ../
-rw-rw-rw- 1 smbuser users      216078 Dec  6  2021 Isn't_It_Romantic-poster.jpg
-rw-rw-rw- 1 smbuser users       60514 Aug  8  2019 Isn't_It_Romantic.TAG
....


Notice that the command   (  ls -al /mnt/user/SymLinkShare/I  ) only shows the symbolic link that stored at that location.  
Whereas,  the command  ( ls -al /mnt/user/SymLinkShare/I/  )--- notice the final '    ' --- shows the files/directories stored at the location where the symbolic link is pointing.  (If you know why Linux behaves this way, you can count yourself as a Linux Guru!)

Edited by Frank1940
  • Like 2
Link to comment
  • 1 month later...

If you are wondering how to remove a symbolic link, I would suggest starting by Googling---    Remove a Symbolic Link in Linux      and you will find links such as the following one:

 

       https://linuxhint.com/remove-symbolic-link-linux/

 

DISCLOSURE: I have not removed the symbolic link that I set up using the procedure described in the first post but I do have some thoughts on the process. 

 

First thing, all the directions that I have seen assume that you are in the directory where the link is at.  So you will need to use the Linux  cd   command to change to the proper directory,  and after using that command, you should check that you are in the right directory by using the    pwd    command.

 

Second thing, notice the warning that a tailing back-slash---   /    ---can change what happens with the both commands.

 

Third thing, I, personally, would only use the  unlink  command.   The   rm    command is one that I know can be extremely destructive!  (I suspect that using the tailing back-slash after the name of the symbolic link will remove the files and directories that the symbolic link points to rather than the link itself.)

  • Like 1
Link to comment
  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.