gpart usage

Victor Balada Diaz victor at
Tue May 24 13:36:03 UTC 2011


I'm trying to setup a MBR partition with a BSD slice in it using gpart on
FreeBSD 8.1 RELEASE. From the fixit console in the install i try to do

gpart create -s MBR ad0
gpart add -t freebsd ad0
gpart create -s BSD ad0s1
gpart add -t freebsd-ufs ad0s1
gpart set -a active -i 1 ad0

For bootcode i do:
gpart bootcode -b /boot/boot0 /dev/ad0
gpart bootcode -b /boot/boot /dev/ad0s1

This seems to work, but i have doubts about it. For example, looking at:

I can see that it leaves a 16 sectors offset. Can't find anything about it
on gpart man page, but i did find on bsdlabel man page the following:

     offset  The offset of the start of the partition from the beginning of
             the drive in sectors, or * to have bsdlabel calculate the correct
             offset to use (the end of the previous partition plus one, ignor-
             ing partition `c').  For partition `c', * will be interpreted as
             an offset of 0.  The first partition should start at offset 16,
             because the first 16 sectors are reserved for metadata.

So seems they're needed. Looking at what sysinstall did on a 8.0 install i can
see the following:

%gpart show
=>       63  285155262  da0  MBR  (136G)
         63  285153687    1  freebsd  [active]  (136G)
  285153750       1575       - free -  (788K)

=>        0  285153687  da0s1  BSD  (136G)
          0    2097152      1  freebsd-ufs  (1.0G)
    2097152    8388608      2  freebsd-swap  (4.0G)
[ more skipped ]

Ie, no 16 sector offset in it. So my question is... What's the proper way of
doing a MBR + BSD label partition and where is it documented? what are the different
bootcodes and when is needed each one?[1] also, how do i know about offsets each
partitioning scheme needs? shouldn't GEOM take care of it without user needing to
know anything about it?

If i wanted to also align partition to 1 MB offsets so i can get better performance
with advanced format drives and RAID controllers, what would be the best option?
I guess that i would need to add the first freebsd-ufs partition starting at 1985
sector, because 1 MB = 2048 512byte sector, and 63 are reserved for MBR scheme
so 2048 - 63 = 1985. Is this right or i'm mistaken in something?

Seems that gpart man page only documents doing it with GPT and doesn't talk
about alignment constraints, but i can't use GPT because i want to do it over
gmirror and last sector is used by gpt and gmirror at the same time causing
some warnings[2].

It would be great if handbook's GEOM chapter would have some part about
using gpart, but of course it's easier asking for it than actually writting it.

Thanks a lot.

[1]: I know handbook does have some info about /boot/boot0, boot1 and boot in
"The Boot Manager and Boot Stages", but i can't find info about for example
gptboot or gptzfsboot.

[2]: Yes i know that i can create the GPT scheme and then gmirror the partitions
but then, i can't use with the same speed the gmirror load algorithms over both
disks so i prefer to gmirror the whole device.

La prueba más fehaciente de que existe vida inteligente en otros
planetas, es que no han intentado contactar con nosotros. 

More information about the freebsd-stable mailing list