0

I have a Solaris 10 server that has mounted a remote filesystem via NFS. I believe the remote system is a NetApp, but it's not clear.

When I run df -h <mountpoint> I get size 12T, used 10T with a capacity at 87%.

When I change to the mountpoint and run ls -A |xargs du -s I get about 8 megabytes. I have come to expect du to descend recursively and add up all the file sizes, but it doesn't appear to do it here.

As a hedge, I ran

find <mountpoint> -ls | awk '{total=total+$7}END{print total}' 

the answer is 13006791645. When divided by 1024^3 (1073741824), I get about 12.1 terabytes.

So it would seem that find -ls and df are more or less in agreement. Why would du fail so greviously?

PS: the command ls -A grabs the hidden snapshot directories also but find finds nothing (except "cycle detected").

4
  • du -s gives a total per name given on the command line, unless you use --total (GNU du only, I don't have Solaris handy to check what options that version of du accepts). So did you add up all the numbers given by ls -A |xargs du -s ? Why not just do du -s $mountpoint? Commented Nov 28, 2019 at 7:57
  • It is most unlikely that people use gdu on Solaris. In special as it is too dumb to understand extended attribute files. Commented Nov 28, 2019 at 11:36
  • 1024^3 byte is a gibibyte, not a terabyte. The 7th field in -ls is the file size, not its disk usage Commented Dec 6, 2019 at 15:50
  • Related: Why are there so many different ways to measure disk usage? Commented Dec 6, 2019 at 15:54

1 Answer 1

0

du -s reports in 512-byte blocks. Your comparison with df -h can not be made since du does not report human readable data.

To compare both values, use either du -sh <mountpoint> or /usr/xpg4/bin/df -P to let df also report in 512-byte units.

According to man du:

Files with multiple links will be counted and written for only one entry. The directory entry that is selected in the report is unspeci- fied. By default, file sizes are written in 512-byte units, rounded up to the next 512-byte unit.

Try /usr/xpg4/bin/df -P to get 512-bytes reported by df:

bash-3.2$ /usr/xpg4/bin/df -P /var Filesystem 512-blocks Used Available Capacity Mounted on rpool/ROOT/s10/var 1147797504 66061270 954397119 7% /var 

And compare with du -s:

bash-3.2$ du -s /var 65976060 /var 

Or compare:

bash-3.2$ df -h /var Filesystem size used avail capacity Mounted on rpool/ROOT/s10x_u11wos_24a/var 547G 32G 455G 7% /var 

with:

bash-3.2$ du -hs /var 31G /var 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.