NetApp : Amending SMB Shares from Shell



I had a requirement to amend a SMB share from the shell today, as I am not one for using the GUI versions, with a shell you get more options and cannot go clicking around, you need to know what you are trying to do, here we needed to add a SMB share to "restricted" mode so users could not write to this share.

Activating Restricted Share Mode

The first of business is to login to the Cluster with SSH for which I usually use puTTY, then once logged in your need to issue this command:

system console

This will get you to the cluster address space, in this example that will be BearClaws-01 then we need to enter privileged mode with the command:

set -privilege advanced

You will get the compulsory warnings with entering this mode, and "yes" we want to continue:

Warning: These advanced commands are potentially dangerous; use them only when
directed to do so by NetApp personnel.
Do you want to continue? {y|n}: y

Then you need to show the current running configuration of your vservers:

vserver show

That will then list them out as below, we are interested in "SMB00"

                               Admin      Operational Root

Vserver     Type    Subtype    State      State       Volume     Aggregate

----------- ------- ---------- ---------- ----------- ---------- ----------
Cluster     system  -          -          -           -          -
BearClaws    admin   -          -          -           -          -
BearClaws-01 node    -          -          -           -          -
BearClaws-02 node    -          -          -           -          -
SMB00       data    default    running    running     SMB00_root aggr1_node1
SMB00       data    default    running    running     SMB00_root aggr1_node2

Then we need to show the shares for "SMB00" with this command:

vserver cifs share show -vserver SMB00

That will then list all the shares as below:

Vserver        Share         Path              Properties Comment  ACL
-------------- ------------- ----------------- ---------- -------- -----------
SMB00          admin$        /                 browsable  -        -
SMB00          Office365$    /Office365_Drive  oplocks    Office   BUILTIN\Admin                                                                                             istrators / Full Control
                                               browsable  365      BUILTIN\Users / Change
                                               changenotify        CREATOR OWNER / Change
                                               show-previous-versions                                                                 
SMB00          users$        /vol_CIFS1        oplocks    HomeDrive
                                               browsable  
                                               changenotify       
                                               access-based-enumeration
                                               show-previous-versions

Now we need to know the volumes on SMB00 with this command:

volume show -vserver SMB00

This will then list all the volumes linked to the shares on SMB00, here we need HomeDrives:

Vserver   Volume       Aggregate    State      Type       Size  Available Used%
--------- ------------ ------------ ---------- ---- ---------- ---------- -----
SMB00     Honey        aggr1_node1  online     RW         10GB     4.89GB   51%
SMB00     HomeDrives   aggr1_node1  online     RW         16TB     6.10TB   61%
SMB00     BearClaws    aggr1_node1  online     RW         24TB     3.10TB   87%
SMB00     Office365    aggr1_node2  online     RW        800GB    777.9GB    2%
SMB00     SMB00_root   aggr1_node1  online     RW          1GB    972.2MB    5%

Next we need to see the status of this share with this command:

volume show -vserver SMB00 -volume Office365_Drive -fields state

That will show the status of the share which be online as its working, but with full access:

vserver volume     state
------- ---------- ------
SMB00   HomeDrives online

We now need to put this share in restricted mode, which means you can read the share but not write to this share, so for that we need this command:

volume restrict -vserver SMB00 -volume HomeDrives

That will then give is a warning about client impact, we need to agree to this to get the share in restricted mode:

Warning: Volume "HomeDrives" on Vserver "SMB00" must be unmounted before
         being taken offline or restricted.  Clients will not be able to access
         the affected volume and related junction paths after that.  Do you
         still want to unmount the volume and continue? {y|n}: y
Volume "SMB00:HomeDrives" is now restricted.

Now if we check the state of the share with this:

volume show -vserver SMB00 -volume HomeDrive -fields state

You will notice is is not restricted:

vserver volume     state
------- ---------- ----------
SMB00   HomeDrives restricted

Disable Restricted Share Mode

If you wish to put this share back in online mode then you can use the command:

volume online -vserver SMB00 -volume HomeDrives

That will then confirm the share is online with this statement:

Volume "SMB00:HomeDrives" is now online.

This will then report as online which you can check with this command:

volume show -vserver SMB00 -volume HomeDrives -fields state

This should indeed confirm the share is online:

vserver volume     state
------- ---------- ------
SMB00   HomeDrives online

However if you try to to access the SMB share you will get an error to say it cannot be accessed, and the reason for this is simple, the restricted mode "dis-mounted" the drive, so all you need to do is remount the drive with this command:

volume mount -vserver SMB00 -volume HomeDrives -junction-path /HomeDrives

Previous Post Next Post

نموذج الاتصال