← 返回命令列表

Linux command

compsize 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Example

sudo compsize [path/to/file_or_directory]

Example

sudo compsize -x [path/to/file_or_directory]

Example

sudo compsize -b [path/to/file_or_directory]

说明

compsize is a specialized utility for btrfs filesystems that reports detailed statistics on transparent filesystem compression. Btrfs supports multiple compression algorithms (zlib, lzo, zstd) that can compress data on-the-fly, and compsize reveals how much space is actually being saved versus the apparent uncompressed file sizes. The tool operates by examining btrfs extent metadata to determine both the logical size (what applications see) and the physical disk space consumed. It breaks down the results by compression type, showing which algorithm is achieving what compression ratio. This is invaluable for evaluating whether compression is providing value, as some file types (already compressed images, videos) may show little to no benefit and could even waste CPU cycles. Running compsize requires root privileges because it needs low-level access to filesystem extent information through btrfs ioctls. Results are typically displayed showing total bytes, compressed bytes, and the compression ratio as a percentage. The tool can operate on individual files, directories, or entire subvolumes, making it useful for identifying which parts of a filesystem benefit most from compression.

参数

-x, --one-file-system
Don't cross filesystem boundaries
-b, --bytes
Show raw byte counts

FAQ

What is the compsize command used for?

compsize is a specialized utility for btrfs filesystems that reports detailed statistics on transparent filesystem compression. Btrfs supports multiple compression algorithms (zlib, lzo, zstd) that can compress data on-the-fly, and compsize reveals how much space is actually being saved versus the apparent uncompressed file sizes. The tool operates by examining btrfs extent metadata to determine both the logical size (what applications see) and the physical disk space consumed. It breaks down the results by compression type, showing which algorithm is achieving what compression ratio. This is invaluable for evaluating whether compression is providing value, as some file types (already compressed images, videos) may show little to no benefit and could even waste CPU cycles. Running compsize requires root privileges because it needs low-level access to filesystem extent information through btrfs ioctls. Results are typically displayed showing total bytes, compressed bytes, and the compression ratio as a percentage. The tool can operate on individual files, directories, or entire subvolumes, making it useful for identifying which parts of a filesystem benefit most from compression.

How do I run a basic compsize example?

Run `sudo compsize [path/to/file_or_directory]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -x, --one-file-system do in compsize?

Don't cross filesystem boundaries