This snippet dumps ext2/3/4 filesystem block allocation info in MiB's
Use case: you want block level allocation info without mounting the filesystem
Example output:
used: 8599.37 MiB
free: 13926.63 MiB
total: 22526.00 MiB
ext_part=/dev/zd64p1
dumpe2fs -h "$ext_part" | awk '
/Block count:/ {blocks=$3}
/Free blocks:/ {free=$3}
/Block size:/ {bsize=$3}
END {
used_blocks = blocks - free
used_mib = used_blocks * bsize / (1024*1024)
free_mib = free * bsize / (1024*1024)
total_mib = blocks * bsize / (1024*1024)
printf("used: %.2f MiB\nfree: %.2f MiB\ntotal: %.2f MiB\n", used_mib, free_mib, total_mib)
}'