ONTAP Discussions

large files and folder deletion from netapp command

Puru01
14,599 Views

Hi

does anyone knows better way to delete a folder inside a share fro example. a is share and it has x,y,z folder. i want to delete a folder y from a from only - how would i can do it by Netapp cli since it is large folder and need some time to delete it .

any commands and method from ontap side only

 

Thanks 

Puru

1 ACCEPTED SOLUTION

ttran
11,526 Views

Hello @Puru01 ,

 

Here is reference material on the ONTAP 9.8 Fast Directory Delete feature @TMADOCTHOMAS mentioned: Perform a fast directory delete by deleting files and directories asynchronously 

 

As always thank you @TMADOCTHOMAS !

 

Regards,

 

Team NetApp

Team NetApp

View solution in original post

13 REPLIES 13

Ontapforrum
14,508 Views

Hi,

 

I don't think there is a way from ONTAP CLI to delete a folder (which is non-empty), you can list the folder and delete files but not empty directory. In any case, it is NOT recommended from NetApp CLI.  Please delete folder/files from the client side.

 

I think efficient way would be to delete using command line from either Windows or Linux side without enumerating.

For NFS it's not an issue, for CIFS I find it easier to map "share" using SMB to linux client, once you have cifs shares mounted on linux you can use these or any other command (from google) to get rid of large directory.

 

From linux: (For ex- Deleting folder 'x')
/]# rm -rf /share/directory/x
/]# rsync -a --delete /mnt/empty/ /mnt/share/directory/x

 

Thanks!

maffo
14,470 Views

hi @Puru01 

as pointed out previously, you cannot delete specific folder/files from ONTAP directly, the only exception is if the folder in question is a qtree created by ONTAP in which case it can be deleted from ONTAP too.

EWILTS_SAS
14,418 Views

We are a large NFS shop and delete tens of millions of files every day.  By far, the fastest method we have found is NetApp's XCP tool using the delete option.

 

We haven't researched any methods for CIFS shares but there is a Windows version of XCP - you might want to check out to see if that has a delete feature as well.

TMADOCTHOMAS
11,579 Views

@Puru01 , FYI there's a new feature in OnTAP 9.8 and above called Fast Directory Delete that finally adds the ability to delete large directories from within OnTAP. I've not used it but I'm reading up on it now.

EWILTS_SAS
11,575 Views

The Asynchronous Directory Delete in ONTAP is not faster than NFS XCP.  It offloads the workload, which can be significant, but it is slower.   It does have a throttle option but even wide open, it loses the race to XCP.  You're limited to a single delete job on the cluster at any one time (we regularly do multiple XCP deletes simultaneously over NFS).  Which tool you use depends on your requirements - do you want the fastest delete possible (with possible performance impacts) or are you ok with slower, less impactful deletes?

TMADOCTHOMAS
11,571 Views

Makes sense, thanks @EWILTS_SAS !

ttran
11,527 Views

Hello @Puru01 ,

 

Here is reference material on the ONTAP 9.8 Fast Directory Delete feature @TMADOCTHOMAS mentioned: Perform a fast directory delete by deleting files and directories asynchronously 

 

As always thank you @TMADOCTHOMAS !

 

Regards,

 

Team NetApp

Team NetApp

MAWAW
5,510 Views

I was testing to delete a file from a qtree by this command, but it failed. Maybe the path format is not right, can you give a example of path format?  Thanks.

 

volume file async-delete start -vserver vs01 -volume Vol_Test -path /Vol_Test/qtree_test/testtesttest.txt

Error: command failed: No such file or directory

 

TMADOCTHOMAS
5,475 Views

@MAWAW here's how I do it. First I enter this command to find out the correct path syntax:

 

cifs share show -vserver <vserver> -share-name <share_name>

 

Then I enter this command to enable the rapid delete:

​​​​​​​volume file async-delete client enable -vserver <vserver> -volume <volume>

And finally this to verify it took:

 

volume file async-delete client show

MAWAW
5,429 Views

@TMADOCTHOMAS , Thank you for responding to my question. 

After I enabled it,  I still got same error message.  

 

I want to know what path exactly needs to be in following command.  For example, I have a qtree qtree_test in vol name Vol_Test, and a file testtesttest.txt in that qtree, I want to delete it with following command but it failed. 

 

volume file async-delete start -vserver vs01 -volume Vol_Test -path  /Vol_Test/qtree_test/testtesttest.txt

 

or path qtree_test/testtesttest.txt, both failed.

 

 

 

TMADOCTHOMAS
5,313 Views

@MAWAW it can't be a file, it has to be a directory. The logic is this is for RAPID deletion of a huge number of files, not individual files, which can just be deleted normally via Windows Explorer.


The path is just the directory name under the share name. So if you have a share "Share1" and two directories under it named "Dir1" and "Dir2", and want to delete "Dir2", it would be:

volume file async-delete start -vserver vs01 -volume Vol_Test -path Dir2

 

If you have subdirectories under Dir2, say Sub1 and Sub2, and want to delete Sub2, it would be:

 

volume file async-delete start -vserver vs01 -volume Vol_Test -path Dir2/Sub2

MAWAW
5,288 Views

@TMADOCTHOMAS  Thank you!  Now I understand the path, and you are right, it has to be a directory.  However, it doesn't do what I want it to do. 

 

In my case, I has a file created in a volume directly by cli like anti-ransomware report, I can't delete that file because strictly permission of the share, so I'm thinking how to delete it use cli in netapp.

 

Regarding volume file async-delete start command and the path d1/d2 ,  d1 is actually the qtree and d2 is a directory in d1. It seems like only related to volume, but no relation to share name in my test.  It could be dangerous, somehow a qtree or a folder in qtree can be deleted with this command without multi-admin-verify  in my test.

 

TMADOCTHOMAS
5,285 Views

I can't speak to qtrees as we don't use them. As for deleting the file that you don't have permission to, you might have to take ownership in Windows (if you have rights to do so). 

Public