0

I'm troubleshooting an issue regarding disk size usage in a centOS system (one of the partitions was growing too fast), and I notice one of my directories has 3.1GB:

$ du -hs /var/log/mongodb/
3.1G    /var/log/mongodb/
$ df -h /var/log/mongodb/
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg00-log  4.0G  3.7G  324M  93% /var/log

However, when I analyse the directory contents, I realize it only has 1 file, and that file is not that large (2.1GB):

$ ls -larth /var/log/mongodb/
total 3.1G
drwxr-xr-x   2 mongod mongod   24 Jul  2  2019 .
drwxr-xr-x. 22 root   root   4.0K May  1 03:50 ..
-rw-r-----   1 mongod mongod 2.1G May  1 08:41 mongod.log

How can this happen?

Stat command:

$ stat /var/log/mongodb/mongod.log
  File: ‘/var/log/mongodb/mongod.log’
  Size: 2448779949  Blocks: 4880912    IO Block: 4096   regular file
Device: fd08h/64776d    Inode: 6291527     Links: 1
Access: (0640/-rw-r-----)  Uid: (  996/  mongod)   Gid: (  994/  mongod)
Access: 2020-05-01 10:02:57.136265481 +0000
Modify: 2020-05-04 10:05:37.409626901 +0000
Change: 2020-05-04 10:05:37.409626901 +0000
 Birth: -

Another example in another host:

$ df -kh | grep var
/dev/dm-3        54G   52G  2.1G  97% /var[
$ du -khs /var/
25G /var/

Is this somehow related to the difference between file size and actual space on disk occupied (due to disk blocks)? If so, how can I perform a defragmentation/optimization?

samthegolden
  • 1,366
  • 1
  • 10
  • 26

0 Answers0