On 2016-06-13, Chris Cappuccio <ch...@nmedia.net> wrote: > c. You must start the first partition past block 0, block 64 > is standard for various reasons.
I think we should consider changing this. Most mechanical drives these days have 4KB sectors (though many hide it with synthetic 512 byte sectors) which work OK with fdisk and disklabel's defaults, but other storage devices have larger natural boundaries. RAID stripe sizes are often a power-of-two >=64KB and 256KB/512KB is not uncommon for a flash erase block. Straddling two of these boundaries is suboptimal for performance and, in the case of flash, longevity. These days I usually manually align to multiples of 2048 sectors (1MB), which keeps the maths simple and matches what Microsoft have been doing for drives of over 4GB since Vista/2008, VMware VMFS-5 (since ESXi 5), and various Linux utilities if DOS compatibility mode is not used. (https://www.thomas-krenn.com/en/wiki/Partition_Alignment has a pretty good write-up). Diffs only meant as a starting point for discussion or for people experimenting, but as a minimal change automating this in disklabel could be done as something like this, Index: disklabel/editor.c =================================================================== RCS file: /cvs/src/sbin/disklabel/editor.c,v retrieving revision 1.300 diff -u -p -r1.300 editor.c --- disklabel/editor.c 10 Dec 2015 17:26:59 -0000 1.300 +++ disklabel/editor.c 14 Jun 2016 10:32:34 -0000 @@ -2070,8 +2070,7 @@ align: orig_size = DL_GETPSIZE(pp); orig_offset = DL_GETPOFFSET(pp); - bsize = (DISKLABELV1_FFS_FRAG(pp->p_fragblock) * - DISKLABELV1_FFS_FSIZE(pp->p_fragblock)) / lp->d_secsize; + bsize = 2048; if (DL_GETPOFFSET(pp) != starting_sector) { /* Can't change offset of first partition. */ adj = bsize - (DL_GETPOFFSET(pp) % bsize); (disklabel normally also rounds size down to a multiple of the cylinder size if you enter values in anything other than sectors. The reported C/H/S geometry hasn't borne any relation to real geometry in most cases for years so it might be worth looking at removing that too, but that's done before bsize-rounding so it's just making partitions smaller than requested in some cases, rather than causing alignment problems.) One possible fdisk diff below, though I'm not sure the power-of-2 makes sense if aligning to 1MB boundaries. Index: fdisk/mbr.c =================================================================== RCS file: /cvs/src/sbin/fdisk/mbr.c,v retrieving revision 1.65 diff -u -p -r1.65 mbr.c --- fdisk/mbr.c 30 Dec 2015 17:21:39 -0000 1.65 +++ fdisk/mbr.c 14 Jun 2016 10:43:03 -0000 @@ -145,8 +145,11 @@ MBR_init(struct mbr *mbr) } #endif - /* Start OpenBSD MBR partition on a power of 2 block number. */ - i = 1; + /* + * Start OpenBSD MBR partition on a power of 2 block number + * with a minimum 2048-block alignment. + */ + i = 2048; while (i < DL_SECTOBLK(&dl, mbr->part[3].bs)) i *= 2; adj = DL_BLKTOSEC(&dl, i) - mbr->part[3].bs;