7

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

thanks

1
  • 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
    Commented Nov 7, 2013 at 13:08

2 Answers 2

4

there is third party tool that can do this.

https://github.com/kilobyte/compsize

usage:

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  
1

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.

1
  • 4
    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" ? Commented Feb 1, 2014 at 13:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .