Grub2 not recognise GPT when presence hybrid MBR

Bug #998097 reported by Stas Davydov
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Root issue:
 grub ignore protective GPT record if that record is not the first one in MBR.
Need to correct:
 If protective GPT record appears on any place in MBR - grub must consider system as GPT.

I have hybrid GPT/MBR. Hybrid MBR contains protective record 0xEE but that record is NOT first.
Here is output of gdisk (hybrid MBR):
Number Boot Start Sector End Sector Status Code
   1 468992 101480447 primary 0x07
   2 234375168 234569727 primary 0xEF
   3 * 550782882 574927413 primary 0x83
   4 1 468991 primary 0xEE

gdisk (GPT):
Number Start (sector) End (sector) Size Code Name
   1 2048 206847 100.0 MiB EF00 EFI system partition
   2 206848 468991 128.0 MiB 0C01 Microsoft reserved part
   3 468992 101480447 48.2 GiB 0700 win7
   4 101480448 138344447 17.6 GiB AF00 other
   5 390625280 527343615 65.2 GiB 8301 copyfilesWIN7
   6 527343616 550780927 11.2 GiB AF00 backupfile
   7 581042176 625141759 21.0 GiB 2700 Samsung_diag
   8 138344448 234375167 45.8 GiB 0700 DATA
  11 574927414 581042175 2.9 GiB 8200
  12 234375168 234569727 95.0 MiB EF02 grub
  13 550782882 574927413 11.5 GiB 0700 linux

After that it result in such errors:
root@helena:~# grub-install /dev/sda
/usr/sbin/grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!.
/usr/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged..
/usr/sbin/grub-setup: error: will not proceed with blocklists.

invoking grub-mkconfig manually gives:
root@helena:~# grub-mkconfig -o test.conf
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-24-generic
Found initrd image: /boot/initrd.img-3.2.0-24-generic
Found linux image: /boot/vmlinuz-3.0.0-19-generic
Found initrd image: /boot/initrd.img-3.0.0-19-generic
Found linux image: /boot/vmlinuz-2.6.38-14-generic
Found initrd image: /boot/initrd.img-2.6.38-14-generic
Found linux image: /boot/vmlinuz-2.6.38-8-generic
Found initrd image: /boot/initrd.img-2.6.38-8-generic
Found memtest86+ image: /boot/memtest86+.bin
grub-probe: error: cannot find a GRUB drive for /dev/sda4. Check your device.map.
grub-probe: error: cannot find a GRUB drive for /dev/sda5. Check your device.map.
grub-probe: error: cannot find a GRUB drive for /dev/sda6. Check your device.map.
grub-probe: error: cannot find a GRUB drive for /dev/sda7. Check your device.map.
done

I have tried diferent approach - was removed hybrid MBR (retained only protective record). After that grub-install succeed. After that I have created hybrid MBR (the same as above).
But after reboot I have got "grub rescue" prompt and error: no such partition.

root@helena:~# lsb_release -rd
Description: Ubuntu 12.04 LTS
Release: 12.04

root@helena:~# apt-cache policy grub-pc
grub-pc:
  Installed: 1.99-21ubuntu3
  Candidate: 1.99-21ubuntu3
  Version table:
 *** 1.99-21ubuntu3 0
        500 http://ua.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
        100 /var/lib/dpkg/status

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: grub-pc 1.99-21ubuntu3
ProcVersionSignature: Ubuntu 2.6.38-14.58-generic 2.6.38.8
Uname: Linux 2.6.38-14-generic x86_64
ApportVersion: 2.0.1-0ubuntu7
Architecture: amd64
Date: Fri May 11 17:45:17 2012
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Release amd64+mac (20110426)
SourcePackage: grub2
UpgradeStatus: Upgraded to precise on 2012-05-07 (3 days ago)
---
ApportVersion: 2.0.1-0ubuntu13
Architecture: amd64
DistroRelease: Ubuntu 12.04
InstallCmdLine: file=/cdrom/preseed/ubuntu.seed vga=788 initrd=/install/initrd.gz quiet -- debian-installer/language=ru keyboard-configuration/layoutcode=ru
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Release amd64+mac (20110426)
Package: ubiquity 2.10.20
PackageArchitecture: amd64
ProcVersionSignature: Ubuntu 3.2.0-30.48-generic 3.2.27
Tags: precise
Uname: Linux 3.2.0-30-generic x86_64
UpgradeStatus: Upgraded to precise on 2012-05-07 (131 days ago)
UserGroups:

