Skip to content

Commit

Permalink
Initial attempt at UEFI support for GRUB.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrobbins committed Jan 3, 2015
1 parent 65536c3 commit 885d840
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 14 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
1.7.1
1.7.2
10 changes: 7 additions & 3 deletions doc/boot-update.8
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH BOOT-UPDATE 8 "" "1.7.1" "Funtoo Linux Core System"
.TH BOOT-UPDATE 8 "" "1.7.2" "Funtoo Linux Core System"
.SH NAME
boot-update \- Automatically create a boot loader configuration file
.
Expand Down Expand Up @@ -76,8 +76,12 @@ loader configuration file is stored at \fI/boot/grub/grub.cfg\fP, is quite
complex and is not intended to be edited directly by system administrators.
.sp
\fIboot\-update\fP has since been extended to support GRUB (\fIsys\-boot/grub\fP), GRUB
Legacy (\fIsys\-boot/grub\-legacy\fP) and LILO (\fIsys\-boot/lilo\fP). This allows a
single file, \fI/etc/boot.conf\fP, to store boot\-related information in a
Legacy (\fIsys\-boot/grub\-legacy\fP) and LILO (\fIsys\-boot/lilo\fP) to boot systems in
MBR (legacy) mode. In addition, GRUB also supports auto\-detecting and configuring
UEFI booting. If boot\-update detects that your system has booted in UEFI mode,
it will create a UEFI\-compatible configuration file automatically.
.sp
Boot\-update allows a single file, \fI/etc/boot.conf\fP, to store boot\-related information in a
boot\-loader\-independent way, thus simplifying boot loader configuration and
providing advanced features to all popular boot loaders.
.sp
Expand Down
8 changes: 6 additions & 2 deletions doc/boot-update.8.rst
Expand Up @@ -46,8 +46,12 @@ loader configuration file is stored at */boot/grub/grub.cfg*, is quite
complex and is not intended to be edited directly by system administrators.

*boot-update* has since been extended to support GRUB (*sys-boot/grub*), GRUB
Legacy (*sys-boot/grub-legacy*) and LILO (*sys-boot/lilo*). This allows a
single file, */etc/boot.conf*, to store boot-related information in a
Legacy (*sys-boot/grub-legacy*) and LILO (*sys-boot/lilo*) to boot systems in
MBR (legacy) mode. In addition, GRUB also supports auto-detecting and configuring
UEFI booting. If boot-update detects that your system has booted in UEFI mode,
it will create a UEFI-compatible configuration file automatically.

Boot-update allows a single file, */etc/boot.conf*, to store boot-related information in a
boot-loader-independent way, thus simplifying boot loader configuration and
providing advanced features to all popular boot loaders.

