Skip to content

Instantly share code, notes, and snippets.

@koumaza
Last active Dec 12, 2020
Embed
What would you like to do?
Calculate Partition Size

Step 1 - Run fdisk

fdisk -l /dev/YOURDEVICE
## Or
fdisk -l /dev/block/YOURDEVICE
## Or
fdisk -l /dev/block/by-name/YOURDEVICEPARTTIONNAME

# Which is my device
df -a # Outputs mount-points

Step 2 - Calculate

There are four things to watch here.

  • Sector Size
  • Start (sector)
  • End (sector)
  • Name
Run this
# Posix Shell
echo $(( ( Start - End ) * SectorSize ))
# Fish
math "( Start - End ) * SectorSize )"
outputs as byte

byte*10^-6=megabyte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment