1

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.

2
  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.

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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