Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an extremely large directory (containing millions of files summing up to 150 GB) which I want to delete.

Is there a faster method than using rm -rf which takes ages to complete on this directory?

BTW: It's an AIX system and the directory resides on an NFS mount.

share|improve this question
add comment

2 Answers

  1. Rename (mv) the directory to some temporary name, re-create it with the same name, owner and permissions. This way any users/processes that use that directory can proceed in a matter of seconds. Delete the temporary directory later (or in the background).

  2. An alternative that requires changes on the side of the actual NFS server: prepare a separate empty filesystem that will hold your data and mount it over the directory. The directory will be empty from the client point of view. You can later delete files that are hidded below the mount point. The benefit here is substantial, because next time when you need to delete the same directory you can just overwrite the whole filesystem (mkfs), which takes minutes not hours. No need to rm -rf anything at all.

share|improve this answer
add comment

rm -rf is going to be as fast as you can get-unless you run the command on the NFS server itself. You may be able to see some speed up by running it from the remote machine. You could also do

rm -rf /path/ &

to put the job into the background so you can keep working.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.