Skip to content

Instantly share code, notes, and snippets.

@alsunseri
Last active October 23, 2021 01:13
Show Gist options
  • Save alsunseri/1bb76b6ec0f62be9242585b33847ea6c to your computer and use it in GitHub Desktop.
Save alsunseri/1bb76b6ec0f62be9242585b33847ea6c to your computer and use it in GitHub Desktop.
get block size of linux drive partition or disk
#!/usr/bin/env bash
# blockdev is in the util-linux package and the binary is in /sbin usually
# util-linux: /sbin/blockdev
# Display an error message if the partition (input) is not
# Exit the shell script with a status of 1 using exit 1 command.
[ $# -eq 0 ] && { echo "Usage: $0 partion"; exit 1; }
PARTITION=$1
/sbin/blockdev --getbsz $PARTITION
#
# thanks to SURENDRA ANNE:
# https://www.linuxnix.com/find-block-size-linux/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment