ONTAP Discussions

Simple 'ls' dir listing in C-MODE

jappereuling
39,650 Views

Hi

 

This might sound trivial (and in some ways it it) but in 7-mode I was able to do an 'ls /vol/vol1' when in the cli on the filer itself. In C-mode the ls command is there via command shell but I cannot find the volumes. Which isn't that strange as the volumes now live in SVM's.

 

But I do have situations where it is helpfull to be able to do a listing of a volume from the CLI. I know I can NFS mount the volume and do an ls but that's just always possible/helpfull etc

 

So the question is "how do I list the content of a volume from the C-Mode cli or the node shell?'

 

Searched the interwebs but seems or a stupid question or a question no one asks 😉

9 REPLIES 9

JamesIlderton
39,630 Views

You have to drop the nodeshell to do this (or run the ls from a nodeshell call).  See this previous article:

http://community.netapp.com/t5/Data-ONTAP-Discussions/ls-command-on-C-Mode/td-p/32593

 

jappereuling
39,614 Views

hi

 

thanks for you reply! But as I stated, i do know the node shell, I do have ls but no volumes.

 

To clarify

 

nac1::*> node run -node fas14a
Type 'exit' or 'Ctrl-D' to return to the CLI
fas14a> priv set diag
Warning: These diagnostic commands are for use by NetApp
         personnel only.
fas14a*> ls /vol
/vol: Can't open directory: No such file or directory
fas14a*>

 

fas14a*> ls /
etc   
home   
storagelog  
vserver_fs  
download   
fas14a*>

 

And the thread you are referring to also doesn't see any volumes.

 

For the record: if I log in to the SVM directly the issue is the same, no difference.

 

So where are my volumes?

JamesIlderton
39,612 Views

Right, you can't "browse" the list of volumes, but if you know the path to your shared data, you can do it:

 

cluster01::> node run -node cluster01-01
Type 'exit' or 'Ctrl-D' to return to the CLI
cluster01-01> priv set advanced
Warning: These advanced commands are potentially dangerous; use
them only when directed to do so by NetApp
personnel.

 

cluster01-01*> ls /vol/dfs_doc/DOC
.
..
.DS_Store
Acct
Agile Development
AnalogGroup

 

In this example the volume name is 'dfs_doc' and the CIFS share under this is 'DOC'

 

Here's another, this one is used for Unix homedirs"

 

cluster01-01*> ls /vol/homedirs/home
.
..
jsmith
mdamon
bgates

 

So it sounds like you just need a little more depth to your ls command and it should work.  

 

One last example with ls -l and a volume containing a single LUN:

 

cluster01-01*> ls -l /vol/netbot
d755 64 2 4096 Mon Dec 14 23:24:09 EST 2015 .
d755 64 2 4096 Mon Dec 14 23:24:09 EST 2015 ..
10600 96 1 5497629096960 Thu Apr 28 14:26:53 EDT 2016 netbot

jappereuling
39,609 Views

Hi

 

Thanks! I found the issue!!!

 

In C-Mode and in NFS i have a 'vol1' but that doesnt work:

 

 

fas14a*> ls /vol/vol1
/vol/vol1: Can't open directory: No such file or directory
fas14a*>

 

but is accedentily did a 'vol status' and noticed that in the node shell it's known as 'vol1(2) online '  Not the (2). So that's kind of confusing but knowing this it works!

 

fas14a*> ls /vol/vol1(2)
.   
..   
Virtual Switch Update Manager   
.dvsData   
.iorm.sf   
.iormstats.sf   
.lck-6735090400000000  

....

 

woohooo! Strange that each volume has a (NUMBER) in node shell but hey now we know we know.

 

 

 

jappereuling
39,603 Views

on second though the (NUMBER) isn't that strange as I do have a vol0 and vol1 in each SVM i have so this is a way for the system to distinguish them.

 

anyhow the solution is : do a 'vol status'  and  use those names in your 'ls' and prepend it with the '/vol' dir

 

nitinshill
24,450 Views

ls -l /vol/vol1(2)

 

Can you please help what all the output columns mean when we add "-l" to this command?

