I am using btrfs on one of my hard drives. I would like to know the actual file size and the compressed file size on btrfs. I am interested in seeing the compression ratios per file . For example ntfs file system can give you such information.

I am using compress-force=zlib option in my fstab. And I am using Debian Squeeze 3.2.0-0.bpo.4-amd64


  • It's easy for the whole filesystem (compare the output of df with the output of du) but I don't know how to do that for single files, I'm really interested in the answer to this question. – FSMaxB Nov 7 '13 at 13:08

there is third party tool that can do this.



ayush@devbox:/code/compsize$ sudo compsize /opt
Processed 54036 files, 42027 regular extents (42028 refs), 27150 inline.
Type       Perc     Disk Usage   Uncompressed Referenced  
Data        82%      5.3G         6.4G         6.4G       
none       100%      4.3G         4.3G         4.3G       
zlib        37%      427M         1.1G         1.1G       
lzo         56%      588M         1.0G         1.0G  

An interesting question, but it seems like that would be a negative for now.

According to the offical FAQ (https://btrfs.wiki.kernel.org/index.php/FAQ) the reason being that the information is just not stored in the file system. There is a patch for the kernel (https://patchwork.kernel.org/patch/117782/) but again, this only counts the blocks used (so the ratio is rounded to the block size, thus off by upto 4KB).

If a utility was made (would be possible) it would be extremely inefficient. The program would have to decompress the file to determine the compression ratio.

  • 3
    why would it have to decompress the file is "ls" and all the other FS calls display the nominal file size? Wouldn't the ratio be "UsedBlocks * 100 / NominalUsedBlocks = ratio" ? – Andre de Miranda Feb 1 '14 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.