Revision history for this message
Stas Davydov (stas-davydov) wrote :
Revision history for this message
YannUbuntu (yannubuntu) wrote :

Hello
Do you still have this issue with a fresh 12.04.1 liveCD ?

if yes, please indicate your Boot-Info URL ( https://help.ubuntu.com/community/Boot-Info )

Revision history for this message
Stas Davydov (stas-davydov) wrote : Re: [Bug 998097] Re: Grub2 not recognise GPT when presence hybrid MBR
Download full text (3.2 KiB)

Hello, YannUbuntu.

Yes. I still have this problem.

Here is link for my boot-info:
http://paste.ubuntu.com/1207043/

Let me ephesize my statement:
If protective GPT record become first - then problem does not appears. It
appears only if it is NOT first.
Reason why I placed it NOT first - becouse my bios (which support UEFI)
refuse to run MBR boot in case it detect protective GPT record.

I have disabled UEFI in bios and using old fashion MBR boot.
I have performed dist-upgrade so here are updated info:

root@helena:~# apt-cache policy grub-pc
grub-pc:
  Installed: 1.99-21ubuntu3.1
  Candidate: 1.99-21ubuntu3.1
  Version table:
 *** 1.99-21ubuntu3.1 0
        500 http://ua.archive.ubuntu.com/ubuntu/ precise-updates/main amd64
Packages
        100 /var/lib/dpkg/status
     1.99-21ubuntu3 0
        500 http://ua.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages

And here are info on version of GRUB
root@helena:~# dlocate -l grub
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err:
uppercase=bad)
||/ Name Version Description
+++-=============================-=============================-============================================================================
un grub <none> (no
description available)
ii grub-common 1.99-21ubuntu3 GRand
Unified Bootloader (common files)
un grub-coreboot <none> (no
description available)
un grub-doc <none> (no
description available)
un grub-efi <none> (no
description available)
rc grub-efi-amd64 1.99-12ubuntu5 GRand
Unified Bootloader, version 2 (EFI-AMD64 version)
ii grub-efi-amd64-bin 1.99-21ubuntu3 GRand
Unified Bootloader, version 2 (EFI-AMD64 binaries)
un grub-efi-ia32 <none> (no
description available)
un grub-emu <none> (no
description available)
ii grub-gfxpayload-lists 0.6 GRUB
gfxpayload blacklist
un grub-ieee1275 <none> (no
description available)
un grub-legacy <none> (no
description available)
un grub-legacy-doc <none> (no
description available)
un grub-linuxbios <none> (no
description available)
ii grub-pc 1.99-21ubuntu3 GRand
Unified Bootloader, version 2 (PC/BIOS version)
ii grub-pc-bin 1.99-21ubuntu3 GRand
Unified Bootloader, version 2 (PC/BIOS binaries)
un grub-yeeloong <none> (no
description available)
un grub2 <none> (no
description available)
ii grub2-common 1.99-21ubuntu3 GRand
Unifi...

Read more...

Revision history for this message
YannUbuntu (yannubuntu) wrote :

/bootmgr and /boot/bcd are present in sda1, so Windows is installed in Legacy mode (although the disk is GPT). The problem is that Ubuntu was installed in EFI mode, when it should have been installed in Legacy mode.
This may be a duplicate of Bug #1050940 .

1) When you installed Ubuntu, which choice did you choose at this screen? ( http://pix.toile-libre.org/upload/original/1312973605.png )

2) Please could you boot your installed Ubuntu, login to your Launchpad account, then type the following command in a terminal:
apport-collect -p ubiquity 998097
This will collect and add information to this report.

Revision history for this message
Stas Davydov (stas-davydov) wrote : Dependencies.txt

apport information

tags: added: apport-collected
description: updated
Revision history for this message
Stas Davydov (stas-davydov) wrote : ProcEnviron.txt

apport information

Revision history for this message
Stas Davydov (stas-davydov) wrote : UbiquityPartman.txt

apport information

Revision history for this message
Stas Davydov (stas-davydov) wrote : UbiquitySyslog.txt

apport information

Revision history for this message
YannUbuntu (yannubuntu) wrote :

