View Single Post
Posts: 3,401 | Thanked: 1,255 times | Joined on Nov 2005 @ London, UK
#46
Correct, the partition sizes quoted in that wiki page are just one possible example (in this case appropriate for a 2GB card split 0.5GB + 1.5GB), and the figures will be inappropriate for a larger or smaller card.

When you run sfdisk, it will state how large each cylinder is on your card - on my Transcend 4GB card, each cylinder is 32768 bytes. Given that information, you can determine how many cylinders you need for a 3.5GB partition by dividing (3.5 * 1024 * 1024 * 1024) by 32768 - this calculation tells me my first partition would be "0,114688,6" and my second partition "114689,," (ie. all remaining space to be used by the second partition).

Alternatively, you can specify the "-uM" parameter when you use sfdisk so that you can then specify the partition sizes in terms of megabytes instead of cylinders, eg. to create a 3.5GB partion #1 with the remaining space* in partition #2, use the following:

#sfdisk /dev/mmcblk0 -uM

/dev/mmcblk0p1: 0,3500,0C
/dev/mmcblk0p2: 3500,,
/dev/mmcblk0p3:
/dev/mmcblk0p4:

Note: I've used a partition type of 0C on the first partition as this will create a FAT32 partition. When formatting the first partition for VFAT, use "mkfs.vfat /dev/mmcblk0p1 -F 32" if you want a FAT32 filesystem.

* Your 4GB card is unlikely to be 4GB in size as memory card manufacturers tend to use 1000 bytes to a K and 1000KB to a MB notation (rather than 2^10 or 1024 notation). Typically a "4GB" memory card will have between 3.7GB and 3.8GB usable space, which means that if you specify 3.5GB of space for the first partition you'll only have ~0.3GB (or less) space remaining for partition 2, in which case adjust the size of your first partition down by the amount of difference between your real card size and 4GB ie. if your card size is 3.8GB, use a figure of 3.3 (ie. 3.5 - 0.2) to calculate the cylinders, or 3300 when specifying the partition sizes in MB.

Last edited by Milhouse; 2007-10-11 at 22:50.