2

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:

  • There is some cache in du command ?
  • There is a trash or hidden file that du can't read?

Some information about my files:

  • Disk filesystem is ext4
  • File are uploaded with rsync
  • Disk is not in raid
William Perron
  • 485
  • 7
  • 16
  • 1
    Any files starting with "." (dot character) inside the raid10 directory? Can you do `ls -al` inside the raid10 directory and see. Or you could run `find . -name ".*" -ls` to find such dirs/files recursively. – blackpen Nov 02 '16 at 17:38
  • 1
    @blackpen Thank, I found my problem, I have a .trash-1000 folder in my raid10 – William Perron Nov 02 '16 at 18:02

2 Answers2

4

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 *
William Perron
  • 485
  • 7
  • 16
0

To look for hidden (names starting with a dot) files/directories recursively:

find . -name ".*" -ls
blackpen
  • 2,339
  • 13
  • 15