I have been trying to partition this SSD (Samsung 840) nicely for a while now. I want to make sure the pages line up with the SSD pages to limit the amount of writes. I found this site which recommends using 224 heads and 56 sectors.

I already have an sfdisk dump that I want to replicate, but move the starting partition up a bit (I think). It's measured in sectors and I am getting quite confused moving between sectors, heads, cylinders and everything (my mate gave me the 2048 starting number):

# partition table of /dev/sdb
unit: sectors

/dev/sdb1 : start=     2048, size=   995329, Id=83, bootable
/dev/sdb2 : start=   997377, size= 10242047, Id=83
/dev/sdb3 : start= 11239424, size= 24611328, Id=83
/dev/sdb4 : start= 35850752, size= 67223296, Id= 5
/dev/sdb5 : start= 35850808, size= 10235848, Id=83
/dev/sdb6 : start= 46086712, size= 56987336, Id=83

So I've been throwing that layout at the disk using sudo sfdisk -H224 -S56 /dev/sdb < sfdisk.dump. But in the aforementioned link the guy says that he makes sure his partition starts on cylinder 2 to ensure it's on a cylinder boundary.

I tried to check my starting cylinder and it is on 0 :(

$ sudo sfdisk -l -uC /dev/sdb        

Disk /dev/sdb: 18689 cylinders, 224 heads, 56 sectors/track
Units = cylinders of 6422528 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdb1   *      0+     79-     80-    497664+  83  Linux
/dev/sdb2         79+    895     817-   5121023+  83  Linux
/dev/sdb3        896    2857    1962   12305664   83  Linux
/dev/sdb4       2858    8216    5359   33611648    5  Extended
/dev/sdb5       2858+   3673     816-   5117924   83  Linux
/dev/sdb6       3674+   8216    4543-  28493668   83  Linux

I also want to resize some of the partitions but converting between cylinders, heads, sectors and megabytes seems inconsistent and is doing my head in. I've done a load of googling but still cannot make sense of how to construct the partitions or calculate the geometries.

I also tried the other way to configure sfdisk:

echo "2,512,83,*
"|sudo sfdisk -uM -H224 -S56 /dev/sdb

And tried upping the megabytes for - and checking the - starting cylinder position but can only get to 6 megabytes before it has a shitfit (Warning: given size (5005) exceeds max allowable size (6)) and I'm still on cylinder zero.

Disk geometry man! How does it work!?

Is there an easier way? Does anyone have any formulas for calculating between the geometry types? Anyone know a good tutorial to link me to? Has anyone done this before for their SSD?

Kind Regards


On an MBR disk, sector values are stored in two ways:

  • In CHS format -- The cylinder/head/sector (CHS) format uses a weird 24-bit encoding to hold sector values. Doing a little math, 2^24 * 512 bytes = 8GiB. (In fact, the true CHS limit is a bit lower than this because not all CHS values are legal.) Note that's 8 GiB, which is well under the total capacity of most modern disks (even SSDs), meaning that CHS encoding is useless and therefore ignored for most purposes today. Focusing on CHS values and on CHS geometries (which determine the maximum cylinder, head, and sector values for a disk) is therefore a waste of time.
  • In LBA format -- The Linear (or Logical) Block Addressing (LBA) format uses a single 32-bit value to specify sectors. 2^32 * 512 bytes = 2TiB, hence the 2TiB limit on MBR. This is big enough for all modern SSDs and even many modern spinning disks; but bigger modern disks require the newer GPT partitioning system, which uses 64-bit LBA values and no CHS values.

In the past, partitions were aligned on cylinder values because this could improve performance on disks of that era (in the 1980s and perhaps the early 1990s). Since then, cylinder alignment has been common just out of habit and for backwards compatibility, but it hasn't really served any purpose. Today, cylinder alignment is detrimental because newer technologies (SSDs, certain types of RAID arrays, and Advanced Format disks) work better with alignment on some power-of-2 multiple of sectors (8, 512, 2048, etc.), but the details differ from one disk type to another. Most modern partitioning tools align at least the first partition on a multiple of 2048 sectors by default because this works well for most modern disks; however, some SSDs require still larger values, such as 4096 or even 8192. If you can get the technical details on your SSD, you can learn what its requirements are. If not, try using a default alignment value of 2048, 4096, or 8192.

My proficiency with sfdisk is limited (I've never liked its command set), so I can't say precisely how to do this with the tool, except to give general advice: Specify partition start and end points in sectors, not in cylinders. If you're setting things up manually, pull out a pocket calculator (or use a calculator desktop app) and ensure that partitions start on values that are evenly divisible by the alignment value you use. The end points aren't important, except insofar as you probably want them to end one sector before the next start point, in order to minimize wasted space.

Both parted and gdisk do more to enforce partition alignment than does fdisk (and I suspect sfdisk). Thus, you might want to consider using one of these tools -- but gdisk works only on GPT disks, so you should use it only if you want to switch to GPT from MBR.

|improve this answer|||||
  • What a terrific breakdown, thank you very much! One question though, the alignment value I am using to divide by would be the sector count (for instance 56 in my above example)? – hamstar Aug 27 '13 at 21:21
  • When using the obsolete CHS modes, typically the first partition begins on the sector value, but subsequent partitions begin on the sector * heads value. The idea is to begin most partitions on the first sector of the first platter, with an exception being the first partition, which is begun earlier so as to minimize the space wasted at the start of the disk. This is all rather confusing, though, and as CHS is now nearly useless, it's best to use tools that use LBA addresses natively and ignore the CHS values. – Rod Smith Aug 29 '13 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.