3

I have a 4TB NFS file system that is being served from a NetApp filer. The NetApp's quota tools tell me that a certain user is using X amount of disk space in that qtree, but it isn't in "their" directory, it could be anywhere in the file system. So I have to find it so that it can be either justified or cleaned up.

I'm running a find -user command and it has been running for three days so far, and that's just the file listing -- I was planning to go back and do a du on each file to get file sizes.

Is there some tool that can do all this for me in a better way? Or an approach that will get me the information I want in an easier way? I'm hoping for something like SequoiaView on Windows, except with the ability to just show me files owned by single user.

Update: this is the command I am running:

find * -name .snapshot -prune -o -type f -user $USER -exec ls -l {} \; > /tmp/output.txt

The intention is to write an awk or perl one-liner to go through this raw data and figure out where things actually are.

5
  • 2
    Are you running this find command? – Ramesh Sep 17 '14 at 15:19
  • 1
    I found this question. It might help you. – Ramesh Sep 17 '14 at 15:23
  • Interesting, but no. Quota tools tell me how much disk space I am using, I need to know where in the mess those files actually are. Both of those examples appear to brute-force quota replacements; I'm interested in the details. – David Mackintosh Sep 17 '14 at 15:26
  • 1
    Given that it's likely a RAID filesystem with at least 2Gbps bandwidth between the disks and the controller, the bottleneck is probably NFS latency. Try running multiple finds, from different clients, in parallel. Try to use clients on the same LAN segment as the filer. – Mark Plotnick Sep 17 '14 at 15:41
  • 1
    You'll likely get "Argument list too long" because of the exec... try find /home/ -user username -type f -size +1048576 -printf "%s %p\n" to find all files for certain user that are larger than 1GB and output the size and full path. – Jan Sep 17 '14 at 15:49
3

Unless there is some NetApp-specific way to do it, a quota is generally just a few numbers: amount used, amount permitted. Its tracked in a trivial manner: If the user deletes a 1MB file, subtract 1MB from the amount used. If the user adds 1MB to a file, add 1MB to the amount used. The quota itself doesn't know (or care) which files are using that space.

That find command you're using is sub-optimal, though. First, to find the owner, find has to run stat on the file. So find already has the size. Next, exec ls {} \; is quite inefficient. You should at least use -exec ls {} + to reduce the number of ls calls. Even better, though (if your find has it, not sure its standard) is -printf. This avoids the ls entirely, and lets you make use of the stat find has already done:

find … -printf '%s %p\0' # that gives null-delimited, you can use \n instead
                         # for newline-delimited

There are many other flags to -printf, check the find manpage.

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.