Bug 744496

Summary: error installing bootloader, F16beta LiveCD, dual boot Mac OS: anaconda blows away hybrid MBRs when formatting a disk as GPT
Product: [Fedora] Fedora Reporter: Chris Murphy <bugzilla>
Component: anacondaAssignee: Anaconda Maintenance Team <anaconda-maint-list>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 16CC: anaconda-maint-list, awilliam, bcl, djvasi, info, jonathan, pjones, tflink, vanmeeuwen+fedora
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-10-18 01:10:32 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 713568    
Attachments:
Description Flags
anaconda log
none
messages log
none
anacondalog from LiveCD /tmp post install
none
ifcfglog from LiveCD /tmp post install
none
programlog from LiveCD /tmp post install
none
storagelog from LiveCD /tmp post install none

Description Chris Murphy 2011-10-08 22:55:25 EDT
Description of problem:

Installing from Fedora 16 Beta Live CD onto a computer with an existing operating system, results in a message near the end of installation:

"There was an error installing the bootloader.
the system may not be bootable."

The system is not bootable upon restart.

Version-Release number of selected component (if applicable):
Fedora 16 beta

How reproducible:
100%

Steps to Reproduce:
1. Reformat the hard disk using Disk Utility, one jhfs+ partition labeled Banana.
[result is sda1=EFI System Partition and sda2=Banana]
2. Install on sd2 "Banana" Mac OS X 10.7.0 Lion.
[result is additional creation of sda3=Recovery HD]
3. Used Bootcamp to non-destructively create an additional partition for Linux. Idea being that most Mac users intended dual boot would use this tool rather than repartitioning their disk.
[result is additional creation of sda4=BOOTCAMP]
4. Reboot from Fedora 16 beta Live CD (making this a CSM/BIOS boot).
5. Used parted to remove sda4 so that it's unallocated free space.
6. Installation type set to "Use Free Space", allowed the installer to determine all partition settings.

Resulting partition:
sda1=EFI System Partition
sda2=Banana (Mac OS X)
sda3=Recovery HD (Mac OS X)
sda4=no label, but flagged bios_grub
sda5=no label, set to boot
sda6=no label, set to lvm
  
Actual results:
Installation itself completes, resizing of lv_root completes, installation of bootloader appears to fail.
"There was an error installing the bootloader.
the system may not be bootable."

Upon reboot, the Fedora system is not a boot option.

Expected results:
Ability to boot Fedora.

Additional info:
1. On the same hardware, with a completely wiped disk (no partitions, all space unallocated), and had the Live CD do a "Use All Space" type of installation. This worked fine. The bug is with the dual boot configuration somehow causing a problem installing the bootloader.

2. So the questions: Must bios_grub partition be sda1? Or is sda4 acceptable as in this case? Must there be either an EFI System Partition or a bios_grub partition? Or is both acceptable?

The hardware kind dictates this, or similar, configuration. Mac OS "requires" the EFI System Partition (primarily just for firmware updates for Apple hardware) and EFI booting. Whereas due to nouveau/EFI conflict, it's necessary to use CSM/BIOS booting of Fedora.
Comment 1 Chris Murphy 2011-10-08 22:59:17 EDT
Created attachment 527061 [details]
anaconda log

Error installing the bootloader message occurred at 19:03ish in this log. At that time the only message recorded is:
19:03:00,106 ERR anaconda: would have run ['--quiet', '--nostart', '-f', '--service=ssh']
Comment 2 Chris Murphy 2011-10-08 23:05:23 EDT
Created attachment 527062 [details]
messages log

At the time of the error installing bootloader message, these suspicious items were recorded:

First:
Oct  8 21:02:56 localhost program: grubby fatal error: unable to find a suitable template

Second (actual writing of bootloader)
Oct  8 21:03:00 localhost program: Running... grub2-set-default Fedora Linux, with Linux 3.1.0-0.rc6.git0.3.fc16.x86_64
Oct  8 21:03:00 localhost program: Running... grub2-mkconfig -o /boot/grub2/grub.cfg
Oct  8 19:03:01 localhost dbus-daemon[995]: Exception TypeError: "'NoneType' object is not callable" in <function _removeHandlerRef at 0x1376050> ignored
Oct  8 21:03:02 localhost program: Generating grub.cfg ...
Oct  8 21:03:02 localhost program: cat: /boot/grub2/video.lst: No such file or directory

