3

At the end of last week one of my colleagues noticed something strange on one of our shared compute servers.

We have a directory which ls -l shows as containing a file which is 132G in size.

However, running df -h shows that the total amount of space used on the disk as 128G. Additionally running du -h --max-depth=1 on the root of the drive also reports 128G for .

Initially I wondered whether this issue might be as a result of open file handles or similar causing these binaries to report different information. However, I have tired unmounting and remounting the disk and all binaries report the same results as before.

To give a bit more information on the configuration of the drive:

  • The volume is formatted using EXT4 on top of LUKS encryption.
  • The disk is not shared via NFS or similar.
  • I have check the file in question and it does not appear to be linked.
  • When unmounting and remounting the volume I forced a disk check, by running fsck -f on the volume, and no issues were returned.
  • The server the disk is located on isn't a virtualisation host and is running Ubuntu 14.04 as the OS.
Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232

1 Answers1

3

Is your server virtualization host?

Different real file and disk space size is normal behaviour for dynamically expanding virtual disks. This disks has different real file size and header filesize data

Example:

possibly you use qemu virtual disks (qcow2 extension or other) which you can find with:

find / -regex '.*\.qcow.*$'

/var/lib/vz/images/105/vm-105-disk-1.qcow2
...

Lets check vm-105-disk-1.qcow2 size with stat:

stat vm-105-disk-1.qcow2

  File: vm-100-disk-1.qcow2
  Size: 68745560064

79728541696 - is approxymately 64GB

Check with wc:

wc -c <vm-105-disk-1.qcow2

68745560064

The same result... Check with du:

du -sh vm-105-disk-1.qcow2

15G        vm-105-disk-1.qcow2

Only 15GB! Lets check with qemu-img util:

qemu-img info vm-105-disk-1.qcow2

image: vm-105-disk-1.qcow2
file format: qcow2
virtual size: 64G (68719476736 bytes)
disk size: 14G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

Pay attention at this two lines and everything should be clear:

virtual size: 64G (68719476736 bytes)
disk size: 14G

If your server is not virtualization host, see this topics: