The compsize command is a utility in Linux that is used to calculate and display the compression ratios of files in a btrfs filesystem. The compsize command reads the specified filesystem and calculates the compression ratio of each file in the filesystem, displaying the results in a table.
To calculate the compression ratios of all files in the current filesystem, use the following command:
# compsize .
This will display the compression ratios of all files in the current filesystem in a table.
If you encounter the below error while running the command compsize:
compsize: command not found
you may try installing the below package as per your choice of distribution:
Distribution | Command |
---|---|
Debian | apt-get install btrfs-compsize |
Ubuntu | apt-get install btrfs-compsize |
Kali Linux | apt-get install btrfs-compsize |
Fedora | dnf install compsize |
compsize Command Examples
1. Calculate the current compression ratio for a file or directory:
# sudo compsize path/to/file_or_directory
2. Don’t traverse filesystem boundaries:
# sudo compsize --one-file-system path/to/file_or_directory
3. Show raw byte counts instead of human-readable sizes:
# sudo compsize --bytes path/to/file_or_directory