gpart rewrites pmbr in a way which breaks Win 7 EFI bootloader

Lawrence Stewart lstewart at freebsd.org
Fri Aug 10 01:14:13 UTC 2012


On 08/10/12 00:20, Andrey V. Elsukov wrote:
> On 09.08.2012 16:11, Lawrence Stewart wrote:
>>>> - Should gpart be writing 0x80 (active) in the protective MBR entry?
>>>
>>> AFAIK, this was added because some BIOS could not boot without it.
>>
>> Makes sense if gpart is writing the pmbr out i.e. "gpart bootcode -b
>> /boot/pmbr <geom>", but manipulating an existing pmbr for a GPT specific
>> subcommand smells dodgy to me.
> 
> When you create GPT it already has PMBR, because it is part of GPT
> metadata. gpart's `bootcode' subcommand writes *bootcode* to specific
> area in the PMBR.

Right, I had a fundamental misunderstanding about the relationship
between the pmbr and GPT. Thanks to you and Marcel for setting me
straight on this.

>>>>   - Why is Windows EFI bootloader so sensitive to 0x80 in pmbr?
>>>
>>> This question you should ask to the Microsoft. :)
>>
>> Perhaps I should rephrase my question as:
>>
>> Is the MS bootloader's behaviour reasonable/unreasonable based on what
>> people know of the relevant specs? My current guess why it behaves like
>> this is that if it sees an MBR partition marked active, it simply
>> assumes another OS is in charge and therefore bails out at the Windows
>> EFI boot stage.
> 
> In the EFI system partition might be several boot loaders, and this MS
> bootloader's behaviour seems strange to me.
> 
>> Can and should are two different things. I would argue it's a POLA
>> violation at the very least to manipulate the pmbr when the user asked
>> for something else. I certainly started my hunting expecting to find the
>> GPT changing in some subtle way when FreeBSD wrote it out compared to
>> what Windows writes.
>>
>> We have a specific gpart command to put a pmbr in place so I think it's
>> reasonable to expect other GPT specific commands not to fiddle with the
>> pmbr.
> 
> Don't confuse bootcode in the PMBR and PMBR.

Despite my misunderstanding about the relationship between the pmbr and
GPT, I still stand by my assertion that gpart is not behaving very well
here, but more on that in my follow up to Marcel.

Cheers,
Lawrence


More information about the freebsd-fs mailing list