Bug 861192

Summary: grub2 will not install to an ext2 ext3 ext4 partition
Product: [Fedora] Fedora Reporter: Chris Murphy <bugzilla>
Component: grub2Assignee: Peter Jones <pjones>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 18CC: bcl, collura, dcantrell, dennis, duffy, germano.massullo, i, jfeeney, mads, mihai, mrmazda, pjones, psabata, stephent98
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugzilla.redhat.com/show_bug.cgi?id=804835
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-08-31 11:39:27 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Description Flags
grubinstall debug output none

Description Chris Murphy 2012-09-27 14:51:48 EDT
Created attachment 618230 [details]
grubinstall debug output

Description of problem:
grub2-install /dev/sdb1, with or without --force, fails to install to ext[234] formatted partitions.

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

How reproducible:
100% for ext4, i.e. /boot on its own partition

Steps to Reproduce:
1. new blank disk
2. gpt partitioned, 1GB linux partition
3. mkfs.ext4 /dev/sdb1
4. grub2-install --force /dev/sdb1

Actual results:
/usr/sbin/grub2-bios-setup: warning: File system `ext2' doesn't support embedding.
/usr/sbin/grub2-bios-setup: error: filesystem `btrfs' doesn't support blocklists.

To test if there were file system changes, before grub2-install:
hexdump -C /dev/sdb1 > beforegrubinstall.bin
After grub2-install:
hexdump -C /dev/sdb1 > aftergrubinstall.bin
After grub2-install --force:
hexdump -C /dev/sdb1 > aftergrubforceinstall.bin

diff says these files are identical.

Expected results:
Unsure. History says it's possible to install grub this way but perhaps we're supposed to place core.img on /dev/sdb1 and then chainload or multiboot it?

Additional info:
Attaching --debug file from grub2-install failure.

Could be related to Bug 804835.
Comment 1 Máirín Duffy 2012-09-27 14:59:11 EDT
Hi Chris, so we talked about this in #anaconda, thankfully Matthew Garrett was there and he really understands this stuff (he also pointed to this for reference: https://wiki.archlinux.org/index.php/GRUB2#Install_to_Partition_or_Partitionless_Disk.)

Here's my attempt to summarize the issue based on the discussion:

- First of all, the filesystem used for /boot shouldn't really matter, so the error/warning message is poorly-worded in that respect. This isn't an ext 2/3/4 specific issue.

- So there's two types of hardware you might have; you might have an EFI system or a BIOS sytem. I'm guessing based on all of this that you have a BIOS system with GPT partitions. Here's what happens when you install to /boot for each of these:

#1) EFI system

EFI systems do not need to embed the bootloader, because the EFI system firmware can read the filesystem. They can simply install it without embedding. No problems there.

#2) BIOS system:

BIOS systems need to have the bootloader embedded on disk because BIOS firmware cannot read the filesystem. There are two cases for BIOS systems:

A) BIOS system with MBR partitions (< 2TB disk) - there's enough space to put the bootloader on disk, so this case is handled okay. 

B) BIOS system with GPT partitions (2TB+ disk) - there isn't enough space to safely embed grub2 (being much bigger than grub1) at the start of the partition; it has to be put at the start of the disk. However, this poses a big problem if you're trying to set up a multi-boot system, because if you have other OSes installed you're going to necessarily muck with their configuration. 

Another confounding issue here is that you can only boot off of a primary  partition, so if you try to solve the problem by creating a separate BIOS boot partition to write the bootloader to, it needs to be one of the limited primary partitions. If you have any available from your other OS installs.

Matthew said he would look into this issue, this is pretty sticky. I'm really glad you pointed it out, I'm hoping we can figure out some kind of solution.
Comment 2 Chris Murphy 2012-09-27 15:20:28 EDT
2A = This is a 'grub2-install /dev/sdb' where core.img goes into the MBR gap. It's not an example of installing to a partition.

2B = There is no MBR gap, because the GPT is in that location, which is why BIOS Boot is needed. BIOS Boot can be anywhere on the disk, grub2-install will find it and use it. There is no such thing as primary partitions in GPT. This is also an example of installing grub to a disk, not to a partition that contains a file system.

When you say installing grub to /boot that means something like 'grub2-install /dev/sdb[123]' where what would have been installed in the MBR bootstrap code area (first 440 bytes of LBA0), it goes in an equivalent area at the start of the partition. ext[234] have nothing in the first 1024 bytes, so it should be possible to put jump code in there that then points to core.img (?) but it's presently not working no matter what I try.

It seems to be a recurring grub2 behavior, in any case.

Also, whether my test disk is MBR or GPT formatted, grub2-install --force /dev/sdb1 (i.e. to a partition) always fails with the above message that ext2 doesn't support embedding. It never fails embedding to a whole disk.

If the file system is not ext[234] grub does embed successfully, including btrfs (in which case the full 64KB blank gap before btrfs metadata is consumed by embedded grub).
Comment 3 Máirín Duffy 2012-09-27 15:26:39 EDT
Chris, are you able/willing to pop into #anaconda on freenode right now? Hehe
Comment 4 Chris Murphy 2012-09-27 17:36:10 EDT
Bug filed with upstream.
Comment 5 Chris Murphy 2012-09-28 15:32:06 EDT
Block lists successfully produced when not cross-installed to another disk and using --force, using grub2-2.00-5.fc18.x86_64. The cross-installation appears to be the source of the failure in this bug, so it's probably notabug.

Additional information/regression:
With grub2-2.0-0.38.beta6.fc17.x86_64 block lists failed to be produced with --force under the same conditions (not cross-installed).

See upstream bug for more information.
Comment 6 Christopher Meng 2013-03-08 21:10:14 EST
This also happened to me.

But after specific the --force option it worked for me.
Comment 7 Germano Massullo 2013-07-02 10:20:47 EDT
could it be related? https://bugzilla.redhat.com/show_bug.cgi?id=979805
Comment 8 Mads Kiilerich 2013-08-31 11:39:27 EDT
Re recent activity on this bug report:

Background info:

When installing to partitions then grub2 can be forced to use blocklists. Blocklists means that grub2-install generates a core.img file, stores it in the filesystem in /boot/grub2, and stores the sector numbers for core.img in the first sectors of the partition. For "simple" filesystems that means that the early boot loader can bootstrap itself by reading sectors, without implementing file systems.

The issue in this bug report:

1. ext2 partitions do not have enough free space outside the file system to install the boot loader. It thus had to use blocklists.

2. btrfs is not a simple file system it is thus not possible to refer to core.img just by enumerating sector numbers.

3. The core.img was on another disk than the partition installed to. Just storing sector numbers was thus insufficient - it also needed to be able to find the other disk ... and that is pretty hard (impossible) that early in the boot process.

The error messages very thus pretty correct.

In the end it was a "user error", trying to do something that for good reasons is unsupported.

The summary of this bug report is thus in general not correct. It is just unsupported functionality that is unsupported.