bobshouseofcards
39,601 Views

If you commonly have the same volume name on different SVMs (for instance a "vol1" on SVM01 and SVM02).  The number differentiates at the node level between two different volumes of the same name because at some point both volumes could "live" on the same node and be accessible via the "/vol/..." path.  At the Cluster level, cDot translates appropriately based on the SVM the volume is in.

 

 

Hope this helps you.

 

Bob Greenwald

Lead Storage Engineer | Consilio, LLC

NCIE SAN Clustered, Data Protection

 

 

Kudos and accepted solutions are always appreciated.

 

 

connoisseur
38,443 Views

Hi guys!


Just a small tip, if you didn´t know.. but you don´t have to drop to node shell.. you can run the whole command in one line as long as you know your path.


So for exampel:

cluster01::> node run -node cluster01-01 "priv set diag;ls /vol/dfs_doc/DOC"

 

This will give you the output directly in cluster view, and you don´t need to skip between cluster view and node view.

 

Cheers.

 

Darkstar
38,383 Views

There is the volume explore command that is available from the cluster shell.

 

But it's a diag-mode command and can potentially be dangerous as it allows you to alter (i.e. destroy) arbitrary data on your disks, so be careful with it Smiley Wink

 

The syntax can be found in the man page and with "volume explore help", but the "scope" parameter is rather complicated, so I'll just mention the general syntax for listing a directory:

volume explore -format dir -scope <vserver>:<volume>/<path...>

 

For example:

cl1::*> volume explore -format dir -scope Infra:iso/Microsoft
found 1454.64/Microsoft to be inode 1454.96
directory data from block 1454.96@0 at location 1454@42693152b
   entry 0:  inum 96, generation 156613115, name "."
   entry 1:  inum 64, generation 1565554427, name ".."
   entry 2:  inum 97, generation 156630775, name "Windows 2008R2" (8.3 "WINDOW~1")
   entry 3:  inum 98, generation 156631151, name "Windows 2012R2" (8.3 "WINDOW~2")
   entry 4:  inum 101, generation 156635340, name "Windows 2012" (8.3 "WINDOW~3")
   entry 5:  inum 103, generation 156640115, name "Windows 2003R2" (8.3 "WINDOW~4")
   entry 6:  inum 20097, generation 156643561, name "_WSUS Update ISOs" (8.3 "_WSUSU~1")
   entry 7:  inum 19467, generation 157064132, name "Windows 8.1" (8.3 "WINDOW~1.1")
   entry 8:  inum 19468, generation 157064706, name "Windows 7" (8.3 "WINDOW~5")
   entry 9:  inum 19470, generation 157069086, name "Windows 8" (8.3 "E0K0000~")
   entry 10:  inum 19475, generation 157471053, name "Windows 2003" (8.3 "K0K0000~")
   entry 11:  inum 19477, generation 157475446, name "Windows 2008" (8.3 "M0K0000~")
   entry 12:  inum 29674, generation 164062243, name "Windows 10" (8.3 "AWT0000~")
   entry 13:  inum 29675, generation 415758740, name "Windows 2016 TP5" (8.3 "BWT0000~")

 

You can also read file contents, file metadata (timestamps etc.), and even system files with that command:

 

Metadata:

cl1::*> volume explore -format inode -scope Infra:iso/Microsoft
found 1454.64/Microsoft to be inode 1454.96
inode 1454.96 generation 156613115 at location 1454@45369601b+2368:192
   type 2.3, flags 0x02, flags2 0x00
   size 4096, blockcount 1, future_blocks 0, level 1
   umask 0777, uid 0, gid 1, xinode 29673, sinode 0, nlink 14, av-gen-num 0
   ctime 28-Apr-2016 14:11:12, mtime 28-Apr-2016 14:11:12, atime 03-Feb-2017 15:48:14
   ptr[0]: pvbn 1308139785, vvbn 42693152

Note that if your directory or file contains spaces, you cannot access it with that command, you have to use the 8.3 short name or inode number then.

 

 

hope that helps

 

regards

-Michael

Public