我在 btrfs 卷上启用了压缩。现在我如何知道文件或目录的压缩率?或者至少是总体统计数据?
答案1
有第三方工具可以做到这一点。
https://github.com/kilobyte/compsize
用法:
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
答案2
compsize
已添加到 Ubuntu 存储库。
您可以通过以下方式安装
sudo apt install btrfs-compsize
如果你跑man compsize
,你就会看到
NAME
compsize - calculate compression ratio of a set of files on btrfs
SYNOPSIS
compsize file-or-dir [ file-or-dir ... ]
DESCRIPTION
compsize takes a list of files on a btrfs filesystem (recursing directories) and measures used compression
types and the effective compression ratio.
As talking about compression ratio for a partial extent doesn't quite make any sense, every used extent is
considered in its entirety. Every extent is also counted exactly once, even if it's reflinked multiple times.
The program gives a report similar to:
Processed 90319 files.
Type Perc Disk Usage Uncompressed Referenced
TOTAL 79% 1.4G 1.8G 1.9G
none 100% 1.0G 1.0G 1.0G
lzo 53% 446M 833M 843M
答案3
答案4
可以使用以下方法轻松完成自由度和杜命令行工具。例如,如果我在/媒体/etamar/文件系统我可以使用以下命令来查看压缩数据和实际数据大小之间的差异:
me@host:~$ df -h /media/etamar/filesystem/ ; du -hd0 /media/etamar/filesystem/
Filesystem Size Used Avail Use% Mounted on
/dev/sdb6 31G 6.2G 23G 22% /media/etamar/filesystem
9.4G /media/etamar/filesystem/
在这种情况下,我使用 BTRFS 文件系统上的 6.2 GB 压缩存储空间存储了 9.4 GB 的实际数据。可以用多种方式(包括计算器)计算 6.2/9.4。