How Symlinks boost productivity!
2017-03-03 03:36 AM
Almost every Company has different Departments, most of the Departments have their own folder in the central file share. In the folder of the Departments you find a lot of different subfolders, so for example there is one for Project X, another with pictures of the last xmas Party and a lot more. The employee knows about the folder structure in his Department, but when he looks for another Project, he must know where to search for. That’s why we create a global matrix view for all Departments on a centralized file share. And with this new view, we can boost up our productivity and for the Head of the departments it’s also easier to get a global view of all the folders/Projects.
Our challenge was, that we have a lot of sales reps, every one of them has its own folder in our central file share. In their folders, they use for every customer a new folder. So, for example, we have a folder called Peter (sales rep), in this folder we have for every customer a new folder. We end up with a folder structure as depicted below.
Now the challenge we had, was to create a global view of all the customers. Every salesperson knows his customers, but for all the other people, it was difficult to find the customer. We decided to use symlinks to create a matrix view of all the customers. We started with a new top level folder called _accounts, under which we created a folder for every letter in the alphabet. In the corresponding folder, symlinks point to the original customer folder under the corresponding sales person.
How to start with Symlinks?
I suppose there is a running NetApp environment with a storage virtual machine (SVM) configured for cifs. I used a rather old version (8.2) to test it, but it will also work with newer versions. So first, you must enable the symlink properties on the SVM. There you have different possibilities, I choose “symlinks_and_widelinks”
cluster::> vserver cifs share modify -vserver svm-demo-cifs -share-name cifs-demo -symlink-properties symlinks_and_widelinks
After that, I like to verify my symlink settings on the SVM. So, with the following command, it’s possible to check if the symlink settings are right.
cluster::> vserver cifs share show -vserver svm-demo-cifs -share-name cifs-demo –instance
You get the following output, where you can see that the symlink properties are correct.
Now you’re almost ready to create some symlinks. Before we start, you also must activate nfs on the cifs share, so that you can mount the cifs share over nfs on a Linux machine.
With the following command, you add the nfs protocol to the existing SVM:
cluster::> vserver add-protocols -vserver svm-demo-cifs -protocols nfs
To check and to start nfs, we use the following two commands:
cluster::> nfs status -vserver svm-demo-cifs The NFS server is not running on Vserver "svm-demo-cifs". cluster::> nfs start -vserver svm-demo-cifs
We also must change the security style on the volume, so that we can access the share with a Linux client.
cluster::> volume modify -vserver svm-demo-cifs -volume cifs_demo_CIFS_volume -security-style unix Volume modify successful on volume cifs_demo_CIFS_volume of Vserver svm-demo-cifs.
You also must check the export policy, so that the Linux client has access to the nfs share. I already configured the export policy, but I just want to show you how you can check if the Linux client really has access right. On the output, you can see that the corresponding IP has read-write access to the share.
Now, we are ready to mount the nfs share from our linux client (192.168.xxx.xxx). We do now connect the share using the following command on the linux client:
[linus@linuxBox]$ sudo mount -o v3 192.168.202.20:/cifs_demo_CIFS_volume /mnt/symlinks-demo/
After that, the share is mounted with nfs3 under the folder “symlinks-demo”. So now we are ready to create some symlinks.
How we create some Symlinks with a Linux client
First, I wrote a small Linux bash script, which loops through the folder structure. It creates a link for every folder in Departement1, Departement2 and Departement3 (for example msb, enterprise), except the one with the exclude Signe “_”. If there are other folders with an include Signe “__”, the script will also include these folders. For the script see the attached file. It’s a quick and dirty script, but it does the job. Just want to show you where I create the symlink, I use for that the command “ln –s” with the source path and the destination path.
Just to compare the two folders structure to each other, on the left side you find the original one, on the right side you found the one with the Matrix view. With the Matrix view, you get a nice little overview over all the customers, sort alphabetically.
With the Linux client, you can verify that the symlinks are not widelinks, cd into a created folder, and then use ll to show the symlinks.
How we create some Symlinks with PowerShell
I suppose there is also a running NetApp environment with a storage virtual machine (SVM) configured for cifs only. The requirements for this will be:
- Clustered Data ONTAP 8.3 or later
- Data ONTAP PowerShell toolkit 3.2.1 or later
- 2 volumes
- 2 shares to each of the volumes
First, I will show you, how you can create a Symlink from one share to another share on the same cluster. I have two shares:
they are both located under the cifs server 192.168.202.221.
Now I will create a folder in the share cifs-demojames which will redirect me into the share cifs_demojames_wide. But before, we must check on the NetApp system how the shares configured.
Now we are almost ready. First, we must connect us to the controller.
# connecte to the controller connect-nccontroller 192.168.202.221 <ip_add_OR_HostName_to_SVM_mgmtLIF>
A successful connection.
Now we create the “Folder” (linktowide) which is the link how will redirect us to the other share.
new-ncsymlink –target /something –linkname /vol/cifs_demojames_CIFS_volume/linktowide
The created symlink points us to a non-existent target (/something) the target doesn’t have to exist.
But the link name is important and must exist. Now you know why we checked the share configuration on our NetApp system.
In the share, you will now find a Folder (linktowide), which points to nowhere (/something).
Create a symbolic path mapping to allow the symlink created in the previous step to be usable:
add-nccifssymlink –unixpath /something/ -cifspath / -locality widelink –sharename cifs_demojames_wide
This NetApp Community is public and open website that is indexed by search engines such as Google. Participation in the NetApp Community is voluntary. All content posted on the NetApp Community is publicly viewable and available. This includes the rich text editor which is not encrypted for https.
- Software files (compressed or uncompressed)
- Files that require an End User License Agreement (EULA)
- Confidential information
- Personal data you do not want publicly available
- Another’s personally identifiable information
- Copyrighted materials without the permission of the copyright owner