wblock@
Developer
Aligning MBR Partitions With 4K Drives
The Problem
The MBR specification says that partitions must be aligned to "cylinder" values. This works fine on old drives where each track had the same number of blocks, but drives like that have not been made in a decade or two. Modern drives pack more blocks in the longer, outer tracks. They have no real concept of cylinders, it's all just blocks.
FreeBSD aspires to be standards-compliant, so gpart(8) insists on rounding values for MBR partitions to something even. With the fake cylinder/heads/sectors (CHS) numbers provided for modern drives, this usually has the same effect as using -a 63 with gpart: partition boundaries are rounded to 63-block values. You can ask it to start an MBR partition at a specific place, but it probably will not go there. FreeBSD allocates the first 63 512-byte blocks to the MBR, probably due to CHS alignment.
The Problem, Part Two
New, large-capacity drives use 4K blocks to more efficiently deal with all that space. They use "logical" 512-byte blocks mapped into those 4K physical blocks to remain compatible with existing systems.
FreeBSD's UFS filesystem uses 4K blocks by default since FreeBSD 9.0 or so. This is fine if a filesystem block corresponds exactly with a physical block, and that's what we mean by "being aligned".
But what happens if they are not aligned? The UFS block overlaps two physical blocks. When the filesystem writes that 4K, it takes twice as long as necessary, because the drive must read one 4K block, change half of it, write it back out, and then do the same for the second block.
If you use the standard defaults, the first partition will start at block 63... misaligned.
Solution One: fdisk(8)
The old partitioning program fdisk(8) will actually let you enter arbitrary values for the starting block of an MBR partition ("slice"). It will complain if they are not CHS aligned, but still use them if you insist. Note: start your first filesystem partition at block 2048, or 1M. I've talked about reasons for that elsewhere.
Solution Two: Align FreeBSD Partitions Within The Slice
Use gpart(8) to try to create an MBR partition ("slice") starting at 2048. Usually, this results in a partition that starts at block 2079 (an even multiple of 63). Leave that alone, and create FreeBSD partitions inside the slice, but use -a to align them:
Extra space will be added before those partitions, so the partition itself ends up aligned.
The Problem
The MBR specification says that partitions must be aligned to "cylinder" values. This works fine on old drives where each track had the same number of blocks, but drives like that have not been made in a decade or two. Modern drives pack more blocks in the longer, outer tracks. They have no real concept of cylinders, it's all just blocks.
FreeBSD aspires to be standards-compliant, so gpart(8) insists on rounding values for MBR partitions to something even. With the fake cylinder/heads/sectors (CHS) numbers provided for modern drives, this usually has the same effect as using -a 63 with gpart: partition boundaries are rounded to 63-block values. You can ask it to start an MBR partition at a specific place, but it probably will not go there. FreeBSD allocates the first 63 512-byte blocks to the MBR, probably due to CHS alignment.
The Problem, Part Two
New, large-capacity drives use 4K blocks to more efficiently deal with all that space. They use "logical" 512-byte blocks mapped into those 4K physical blocks to remain compatible with existing systems.
FreeBSD's UFS filesystem uses 4K blocks by default since FreeBSD 9.0 or so. This is fine if a filesystem block corresponds exactly with a physical block, and that's what we mean by "being aligned".
But what happens if they are not aligned? The UFS block overlaps two physical blocks. When the filesystem writes that 4K, it takes twice as long as necessary, because the drive must read one 4K block, change half of it, write it back out, and then do the same for the second block.
If you use the standard defaults, the first partition will start at block 63... misaligned.
Solution One: fdisk(8)
The old partitioning program fdisk(8) will actually let you enter arbitrary values for the starting block of an MBR partition ("slice"). It will complain if they are not CHS aligned, but still use them if you insist. Note: start your first filesystem partition at block 2048, or 1M. I've talked about reasons for that elsewhere.
Solution Two: Align FreeBSD Partitions Within The Slice
Use gpart(8) to try to create an MBR partition ("slice") starting at 2048. Usually, this results in a partition that starts at block 2079 (an even multiple of 63). Leave that alone, and create FreeBSD partitions inside the slice, but use -a to align them:
gpart add -t freebsd-ufs -a4k -s20g ada0s1
Extra space will be added before those partitions, so the partition itself ends up aligned.