Announcement: Upgrade to macOS Mojave

With features like Dark Mode, Stacks, and four new built-in apps, macOS Mojave helps you get more out of every click. 
Find out how to upgrade to macOS Mojave > https://support.apple.com/macos/mojave

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

Question:

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

Reply

Page content loaded

Nov 13, 2017 2:47 PM in response to rxspl162 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 13, 2017 2:47 PM

Reply Helpful

Nov 14, 2017 2:17 PM in response to VikingOSX 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.

Nov 14, 2017 2:17 PM

Reply Helpful
User profile for user: rxspl162

Question: du and ls show different file sizes