Bug 202891 - du, df, ls etc. report different storage sizes
Summary: du, df, ls etc. report different storage sizes
Status: Closed Works As Intended
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.2-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-04 12:42 UTC by Tandy
Modified: 2015-10-07 20:22 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tandy 2015-09-04 12:42:53 UTC
With the risk of this just being sparse files tricking me... du(1), df(1), ls(1) and various other applications report different storage footprints:

root@skrot:/var/db # du -sh mongodb/
1.7G	mongodb/

root@skrot:/var/db # du -sh mongodb/*
 47M	mongodb/bongo.0
 93M	mongodb/bongo.1
237M	mongodb/bongo.2
466M	mongodb/bongo.3
872M	mongodb/bongo.4
 32M	mongodb/bongo.5
 16M	mongodb/bongo.ns
 20K	mongodb/journal
160K	mongodb/local.0
 16M	mongodb/local.ns
4.0K	mongodb/mongod.lock
 44K	mongodb/mongod.log

root@skrot:/var/db # df -h
Filesystem    Size    Used   Avail Capacity  Mounted on
/dev/ada0a    143G    3.1G    129G     2%    /
devfs         1.0K    1.0K      0B   100%    /dev

root@skrot:/var/db # ls -lh mongodb/
total 1821940
-rw-------  1 mongodb  mongodb    64M Sep  4 03:41 bongo.0
-rw-------  1 mongodb  mongodb   128M Sep  4 02:04 bongo.1
-rw-------  1 mongodb  mongodb   256M Sep  4 02:47 bongo.2
-rw-------  1 mongodb  mongodb   512M Sep  4 03:42 bongo.3
-rw-------  1 mongodb  mongodb   1.0G Sep  4 03:42 bongo.4
-rw-------  1 mongodb  mongodb   2.0G Sep  4 03:42 bongo.5
-rw-------  1 mongodb  mongodb    16M Sep  4 03:42 bongo.ns
drwxr-xr-x  2 mongodb  mongodb   512B Sep  4 12:25 journal
-rw-------  1 mongodb  mongodb    64M Sep  4 12:26 local.0
-rw-------  1 mongodb  mongodb    16M Sep  4 12:26 local.ns
-rwxr-xr-x  1 mongodb  mongodb     4B Sep  4 12:25 mongod.lock
-rw-r--r--  1 mongodb  mongodb    43K Sep  4 12:27 mongod.log

root@skrot:/var/db # mongo
MongoDB shell version: 2.6.7
connecting to: test
> show dbs
admin  (empty)
bongo  3.952GB
local  0.078GB
> 

root@skrot:/var/db # tar -cf /root/db.tar mongodb/
root@skrot:/var/db # ls -lh /root/db.tar 
-rw-r--r--  1 root  wheel   1.7G Sep  4 13:17 /root/db.tar

root@skrot:/var/db # tar --list -tf /root/db.tar
drwxr-xr-x  0 mongodb mongodb     0 Sep  4 03:45 mongodb/
-rw-r--r--  0 mongodb mongodb 46613 Sep  4 13:12 mongodb/mongod.log
-rwxr-xr-x  0 mongodb mongodb     4 Sep  4 12:25 mongodb/mongod.lock
drwxr-xr-x  0 mongodb mongodb     0 Sep  4 12:25 mongodb/journal/
-rw-------  0 mongodb mongodb 16777216 Sep  4 12:26 mongodb/local.ns
-rw-------  0 mongodb mongodb 67108864 Sep  4 12:26 mongodb/local.0
-rw-------  0 mongodb mongodb 16777216 Sep  4 03:42 mongodb/bongo.ns
-rw-------  0 mongodb mongodb 67108864 Sep  4 03:41 mongodb/bongo.0
-rw-------  0 mongodb mongodb 134217728 Sep  4 02:04 mongodb/bongo.1
-rw-------  0 mongodb mongodb 268435456 Sep  4 02:47 mongodb/bongo.2
-rw-------  0 mongodb mongodb 536870912 Sep  4 03:42 mongodb/bongo.3
-rw-------  0 mongodb mongodb 1073741824 Sep  4 03:42 mongodb/bongo.4
-rw-------  0 mongodb mongodb 2146435072 Sep  4 03:42 mongodb/bongo.5
-rw-------  0 mongodb mongodb      16384 Sep  4 12:26 mongodb/journal/j._0


Is there any way to make du, ls etc. "align" to report the same instead of wildly varying numbers, or a way to make ls indicate sparse file if this is the cause?

This is 10.2-RELEASE-p2 amd64, generic kernel, non-journaled UFS on MBR.
Comment 1 Alan Somers freebsd_committer freebsd_triage 2015-10-07 20:22:29 UTC
du(1) suggests that "-A" is the option you want.