Partition alignment

Warren Block wblock at wonkity.com
Wed Mar 26 21:59:29 UTC 2014


On Wed, 26 Mar 2014, Andrea Venturoli wrote:
>> root@:~ # gpart show /dev/mfid0
>> =>        63  1751949249  mfid0  MBR  (835G)
>>           63  1751936382      1  freebsd  [active]  (835G)
>>   1751936445       12867         - free -  (6.3M)
>
>> root@:~ # gpart show /dev/mfid0s1
>> =>         0  1751936382  mfid0s1  BSD  (835G)
>>            0    16777216        4  freebsd-ufs  (8.0G)
>>     16777216    33554432        2  freebsd-swap  (16G)
>>     50331648    67108864        5  freebsd-ufs  (32G)
>>    117440512    33554432        6  freebsd-ufs  (16G)
>>    150994944   536870912        7  freebsd-ufs  (256G)
>>    687865856   536870912        8  freebsd-ufs  (256G)
>>   1224736768    33554432        1  freebsd-ufs  (16G)
>>   1258291200   493645182           - free -  (235G)
>
> AFAICT the partition are correctly aligned within the slice, but I'm not sure 
> about the slice itself.

No.  The starting blocks of the slice and partition are added together 
to determine the actual start block of the partition:

The first partition begins at 63+0, or 63.  63*512 = 32256, not evenly 
divisible by 4K.  Or just divide the block number by 8, same thing.

When creating the partitions, use gpart's -a option, and it will add an 
offset so the slice is aligned:

gpart add -t freebsd-ufs -a4k -s8g mfid0s1

That will make the first partition start at the first aligned offset in 
the slice, probably block 1 or 9.

Use GPT if you can, it simplifies this by not needing the partition with 
a partition scheme.


More information about the freebsd-questions mailing list