ONTAP Discussions

Highlighted

Create parent directories for a junction path using the CLI

Hi,

I'm trying to mount a volume on a deep hierarchy.  For example: /a/long/mount/path/vol1.

If I use vserver setup -vserver vserver1 -storage I can create this long junction path, but I don't want to use the interactive wizard.

Without mounting the root volume from a client, how do I create the parent directories on the vserver root volume?

Cheers,

Greg

19 REPLIES 19
Highlighted

Re: Create parent directories for a junction path using the CLI

Create a new 20MB volume and mount it to /namespace.

Then mount all of your volumes under that.

So they would be /namespace/volname.

Highlighted

Re: Create parent directories for a junction path using the CLI

Mount command should create the full path

Sent from my iPhone 5

Highlighted

Re: Create parent directories for a junction path using the CLI

Thanks for the quick response.  Although what you propose will work, I don't want to waste my valuable number of volumes creating mount points.  I'm sure that there is a cleaner way to do this.

Highlighted

Re: Create parent directories for a junction path using the CLI

System manager creates a vol folder under the root vol that could be used.

Otherwise, you're stuck with mounting the vsroot and adding the folder manually.

Highlighted

Re: Create parent directories for a junction path using the CLI

I'm afraid that I already tried this:

cluster1::*> volume mount -vserver vstor-001 -volume vol3 -junction-path /a/long/junction/path

                                                                                                                                                    

Error: command failed: Failed to create or determine if a junction exists within volume 'rootvol1'. Error occurred with the remaining junction

       path of '/a/long/junction/path' for the given path of '/a/long/junction/path'  Reason: Junction create failed (2).

Highlighted

Re: Create parent directories for a junction path using the CLI

Yep, the path has to exist.

Highlighted

Re: Create parent directories for a junction path using the CLI

That can't be the only way.  The vserver setup command will create parent paths as deep as you want:

cstor-001::*> vserver setup -vserver vserver1 -storage

Welcome to the Vserver Setup Wizard, which will lead you through

the steps to create a virtual storage server that serves data to clients.

You can enter the following commands at any time:

"help" or "?" if you want to have a question clarified,

"back" if you want to change your answers to previous questions, and

"exit" if you want to quit the Vserver Setup Wizard. Any changes

you made before typing "exit" will be applied.

You can restart the Vserver Setup Wizard by typing "vserver setup". To accept a default

or omit a question, do not enter a value.

Step 1. Create a Vserver.

You can type "back", "exit", or "help" at any question.

Choose the Vserver data protocols to be configured {nfs, cifs, fcp, iscsi} [nfs]:

Choose the Vserver client services to be configured {ldap, nis, dns}:

Vserver vserver1's allowed protocol list has been modified to nfs

Step 2: Create a data volume

You can type "back", "exit", or "help" at any question.

Do you want to create a data volume? {yes, no} [yes]:

Enter the volume name [vol1]:

Enter the name of the aggregate to contain this volume {aggr1_stor001, aggr1_stor002, aggr1_stor003, aggr1_stor004} [aggr1_stor002]:

Enter the volume size: 2G

Enter the volume junction path [/vol/vol1]: /this/junction/path

It can take up to a minute to create a volume...

Volume vol1 of size 2GB created on aggregate aggr1_stor002 successfully.

Do you want to create an additional data volume? {yes, no} [no]: no

cstor-001::*> volume show -fields junction-path

vserver  volume junction-path

-------- ------ -------------          

vserver1

         vol1   /this/junction/path

I'm pretty sure that the vserver setup wizard doesn't mount the volume and create a directory, so it must be doing something that creates directories on the rootvol.

Highlighted

Re: Create parent directories for a junction path using the CLI

Yep, it creates folders in the root vol.

That seems like a valid workaround for what you'd want to do.

You can re-run vserver setup on the same vserver at any time without worrying about losing stuff.

Highlighted

Re: Create parent directories for a junction path using the CLI

The problem is that it's a workaround.  I don't want this to be interactive.  All I want to know is the magic behind the vserver create wizard that creates directories in the rootvol.

Highlighted

Re: Create parent directories for a junction path using the CLI

The vserver setup command is using ZAPI calls. There is a ZAPI that allows folder creation, but no commands that I know of.

I'd suggest opening a support case and having the engineer file an RFE for this. Sounds like it could be a useful feature.

In the meantime, we have an SDK that might allow you to do what you want (though I prefer the apitest found with DFM/OnCommand). The ZAPI call is "file-create-directory."

Example:

[root@nfsv4-host /]# mount 10.61.100.102:/ /mnt

[root@nfsv4-host mnt]# ls | grep testdir

[root@nfsv4-host mnt]#

::*> vol create -vserver win2k8 -volume testdir -aggregate aggr2 -size 20MB -state online -type RW -policy default -junction-path /testdir/testdir

  (volume create)

[Job 7026] Job is queued: Create testdir.

Error: command failed: [Job 7026] Job failed: Volume created successfully but not mounted. Reason: Failed to create or determine if a junction exists within volume 'root'. Error occurred with the

       remaining junction path of '/testdir/testdir' for the given path of '/testdir/testdir'  Reason: Junction create failed (2).

C:\Program Files\NetApp\DataFabric Manager\DFM\bin>apitest -t filer -h 10.61.100.100 -u vsadmin -p XXXXXXXX file-create-directory path /vol/root/testdir perm 0777

Testing: file-create-directory(path=/vol/root/testdir, perm=0777) Success (0.047 seconds)

[root@nfsv4-host mnt]# ls -la | grep testdir

drwxrwxrwx  2 root unixadmins     4096 Mar 19 10:32 testdir

::*> vol create -vserver win2k8 -volume testdir -aggregate aggr2 -size 20MB -state online -type RW -policy default -junction-path /testdir/testdir

  (volume create)

[Job 7028] Job succeeded: Successful

::*> vol show -vserver win2k8 -volume testdir -fields junction-path

  (volume show)

vserver volume  junction-path

------- ------- ----------------

win2k8  testdir /testdir/testdir

I can also create directories inside of the directories:

C:\Program Files\NetApp\DataFabric Manager\DFM\bin>apitest -t filer -h 10.61.100.100-u vsadmin -p XXXXXXXX file-create-directory path /vol/root/testdir/testdir2 perm 0777

Testing: file-create-directory(path=/vol/root/testdir/testdir2, perm=0777) Success (0.313 seconds)

So you could get creative... or open a case and ask for an RFE.

Highlighted

Re: Create parent directories for a junction path using the CLI

Thanks for your response.  This is what I was expecting.

I'll certainly create that RFE.

Thanks again.

Highlighted

Re: Create parent directories for a junction path using the CLI

I was at customer site and we had to tweak the apitest syntax in order to get it to work.


apitest -t filer -v <SVM_NAME> -s <CLUSTER-NAME> admin <PASSWORD> file-create-directory path /vol/<SVM_ROOT_VOL_NAME>/<FOLDER1> perm 0777

Highlighted

Re: Create parent directories for a junction path using the CLI

Thank you for posting...did you use OnCommand 5.2 ?  This might be a good reason to have an older DFM install along with 6 to get this functionality for systems without a NAS protocol to mkdir.

Highlighted

Re: Create parent directories for a junction path using the CLI

We used the apitest.exe from the NetappSDK. The version of apitest was 5.2.1r1.

Highlighted

Re: Create parent directories for a junction path using the CLI

Right. The syntax with the DFM apitest vs the SDK will differ. Good find though!

Check out the KB!
Knowledge Base
All Community Forums