Removing PMBR

SirDice

Administrator
Staff member
Administrator
Moderator
I have a Windows 7 system using GPT and UEFI boot. I tried to install FreeBSD with ZFS but I seem to have buggered it up :(

FreeBSD boots fine but Windows is now broken. I think its because I did:
# gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 4
(The freebsd-boot partition has id 4)

I probably shouldn't have added the -b /boot/pmbr as that writes a MBR to the first sector on the disk. I'm guessing that because of that my BIOS defaults to a BIOS boot instead of EFI boot.

Just to be clear, I'm not trying to get FreeBSD to EFI boot, I know that doesn't work. I just want to restore my Windows again. Removing all FreeBSD partitions didn't help.

# dd if=/dev/zero of=/dev/ada0 bs=512 count=1
That also destroys my partition table :(

# dd if=/dev/zero of=/dev/ada0 bs=446 count=1
Results in a weird error message, something about an illegal option.

When I get home I'm going to try to use gpart backup to save the table, dd the first 512 bytes and restore the table from backup. Hopefully that works.

If anybody else has any suggestions, I'm all ears.
 
I'm definitely going to try that, if all else fails, I know which byte to change on disk.
 
Ha! Success!

Unfortunately, both suggestions didn't work. gpart(8) doesn't accept active as an attribute on GPT. In hind sight understandable, I needed to remove the active bit from the 'fake' MBR partition. So, I also though about fdisk(8), but, although you can set any partition active, you can't unset it.

I ended up using editors/chexedit and dd(1) :

Code:
# dd if=/dev/ada0 of=ada0.backup bs=512 count=1
# cp ada0.backup ada0.copy
# chexedit ada0.copy
# dd if=ada0.copy of=/dev/ada0 bs=512 count=1

With chexedit(1) I changed byte 0x1be from 0x80 to 0x00. And rebooted...

Dammit, still booting straight to FreeBSD...

This turns out to be a BIOS/UEFI thing. Hitting F8 for the BIOS/UEFI boot selector did show my UEFI Windows 7. And it boots perfectly. Setting it to boot "EUFI only" always boots Windows 7 and I can't select FreeBSD with F8. Setting it to "UEFI and Legacy" boots FreeBSD and gives me the option to boot windows. I've also played a little with rEFInd but couldn't figure out how to boot FreeBSD with it. Still working on that. For the time being it's enough, it's getting late, again x(

But, I did learn a lot about the details of MBR, GPT and UEFI :stud
 
Despite the old thread date I am curious if you've done some more research on this? I am still searching for the best combination of partitioning and boot codes for dual booting FreeBSD and Linux or Windows.
 
Back
Top