Third (many entries including these):
Oct  8 21:03:05 localhost kernel: [ 1178.449285] attempt to access beyond end of device
Oct  8 21:03:05 localhost kernel: [ 1178.449292] sda4: rw=2048, want=57835, limit=2048
[repeating]

Oct  8 21:03:05 localhost kernel: [ 1178.449783] attempt to access beyond end of device
Oct  8 21:03:05 localhost kernel: [ 1178.449785] sda4: rw=0, want=57853, limit=2048
Oct  8 21:03:05 localhost kernel: [ 1178.449787] FAT-fs (sda4): Directory bread(block 57852) failed
[repeating]

sda4 is the small partition flagged as bios_grub.
Comment 3 Chris Murphy 2011-10-09 03:35:41 EDT
When I redo this with a blank GPT, and use the "Use All Space" option, and reinstall, I end up with the 1st and 2nd errors listed in comment 2, but none of the third series of errors (which consume quite a bit of space in the posted messages files).

It seems the partition code is set incorrectly by the installer for the 500MB ext4 boot partition no matter whether I use the Use All Space or Use Free Space option. It is set to EF00, according to gdisk, which is EFI System, GUID code C12A7328-F81F-11D2-BA4B-00A0C93EC93B. It seems that it should be set to 8300, Linux filesystem, GUID code 0FC63DAF-8483-4772-8E79-3D69D8477DE4.

Presently, the installer using "Use Free Space" is causing two EFI System partitions to exist on the disk simultaneously.
Comment 4 Chris Murphy 2011-10-10 00:50:24 EDT
If I change the partition code for sda2 (the 500MB ext4 boot partition) from EF00 to 8300, it makes no difference, the computer is still not bootable.

If I change the protective MBR to hybrid MBR, no change, computer is still not bootable.

***If I set the 500MB ext4 boot partition boot flag in the MBR to "bootable", computer is now bootable.***

I think possibly Apple's EFI may only present a disk to the CSM for BIOS boot if it detects both MBR and a boot flagged partition.
Comment 5 Chris Murphy 2011-10-10 05:02:25 EDT
Consolidation of issues in this bug report:

1. When starting from a blank disk, the installer consistently makes a GPT only disk with the 500MB ext4 /boot partition set to type EF00 instead of 8300. This clearly seems like a bug.

2. "error installing bootloader message" when there is a pre-existing Mac OS installation, and using "Use Free Space" to install Fedora 16 beta. Error does not occur when starting with a blank disk. This also seems like a bug.

3. In any case (Fedora only or dual OS), at least this particular Apple model (Macbook Pro 4,1), seems to require an MBR-only or hybrid MBR (not protective MBR) with the MBR boot flag set for the 500MB ext4 linux boot partition. Using a GPT-only disk with the linux boot partition set to GPT attribute "Legacy BIOS boot" is insufficient, the resulting disk is still not bootable.
Comment 6 Chris Murphy 2011-10-10 05:04:49 EDT
I just downloaded Fedora-16-Beta-x86_64-DVD.iso and issue 2 is not reproducible (with pre-existing Mac OS installation). 

