I want to check the size of my directory.
directory is xen domU image.
directory name is xendisk
du -sh ./xendisk
returns 5.4G.
but xen domU Image size is 10G.
what happened?
I want to check the size of my directory.
directory is xen domU image.
directory name is xendisk
du -sh ./xendisk
returns 5.4G.
but xen domU Image size is 10G.
what happened?
You have created a sparse file for your image. If you used a command like
truncate -s 10G domU.img
to create the image then this would be the result.The wiki which I have linked has more information but basically a sparse file is one where the empty parts of the file take no space. This is useful when dealing with VMs because in most cases your VM will only take a fraction of the space available to it so using a sparse file will mean that it takes far less space on your filesystem (as you have observed). The article states that this is acheived using the following mechanism:
If you need to check the size with
du
you may be interested in the--apparent-size
option, which will include all of the unallocated blocks in the calculation. Therefore you could use this command if you need the output to match whatls
is telling you: