Fast directory delete on AIX

aixdirectory

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.

Best Answer

  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.

Related Topic