Expand Down
9 changes: 7 additions & 2 deletions doc/boot.conf.5
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH BOOT.CONF 5 "" "1.7.1" "Funtoo Linux Core System"
.TH BOOT.CONF 5 "" "1.7.2" "Funtoo Linux Core System"
.SH NAME
boot.conf \- Funtoo global boot loader configuration file
.
Expand Down Expand Up @@ -45,6 +45,11 @@ The benefit of \fI/etc/boot.conf\fP is that it provides a single location to
store all boot\-related information. It also provides a single, consistent file
format and feature set for configuring all boot loaders.
.sp
For MBR booting, GRUB, GRUB (legacy) and LILO boot loaders are supported. For
UEFI booting, GRUB is supported. When using GRUB, boot\-update will auto\-enable
UEFI boot configuration if it sees that your system has been booted in UEFI mode.
Otherwise, MBR (legacy) boot mode will be used.
.sp
\fIboot\-update(8)\fP utilizes \fI/etc/boot.conf\fP to provide a consistent process for
updating boot loader configuration, regardless of the actual boot loader used.
.sp
Expand Down Expand Up @@ -635,7 +640,7 @@ rootfstype=auto\fP\&.
Specifies the video mode to be used by the boot loader\(aqs menus. This value is
also inherited and used as the video mode for the kernel when a graphical boot
(\fIuvesafb\fP, \fIvesafb\-tng\fP) is used. This option is only supported for
\fIgrub\fP\&.
\fIgrub\fP\&. Default value is "text" for MBR booting, or "640x480" for UEFI booting.
.SS \fIdisplay :: background\fP
.sp
Specifies the graphical image to display at boot. The specified file should
Expand Down
7 changes: 6 additions & 1 deletion doc/boot.conf.5.rst
Expand Up @@ -26,6 +26,11 @@ The benefit of */etc/boot.conf* is that it provides a single location to
store all boot-related information. It also provides a single, consistent file
format and feature set for configuring all boot loaders.

For MBR booting, GRUB, GRUB (legacy) and LILO boot loaders are supported. For
UEFI booting, GRUB is supported. When using GRUB, boot-update will auto-enable
UEFI boot configuration if it sees that your system has been booted in UEFI mode.
Otherwise, MBR (legacy) boot mode will be used.

*boot-update(8)* utilizes */etc/boot.conf* to provide a consistent process for
updating boot loader configuration, regardless of the actual boot loader used.

Expand Down Expand Up @@ -465,7 +470,7 @@ rootfstype=auto*.
Specifies the video mode to be used by the boot loader's menus. This value is
also inherited and used as the video mode for the kernel when a graphical boot
(*uvesafb*, *vesafb-tng*) is used. This option is only supported for
*grub*.
*grub*. Default value is "text" for MBR booting, or "640x480" for UEFI booting.

*display :: background*
~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
22 changes: 18 additions & 4 deletions python/modules/funtoo/boot/extensions/grub.py
Expand Up @@ -26,6 +26,10 @@ def __init__(self, config, testing = False):
self.GuppyMap()
self.defpos = 0
self.defname = "undefined"
if os.path.exists("/sys/firmware/efi"):
self.uefiboot = True
else:
self.uefiboot = False

def grubProbe(self):
gprobe = "/usr/sbin/grub-probe"
Expand Down Expand Up @@ -134,16 +138,27 @@ def generateBootEntry(self, l, sect, kname, kext):

# Append graphics line
if self.config.hasItem("{s}/gfxmode".format(s = sect)):
l.append(" set gfxpayload={gm}".format(gm = self.config.item(sect, "gfxmode")))
l.append(" set gfxpayload=keep")
l.append("}")

return [ ok, allmsgs ]

def sanitizeDisplayMode(self,dm):
if self.uefiboot and dm == "text":
# UEFI doesn't support text mode:
return "640x480"
else:
return dm

def generateConfigFile(self):
l = []
c = self.config
ok = True
allmsgs = []
if self.uefiboot:
allmsgs.append(["warn","Detected UEFI boot. Configuring for UEFI booting."])
else:
allmsgs.append(["warn","Detected MBR boot. Configuring for Legacy MBR booting."])
l.append(c.condFormatSubItem("boot/timeout", "set timeout={s}"))
# pass our boot entry generator function to GenerateSections,
# and everything is taken care of for our boot entries
Expand Down Expand Up @@ -175,9 +190,8 @@ def generateConfigFile(self):
return [False, allmsgs, l]

l += [ "if loadfont {dst}; then".format(dst = self.r.RelativePathTo(dst_font,c["boot/path"])),
" set gfxmode={gfx}".format(gfx = c["display/gfxmode"]),
" insmod gfxterm",
" insmod vbe",
" set gfxmode={gfx}".format(gfx = self.sanitizeDisplayMode(c["display/gfxmode"])),
" insmod all_video",
" terminal_output gfxterm" ]
bg = c.item("display","background").split()
if len(bg):
Expand Down
2 changes: 1 addition & 1 deletion sbin/boot-update
Expand Up @@ -26,7 +26,7 @@ GREEN = "\x1b[32;01m"
RED = "\x1b[31;01m"
PURP = "\x1b[35;01m"
OFF = "\x1b[0m"
version = "1.7.1"
version = "1.7.2"
verbose = False

def banner(extra=True):
Expand Down

0 comments on commit 885d840

Please sign in to comment.