Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

du and ls show different file sizes

I am using a MacAir with High Sierra and I noticed something odd in one of VirtualBox Directories. I can use ls -l to look at file sizes and I get


Odin-2:server_io_1_1510416322051_80277 rsplinter$ ls -l

total 3689032

drwx------ 6 rsplinter staff 192 Nov 12 08:29 Logs

-rw------- 1 rsplinter staff 1846870016 Nov 12 08:48 box-disk001.vmdk

-rw------- 1 rsplinter staff 1932360271360 Nov 12 08:48 box-disk002.vmdk

-rw------- 1 rsplinter staff 2686976 Nov 12 08:48 box-disk003.vmdk

-rw------- 1 rsplinter staff 2686976 Nov 12 08:48 box-disk004.vmdk

-rw------- 1 rsplinter staff 2195266973696 Nov 12 08:48 box-disk005.vmdk

-rw------- 1 rsplinter staff 2621440 Nov 12 08:48 box-disk006.vmdk

-rw------- 1 rsplinter staff 2621440 Nov 12 08:48 box-disk007.vmdk

-rw------- 1 rsplinter staff 2621440 Nov 12 08:48 box-disk008.vmdk

-rw------- 1 rsplinter staff 1728720041984 Nov 12 08:48 box-disk009.vmdk

-rw------- 1 rsplinter staff 2621440 Nov 12 08:48 box-disk010.vmdk

-rw------- 1 rsplinter staff 2621440 Nov 12 08:48 box-disk011.vmdk

-rw------- 1 rsplinter staff 7790 Nov 12 08:48 gluster_gluster0_1510416337924_10125.vbox

-rw------- 1 rsplinter staff 7790 Nov 12 08:29 gluster_gluster0_1510416337924_10125.vbox-prev


But if I use du -skH I get


Odin-2:server_io_1_1510416322051_80277 rsplinter$ du -skH *

576 Logs

1802804 box-disk001.vmdk

19132 box-disk002.vmdk

2472 box-disk003.vmdk

2472 box-disk004.vmdk

2784 box-disk005.vmdk

2408 box-disk006.vmdk

2408 box-disk007.vmdk

2408 box-disk008.vmdk

2796 box-disk009.vmdk

2408 box-disk010.vmdk

2408 box-disk011.vmdk

8 gluster_gluster0_1510416337924_10125.vbox

8 gluster_gluster0_1510416337924_10125.vbox-prev

Does anyone know why I see some files with massively different sizes? This system only has a 500GB SSD so TB size files is out of the question and they cannot be correct from "ls -l", but there they are. This is also affecting my ability to do Time Machine backups as well.

MacBook Pro, OS X Mountain Lion (10.8.5), Hard drives

Posted on Nov 13, 2017 1:06 PM

Reply
3 replies

Nov 13, 2017 2:47 PM in response to rxspl162

By default the ls command shows the number of bytes in a file, and by default, the du command shows the number of 512 byte blocks in a file. Your specifying du -skH tells it to display the number of 1024-byte blocks in each file — a different representation than ls.


If by default, you want ls and du to show the same block count value (512-bytes) then:


du ./filename

ls -sl ./filename

Nov 14, 2017 2:17 PM in response to VikingOSX

There is still something I don't understand. So I set the BLOCKSIZE,


Odin-2:server_io_1_1510416322051_80277 rsplinter$ printenv | grep BLOCKSIZE

BLOCKSIZE=1024


Now


Odin-2:server_io_1_1510416322051_80277 rsplinter$ du box-disk005.vmdk

2784 box-disk005.vmdk

Odin-2:server_io_1_1510416322051_80277 rsplinter$ du -sk box-disk005.vmdk

2784 box-disk005.vmdk

Odin-2:server_io_1_1510416322051_80277 rsplinter$ ls -sl box-disk005.vmdk

2784 -rw------- 1 rsplinter staff 2195266973696 Nov 12 08:48 box-disk005.vmdk

The output of the du commands are in terms of 1KB blocks. So 2784 x 1KB = 2.8MB, while the output of ls is in bytes. So from ls we have a file size of 2.2TB. This cannot be correct.

There is something odd about this particular VM disk file. This only seems to occur for a couple of VM disk files.

du and ls show different file sizes

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.