View Single Post
Posts: 12 | Thanked: 21 times | Joined on Aug 2010 @ Alger
#290
Hello,
Here is a method to calculate the partition's table.
You must know that a bloc is 32k and it's better to use boundaries at 256k.
To calculate a size the rule is to change to KB and divide by 32.
Maybe an example will make it clearer :
To keep it simple, let's assume that you want at most 4 partitions.
1) Choose a partitionning layout
in my example
p1=remaining (21GB) as fat, p2=8GB as ext3, p3=512MB as swap, p4=128MB as ext3
2) Get the highest block number of your device
Code:
sfdisk -l /dev/mmcblk0 | grep mmcblk | grep -v Empty | tail -n 1 | awk '{print $3;}'
This gives me 974974 (you can have a different number because i calculate the last used bloc)
3) Calculate the highest 256k bloc number
high256k=int((974974+1)/8)*8
974974+1=974975
974975/8=121871.88
121871*8=974968
we have a difference of 974974-974968=6 blocs that will be added to the last partition
4) calculate the 4th partition
size=128MB=128*1024KB=131072KB=131072/32 blocs=4096 blocs
add 6 blocs
4096+6=4102 blocs
we know the end bloc and the size :
end bloc=974974
size=4102
let's calculate the beginning bloc :
beginning=974974-4102=970872
that is also the end of the 3rd partition
5) calculate the 3rd partition (it's nearly copy and past from 4)
size=512MB=512*1024KB=524288KB=524288/32 blocs=16384 blocs
we know the end bloc and the size :
end bloc=970872
size=16384
let's calculate the beginning bloc :
beginning=970872-16384=954488
you guessed right ! that is also the end of the 2nd partition
6) calculate the 2nd partition (also the same as above)
size=8GB=8*1024MB=8192MB=8192*1024KB=8388608KB=838 8608/32 blocs=262144 blocs
we know the end bloc and the size :
end bloc=954488
size=262144
let's calculate the beginning bloc :
beginning=954488-262144=692344
And yes, that's the end of the 1st partition too
7) calculate the 1st partition (the easiest part)
we know the start and end blocs
end bloc=692344
beginning=0 (*)
let's calculate the size :
size=692344-0 blocs=692344 blocs
Congratulations ! You just finished the caclulation of your partitions !
One last thing :
the type of partition is c for fat, 82 for swap and 83 for ext3
using sfdisk you just have to give beginning, size and type for each partition
----------------
(*) : I haven't any issue beginning with 0, the default is 1, many says to begin with 64 (losing 2MB)
 

The Following User Says Thank You to brahim98 For This Useful Post: