butterknife-provisioning-image/overlay/sbin/butterknife-partition-size
2021-02-23 00:32:51 +02:00

13 lines
373 B
Bash
Executable File

#!/bin/sh
partition_slug=$(echo $1 | cut -d "/" -f 3)
sys_part="/sys/block/*/$partition_slug"
sys_disk=$(dirname $sys_part)
sector_count=$(cat $sys_part/size)
sector_size=$(cat $sys_disk/queue/hw_sector_size)
size=$(expr $sector_count / 1000000 \* $sector_size / 1000)G
if [ $size == "G" ]; then
size=$(expr $sector_count / 1000 \* $sector_size / 1000)M
fi
echo $size