Thanks.
Do you remember which choice you chose at this screen ( http://pix.toile-libre.org/upload/original/1312973605.png ) when you installed Ubuntu ?

Revision history for this message
Stas Davydov (stas-davydov) wrote :

>> Do you remember which choice you chose at this screen ( http://pix.toile-libre.org/upload/original/1312973605.png ) when you installed Ubuntu ?

I have performed manual partition of disk.

I do NOT tring to create dualboot - so it is not like Bug #1050940 .
The only I want is to load Ubuntu on GPT partition in legacy mode.
I have set of problems with it which I identify as limitations (bugs?) in GRUB2 and kernel:
1. ( in grub-install) Grub2 refuse to "grub-install /dev/sda" if protective GPT entry is NOT the first.
This bug could be workarounded with method described in bug 2.

2. ( in grub booting - core.img? )I could do grub-install IF protective GPT entry is the first, and to rearainge order of records in MBR so it become not first - but in this case GRUB failed to detect GPT during booting.
During boot shown:
error: no such partition
grub rescue> ls
(hd0)

3. ( in grub-install) IF I do protective record start from sector 2048 - then I could install GRUB in "biosdisk" (?) mode but in this case it installed it data (102 sectors) starting from sector 1 and so corrupt GPT header. I assume that is stage1.5/core.img data ?

4. ( in kernel?) with setup when GPT protective record is NOT first and starts from sector 2048 kernel not able recognise hybrid partition table. in dmesg I see:
[sda]: unknown partition table
same time gdisk sees correct GPT and hybrid MBR

Most correct approach - will be to resolve bug 2. But guess that reqires re-working ASM code.

For now I am trying diferent approach - boot core.img in biosdisk mode and then load correct module (part_gpt) through (hd0,msdos2) and then perform father actions through (hd0,gptN).
For that I need to find way to force GRUB install it stage1.5 not to sector 1 (resolve bug 3) .
I guess for that needed to tweak (or hack) boot.img to point it to new place of core.img

I could easily migrate stage1.5/core.img to diferent place with "dd" - but I do not know how point that place for stage1/boot.img

I see that size of stage1.5 is 51kB(102 sectors) so if I place it starting from sector 1901 it will be good enough. Another option is to use partition gpt12 (EF02) but then either grub must recognise GPT partition table (see bug 2) or point for stage 1 it location in biosdisk mode.

Revision history for this message
YannUbuntu (yannubuntu) wrote :

"I have performed manual partition of disk." --> ok. So it's definitely not Bug #1050940 .

"The only I want is to load Ubuntu on GPT partition in legacy mode." --> for this, you need a BIOS-Boot partition. If you haven't, grub-install will return the error you observed in your bug description.

Revision history for this message
Stas Davydov (stas-davydov) wrote :

>> for this, you need a BIOS-Boot partition.

I have it all the time.
See partition gpt12 - it has code EF02 so is BIOS-Boot partition.

Revision history for this message
YannUbuntu (yannubuntu) wrote :

ok thanks.
Last idea: placing your boot files at the start of the disk (in case you were affected by Bug #1030887 ):
1) via Windows tools, reduce Windows partition from 51.7GB to 50GB, in order to create 2GB free space between sda2 and sda3.
2) in this free space, create a 1GB EXT4 partition , and a new BIOS-Boot partition. (you can delete the old one)
3) Make your Ubuntu use the 1GB EXT4 partition as separate /boot (see https://help.ubuntu.com/community/BootPartition )
4) Please reboot and indicate if you can reproduce the bug.

Necrodust (necrodust44)
information type: Public → Public Security
Revision history for this message
Necrodust (necrodust44) wrote :
information type: Public Security → Public
Revision history for this message
Necrodust (necrodust44) wrote :

Also, if you have an encrypted root, and GRUB 1.98 does not recognize it, remove the following lines in the /util/getroot.c file.

   if (ent->d_name[0] == 'd' &&
       ent->d_name[1] == 'm' &&
       ent->d_name[2] == '-' &&
       ent->d_name[3] >= '0' &&
       ent->d_name[3] <= '9')
     continue;

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in grub2 (Ubuntu):
status: New → Confirmed
Revision history for this message
Grief (iamgrief) wrote :

Look here: http://savannah.gnu.org/bugs/?28149
"GRUB2 supports hybrid GPT. It has even a tool gptsync for manipulating MBR of hybrid GPT. However Hybrid GPT has to have protective entry in MBR as its first entry and I see no reason to break this rule, especially that hybrid GPT is just a kludge for legacy systems and often is worse as either GPT or MSDOS. So your partition table is just invalid. Contact the developpers of whatever tool created it and say that protective entry has to be the first one"

Revision history for this message
Mate Kukri (mkukri) wrote :

Per the above upstream comment, closing as 'Invalid'.

Additionally there is basically no reason to use hybrid GPT on modern systems.

Changed in grub2 (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.