From ed68e416df81cabadd30c5e6f67f43b8c6ae0adf Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 7 Nov 2012 17:54:58 -0800 Subject: check for small grub2 embed space (#737508) Depending on the filesystem choices for stage2 grub2's core.img may be too large to fit into the area between the mbr and the first partition. This adds a check that will show an error if the stage2 fs isn't extX and the first partition starts lower than 512K. --- pyanaconda/bootloader.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'pyanaconda/bootloader.py') diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py index 3ccecfb21..3dfe42f88 100644 --- a/pyanaconda/bootloader.py +++ b/pyanaconda/bootloader.py @@ -25,6 +25,7 @@ import sys import os import re import struct +from parted import PARTITION_BIOS_GRUB from pyanaconda import iutil from pyanaconda.storage.devicelibs import mdraid @@ -728,6 +729,10 @@ class BootLoader(object): return t + def check(self): + """ Run additional bootloader checks """ + return True + # pylint: disable-msg=E0102,E0202,E1101 @timeout.setter def timeout(self, seconds): @@ -1546,6 +1551,40 @@ class GRUB2(GRUB): sync() self.stage2_device.format.sync(root=ROOT_PATH) + def check(self): + """ When installing to the mbr of a disk grub2 needs enough space + before the first partition in order to embed its core.img + + Until we have a way to ask grub2 what the size is we check to make + sure it starts >= 512K, otherwise return an error. + """ + ret = True + self.errors = [] + self.warnings = [] + + for (stage1dev, stage2dev) in self.install_targets: + if stage1dev == stage2dev: + continue + + # These are small enough to fit + if stage2dev.format.type in ("ext2", "ext3", "ext4") \ + and stage2dev.type == "partition": + continue + + # If the first partition starts too low show an error. + parts = stage1dev.format.partedDisk.partitions + for p in parts: + start = p.geometry.start * p.disk.device.sectorSize + if not p.getFlag(PARTITION_BIOS_GRUB) and start < 1024*512: + msg = _("%s may not have enough space for grub2 to embed " + "core.img when using the %s filesystem on %s") \ + % (stage1dev.name, stage2dev.format.type, stage2dev.type) + log.error(msg) + self.errors.append(msg) + ret = False + break + return ret + class EFIGRUB(GRUB2): packages = ["grub2-efi", "efibootmgr", "shim"] can_dual_boot = False @@ -1640,6 +1679,8 @@ class EFIGRUB(GRUB2): self.install() self.write_config() + def check(self): + return True class MacEFIGRUB(EFIGRUB): def mactel_config(self): -- cgit