blkcnt_t - Linux


blkcnt_t is a command-line utility for manipulating the blkcnt_t data type, which is used in Linux to represent block counts and logical block sizes for block devices. It allows users to convert between block counts and logical block sizes, facilitating the management and understanding of storage devices.


blkcnt_t [OPTIONS] <VALUE> <UNIT>


  • -l, –logical: Convert from a block count to a logical block size.
  • -p, –physical: Convert from a logical block size to a block count.
  • -b, –bytes: Specify that the input value represents bytes instead of blocks.
  • -h, –help: Display help information and exit.


Convert a block count (1024 blocks) to a logical block size:

blkcnt_t --logical 1024 B



Convert a logical block size (4KiB) to a block count for a 1TiB device:

blkcnt_t --physical 4K 1T



Convert bytes (100MB) to a block count with a logical block size of 4KiB:

blkcnt_t -b --logical 100M 4K



Common Issues

  • Incorrect unit: Ensure to specify the correct unit (B, K, M, G, T) for the input value.
  • Invalid input: The input value must be a numeric value. Non-numeric characters or invalid units will cause an error.
  • Overflow: Converting very large values can lead to integer overflow. Consider using bc or other tools for such calculations.


blkcnt_t can be integrated into scripts or command chains for automating storage management tasks. For example:

fdisk -l | grep "Disk /dev/" | awk '{print $3}' | blkcnt_t -l K

This command chain extracts the disk size in bytes from fdisk output and converts it to a logical block size in KiB.

Related Commands

  • fdisk: Partition disk devices.
  • lsblk: List block devices and their properties.
  • bc: Perform arbitrary precision calculations.