Thunar and ls different file size

I have a complete android userdata partition image on disk and it shows 48.9 GiB on Thunar but only 3.8 GB in ls and Baobab. How is it possible ?
Thanks

Asked By: darkon11

||

This might be a sparse file; i.e. a file that has "holes" where there really is nothing, just zeroes. Since you wrote that this was a disk partition, that is actually quite likely.

[sh @ balrog] .../work/test/sparse 24 % ls -lh
total 1.1M
-rw-rw-r-- 1 sh 1000 1001M  5. Feb 2016  sparse-1MB.bin
-rw-rw-r-- 1 sh 1000  8.0K 16. Jun 2020  sparse-8k
-rw-rw-r-- 1 sh 1000  8.0K 16. Jun 2020  sparse-8k-zero
-rw-rw-r-- 1 sh 1000 1000M  5. Feb 2016  sparse-zero.bin

[sh @ balrog] .../work/test/sparse 25 % ls -sh1
total 1.1M
1.0M sparse-1MB.bin
4.0K sparse-8k
   0 sparse-8k-zero
   0 sparse-zero.bin

Many file tools can’t really handle them correctly. The problem is that those files really have two sizes: The nominal size (which is what ls -l and Thunar show you) and the true allocated size (which du -h or ls -sh show).

Be really careful when copying such a file; some tools may "fill" the holes and actually write zeroes where there used to be the hole, really consuming the nominal size. See also man cp and the --sparse option.

If you use that kind of files often, use QDirStat which shows you both sizes at once:

QDirStat showing sparse files

Answered By: HuHa
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.