Issues 1 and 3 are still present. And if I use the workaround mentioned above: change linux boot from EF00 to 8300, change protective MBR to hybrid MBR*, set boot flag in MBR for linux boot partition - I now have a dual boot machine. By holding down option at start, Fedora 16 is booted via the "Windows" disk icon (actually first drops me into GRUB2's menu as expected).

* specifically, starting with the same six partitions in Description, and using gdisk 0.7.2, the three GPT partitions added to the hybrid MBR are 4, 5, and 6. Thus MBR partition 1 is the GPT itself + GPT partitions 1, 2, and 3. MBR 2, 3, 4 are GPT 4, 5, 6 respectively. And MBR 3's boot flag is set.
Comment 7 Brian Lane 2011-10-10 12:32:58 EDT
Please attach the install logs from /tmp/*log (or from /var/log/anaconda/*log after the install).

As noted in one of your other bugs the live media currently isn't EFI capable yet.

If you boot it in CSM mode it is going to treat it like a BIOS system and a variety of things won't be setup correctly (eg. /boot/efi and efibootmgr won't be run).

When you installed using the DVD did you boot in CSM or EFI mode?
Comment 8 Chris Murphy 2011-10-10 15:03:51 EDT
Created attachment 527293 [details]
anacondalog from LiveCD /tmp post install
Comment 9 Chris Murphy 2011-10-10 15:04:44 EDT
Created attachment 527294 [details]
ifcfglog from LiveCD /tmp post install
Comment 10 Chris Murphy 2011-10-10 15:05:10 EDT
Created attachment 527295 [details]
programlog from LiveCD /tmp post install
Comment 11 Chris Murphy 2011-10-10 15:05:48 EDT
Created attachment 527296 [details]
storagelog from LiveCD /tmp post install
Comment 12 Chris Murphy 2011-10-10 15:19:26 EDT
(In reply to comment #7)
Four logs found postinstall in /tmp while still booted from LiveCD. Steps to reproduce as listed 1-6 in Description.

For LiveCD and full DVD boot it's CSM* (choosing the Windows disc icon from the option key startup).

 I am only doing CSM boot on this hardware because its EFI and nouveau conflict preventing X from starting (have discussed with Ben Skeggs, this model and many others are effectively CSM only for non-Mac OS booting).

My expectations are the same as for F13, F14, and F15. The big difference in F16 is that for Apple hardware, Fedora (single OS or dual boot OS) is non-bootable after installation because there is no hybrid MBR after installation. Even if it started with a hybrid MBR, if the installer makes any changes to partitioning it appears to blow away the hybrid MBR in favor of a protective MBR. So while Apple hardware will continue to boot Mac OS after installing Fedora, in no case will it boot Fedora without manual creation of a hybrid MBR. And that's new with F16 on hardware that previously was bootable right after Fedora installed.

I don't do Windows, but my understanding is Windows on BIOS hardware can optionally use GPT for secondary disks. But depends on MBR for the boot disk. So if the Fedora 16 installer is blowing away full or hybrid MBRs in favor of GPT (plus protective MBR) I can see how this might cause dual boot problems for Windows users as well. The perversion that is hybrid MBR is something that some systems apparently aren't going to be able to live without.
Comment 13 Chris Murphy 2011-10-10 15:29:38 EDT
Please let me know if I should file a separate bug report for the incorrect partition type GUID being used for the linux boot partition (/boot). Installer is presently setting it to EFI System GUID instead of a Linux filesystem GUID. And if so what component and who to cc.
Comment 14 Mr.doob 2011-10-15 22:41:38 EDT
I can confirm this also affects MacBook5,2. Using both, 32-bit and 64-bit, liveCD. I'm currently unable to get a working Fedora on it. Hope this gets fixed in time before release.
Comment 15 Chris Murphy 2011-10-15 22:56:00 EDT
>(In reply to comment #14)

Let's see if I've got this figured out or not. Please boot from the Live CD, in Terminal use "su" to become root, and "yum install gdisk" then "gdisk -l /dev/xxx" for the disk and report the table information. Also "fdisk -l /dev/xxx" for the same disk and report that table information as well. Ideally the full table (device, start, end, ID/code), minus the header.
Comment 16 Chris Murphy 2011-10-15 22:58:31 EDT
>(In reply to comment #14)
And just to confirm, you have a pre-existing Mac OS X system on the MBP, and you've installed Fedora 16beta, and you got the "error installing the bootloader" message at the end of your installation?
Comment 17 Mr.doob 2011-10-15 23:20:11 EDT
(In reply to comment #15)
> >(In reply to comment #14)
> 
> Let's see if I've got this figured out or not. Please boot from the Live CD, in
> Terminal use "su" to become root, and "yum install gdisk" then "gdisk -l
> /dev/xxx" for the disk and report the table information. Also "fdisk -l
> /dev/xxx" for the same disk and report that table information as well. Ideally
> the full table (device, start, end, ID/code), minus the header.


[root@localhost liveuser]# gdisk -l /dev/sda
GPT fdisk (gdisk) version 0.7.2

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 488397168 sectors, 232.9 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 4DDBCF67-5BEE-4937-B1D6-10AF14322DAA
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 488397134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2349 sectors (1.1 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048            4095   1024.0 KiB  EF02  
   2            4096         1028095   500.0 MiB   EF00  ext4
   3         1028096       488396799   232.4 GiB   8E00  


[root@localhost liveuser]# fdisk -l /dev/sda

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1   488397167   244198583+  ee  GPT
Comment 18 Mr.doob 2011-10-15 23:22:17 EDT
(In reply to comment #16)

I have tried both ways, with Mac OS X installed, and formatting the whole thing and installing Fedora only. As you can see the HD info currently shows the later option.
Comment 19 Chris Murphy 2011-10-15 23:44:42 EDT
(In reply to comment #18)
OK so when you had Mac OS on the disk also, and you installed Fedora 16 as a 2nd option, did you get the "error installing the bootloader" error message?
Comment 20 Chris Murphy 2011-10-15 23:59:36 EDT
I'll tell you what, let's leave this bug for the "error installing bootloader" problem. I'll leave it up to the devs if they would find it helpful if you can reproduce (or not) the exact steps in the Description post (very top).

In the meantime, if you could combined comments 14 and 17, and post to:
https://bugzilla.redhat.com/show_bug.cgi?id=503149

I will post a gdisk sequence that should get your current installation booting Fedora.
Comment 21 Mr.doob 2011-10-16 00:09:19 EDT
(In reply to comment #19)
That's correct.

I'm currently installing Mac OS X again and will try again. Ideally I would like to dualboot, I formatted the disk before to see if at least worked that way. I'll post gdisk info with the bootcamp setup in a sec.

Oh, and no, I'm not using Fedora 16 Beta but yesterday's nightly build.
Comment 22 Chris Murphy 2011-10-16 00:44:39 EDT
(In reply to comment #17)
> Number  Start (sector)    End (sector)  Size       Code  Name
>    1            2048            4095   1024.0 KiB  EF02  
>    2            4096         1028095   500.0 MiB   EF00  ext4
>    3         1028096       488396799   232.4 GiB   8E00 

Just want to point out to anaconda devs that gdisk's info command will report #2 partition type GUID as C12A7328-F81F-11D2-BA4B-00A0C93EC93B which is for "EFI System." If anaconda uses parted for GPT modifications, I surmise that anaconda is incorrectly having parted set the 'boot' flag for this partition. Parted translates the 'boot' flag for GPT disks into the GUID for "EFI System."

A separate bug with parted, is that without the 'boot' flag set, the partition type GUID is set to EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 "Microsoft basic data" which is also incorrect, but at least has some historical precedent from the MBR world where this was done, and that habit has apparently carried over to GPT. I'll look for a bug report on this and if none I'll file it separately.
Comment 23 Mr.doob 2011-10-16 01:02:09 EDT
Reproduced the issue on MacBook5,2. At the end of the installation I got this error "There was an error installing the bootloader.  The system may not be bootable."

gdisk/fdisk output:

[root@localhost liveuser]# gdisk -l /dev/sda
GPT fdisk (gdisk) version 0.7.2

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 488397168 sectors, 232.9 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 55C82901-E1FF-4A1A-A2EF-C06ACDF33132
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 488397134
Partitions will be aligned on 8-sector boundaries
Total free space is 2349 sectors (1.1 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          409639   200.0 MiB   EF00  EFI System Partition
   2          409640       243679271   116.0 GiB   AF00  Untitled 1
   3       243681280       243683327   1024.0 KiB  EF02  
   4       243683328       244707327   500.0 MiB   EF00  ext4
   5       244707328       488396799   116.2 GiB   8E00  


[root@localhost liveuser]# fdisk -l /dev/sda

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1   488397167   244198583+  ee  GPT
Comment 24 Chris Murphy 2011-10-16 01:37:55 EDT
(In reply to comment #23)
See comment 7 and post the logs if you like. I'm not sure if they're needed or if the ones I submitted are adequate.

To fix this so you can dual boot requires multiple steps because not only is the MBR incorrect to get Apple hardware to boot into grub, but grub2 probably didn't correctly install. I can help fix your problem since I've already done it but I'm reluctant to clutter this bug report with something that's unlikely to help the devs further on this problem. I suggest posting the full dual boot problem and failures and partition maps to fedoraforum.org either in Rawhide or Mac forums, and then private email me the post URL and I'll respond with the write up so others can benefit also.
Comment 25 Adam Williamson 2011-10-17 15:10:18 EDT
added a chunk to Summary which I hope accurately describes the problem, Chris?
Comment 26 Adam Williamson 2011-10-17 15:15:12 EDT
proposing as a blocker so we can kick it around, specifically the implications for Win7 dual-boot scenarios.
Comment 27 Chris Murphy 2011-10-17 16:47:41 EDT
(In reply to comment #25)
> added a chunk to Summary which I hope accurately describes the problem, Chris?

Well if anaconda uses parted for modifying partitions, then it's actually parted that's blowing away the hybrid MBR. Dropping the hybrid MBR isn't necessarily a bad thing, it's just that if it's really needed (question 1 which is hardware specific), it needs to be replaced with something sensible.

Does anaconda know make/model of the target system? It might make it possible to create a heuristic that does the right thing as we are in a nasty transitory arena with BIOS, EFI and CSMs right now. I would not be surprised if other Intel EFI (non-UEFI) systems or those with CSMs, maybe even certain BIOS implementations, want to see an MBR with at least one partition flagged as bootable.
Comment 28 Adam Williamson 2011-10-17 17:05:48 EDT
Chris: can you please do what I asked in 503149 and split out all these different issues you've reported into separate bugs, so we can get past the confusion and noise in these two overlapping reports? that'd make it easier to follow up on things. thanks.
Comment 29 Chris Murphy 2011-10-17 17:11:33 EDT
(In reply to comment #12)
> I don't do Windows, but my understanding is Windows on BIOS hardware can
> optionally use GPT for secondary disks. But depends on MBR for the boot disk....

With a system that already has Windows only on it, and Fedora is going to be an additional system, the disk is almost certainly MBR only. No GPT. And I do not think anaconda or parted will change the disk from MBR to GPT. I am pretty sure it keeps the MBR, in which case, there is no issue dual booting Windows. Further, I think there'd be overflowing forums and bug reports if there were.

Issue arrises only if the user wants/expects (historically?) to install Fedora first, and then Windows second. Windows installer would see a GPT disk and refuse to install, whereas with F15 and older, Windows installer would see an MBR disk and allow Windows to be installed. Is this ever an expected or desirable installation order? I would think not just because the Windows installer will blow away Grub stage 1 (Grub2 boot.img) leaving the end user having to fix this situation with a rescue disk, and reinstall grub themselves.
Comment 30 Chris Murphy 2011-10-17 17:15:52 EDT
Should I refile bug 744496 as a new bug? 

There is really only one bug here as originally reported which is the ""There was an error installing the bootloader. The system may not be bootable." message, when installing Fedora on a disk with a pre-existing (foreign) operating system.
Comment 31 Adam Williamson 2011-10-17 17:28:25 EDT
you mentioned three apparently separate issues in comment #5.
Comment 32 Chris Murphy 2011-10-17 17:44:30 EDT
Yeah I will split out 1 and 3 into separate reports as they relate to bug 503149. Comment #5, bug 2 is the primary bug for bug 744496. So is it cleaner to open a new bug with just that specific issue, and mark this bug 744496 as a duplicate?
Comment 33 Adam Williamson 2011-10-17 17:51:13 EDT
I think so, yes, this has gotten so long and confused.
Comment 34 Chris Murphy 2011-10-18 01:10:32 EDT

*** This bug has been marked as a duplicate of bug 746885 ***
Comment 35 Jesse Keating 2012-07-02 21:48:57 EDT
*** Bug 836896 has been marked as a duplicate of this bug. ***