linuxdudisk-access

Why du command show different total in folder versus in parent


I can't understand why I have different total size in a folder versus in parent.

That's my folder tree

bkp
|-- raid10
|    |-- folder_a 
|    |-- folder_b 
|    |-- folder_c 
|    |-- folder_d 
|    |-- folder_e 
|    |-- folder_f 
|    |-- folder_g 
|    |-- folder_h 
|    |-- folder_i 
|    |-- folder_j 
|    |-- folder_k 
|    |-- folder_l
|    |-- script.sh
|-- vm

I previously delete a big amount of file in that folder and I want to get my new disk usage.

sudo du -shc /bkp/*
756G    raid10
4.0K    vm
756G    total

Now I execute that command to get more info about the folder raid10:

sudo du -shc /bkp/raid10/*
13G     folder_a
178M    folder_b
15G     folder_c
2.3G    folder_d
32M     folder_e
31G     folder_f
31G     folder_g
49G     folder_h
131M    folder_i
4.7G    folder_j
392M    folder_k
4.0K    folder_l
4.0K    lost+found
4.0K    script.sh~
144G    total

Why the total is so different ?

I checked man du and tried some command, like --apparent-size, but same result. Also try without -s sudo du -hc /bkp/raid10/*, I have the same total but I see all directory...

I have some assumptions:

Some information about my files:


Solution

  • To make du search for invisible just do:

    #First part will get all invisible and second will get all non-invisible
    du -shc /bkp/raid10/.[!.]* /bkp/raid10/*
    

    Or cleaner command:

    cd /bkp/raid10
    du -sch .[!.]* *
    

    Or enable shell option that matches hidden file with globbing

    shopt -s dotglob
    du -sch *