Created
September 9, 2012 18:34
-
-
Save dweeber/3686318 to your computer and use it in GitHub Desktop.
Sample code of determining the size of the partition.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DISK_SIZE="4" # set this to the card size in nominal GB | |
# or: DISK_SIZE="$(($(sudo blockdev --getsz /dev/mmcblk0)/2048/925))" | |
PART_START="$(sudo parted /dev/mmcblk0 -ms unit s p |grep "^2" |cut -f2 -d:)" | |
[ "$PART_START" ] || exit 1 | |
PART_END="$((DISK_SIZE*925*2048-1))" | |
[ "$PART_END" -ge 3788799 ] || exit 1 | |
printf "d\n2\nn\np\n2\n$PART_START\n$PART_END\np\nw\n" |sudo fdisk /dev/mmcblk0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment