Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grub.cfg isn't being properly updated on EFI systems running CentOS 7 #4

Closed
w3ttr3y opened this issue May 28, 2015 · 11 comments · Fixed by #57
Closed

grub.cfg isn't being properly updated on EFI systems running CentOS 7 #4

w3ttr3y opened this issue May 28, 2015 · 11 comments · Fixed by #57
Labels
bug Something isn't working

Comments

@w3ttr3y
Copy link

w3ttr3y commented May 28, 2015

grub.cfg isn't being properly updated on EFI systems running CentOS 7

It works as expected on servers with a traditional BIOS, but when run on an EFI system, grub active configuration doesn't get updated.

Looking into the issue a bit, line 111 of lib/puppet/provider/kernel_parameter/grub2.rb says:

["/boot/grub/grub.cfg", "/boot/grub2/grub.cfg"].each {|c|

The problem is the system does have a /boot/grub2/grub.cfg file, but the file actively being used is /boot/efi/EFI/centos/grub.cfg

I was going to submit a patch, but since centos is in the name, it would have been very distribution specific so taking a step back to create a more generic version probably makes sense.

Why would /boot/grub2/grub.cfg exist if /boot/efi/EFI/centos/grub.cfg is the active configuration?

Honestly, I don't know; making an educated guess is if I were to change to running in legacy bios mode then the /boot/grub2/grub.cfg file probably gets used.

EFI requires that there is a partition of a limited number of files systems (e.g. fat16/fat32/etc) that has an EFI folder in the root. To support this, /boot/efi is a different partition then /boot So when booting in legacy bios mode, my guess is it acts as if there was no efi and reads the configuration file off of the /boot partition. Since they are separate partitions, you can't hard link etc, so two copies are maintained.

Thus the "best" solution may be to add a line after 117 (mkconfig "-o", cfg), that looks for files /boot/efi/EFI//grub.cfg and if so copies cfg (in this case /boot/grub2/grub.cfg) over /boot/efi/EFI//grub.cfg

@raphink
Copy link
Member

raphink commented Jun 12, 2015

I don't think copying this file in this resource type is a proper solution.

How about managing a file resource for your need?

file { '/boot/efi/EFI//grub.cfg':
  ensure => file,
  source => '/boot/grub2/grub.cfg',
}

@raphink raphink added the bug Something isn't working label Jun 12, 2015
@paulraines68
Copy link

/boot/grub2/grub.cfg does not exist on my CentOS 7 system using EFI. So running puppet would give me an error on my kernel_parametering complaining no grub.cfg existed.

So I fixed this by simplying adding "/boot/efi/EFI/centos/grub.cfg" to the list in the each command in grub2.rb

@raphink
Copy link
Member

raphink commented Dec 2, 2015

OK. Feel free to provide a PR for that.

@paulraines68
Copy link

I notice though that /etc/grub2-efi.cfg is a symlink to ../boot/efi/EFI/centos/grub.cfg so it would be a more general option to put in the list assuming you don't anticipate any way the code would not work with symlinks by, for example, doing 'rm' on the given file path before writing out a new file?

@raphink
Copy link
Member

raphink commented Dec 3, 2015

I think symlinks should work imo.

@paulraines68
Copy link

I note on non-EFI CentOS 7 systems, it is /etc/grub2.cfg that exists and is
a symlink to /boot/grub2/grub.cfg

I have no idea why the grub2 packages for RHEL/CentOS felt it was necessary
to have the link be named grub-efi.cfg on EFI systems.

I see in the new-kernel-pkg script that it does a readlink on both possible
names to find which one to use.

On Thu, Dec 3, 2015 at 2:43 AM, Raphaël Pinson notifications@github.com
wrote:

I think symlinks should work imo.


Reply to this email directly or view it on GitHub
#4 (comment)
.

@cohdjn
Copy link
Contributor

cohdjn commented Oct 5, 2017

I'd like to bump this issue. I just installed on RHEL 7 and I have the same problem. Only difference is that the active grub.cfg is /boot/efi/EFI/redhat/grub.cfg.

@srinivassrija
Copy link

Hi,

We have the same issue on RHEL-7. But we are assuming its using /boot/efi/EFI/redhat/grub.cfg but when the server reboots it couldn't find the kernel and disk to load. We have to give manually at grub loader. I assumed its looking the files in /boot/grub2/grub.cfg so created a symbolic link there and tried. But still same issue.

@raphink
Copy link
Member

raphink commented Apr 4, 2019

That's surprising. 5e2d464 introduced the support for EFI config files. @trevor-vaughan what do you think?

@trevor-vaughan
Copy link
Contributor

@raphink Well, the code certainly looks like it should be doing the right thing.

@srisrija Can you let us know if running grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg produces any errors? I haven't seen any issues when running the commands on a clean system so far.

Also, have you modified your grub2 scripts by hand in any way? It's notoriously difficult to auto-test EFI settings.

@traylenator
Copy link
Contributor

HI,

We just run into items related to this

So it's true that this module runs

grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

if the file /boot/efi/EFI/redhat/grub.cfg exists.

However if you are running booting with

/etc/grub2.cfg -> ../boot/grub2/grub.cfg

then this file is not updated.

I had a look through what a kernel upgrade does which calls /usr/sbin/new-kernel-pkg.
In this case grubby is called to generate both files for UEFI or Bios mode.

So I believe this module should mkconfig for each file that exists and copy the logic
of a kernel upgrade.

traylenator added a commit to traylenator/augeasproviders_grub that referenced this issue May 14, 2020
Currently grub2-mkconfig is called on the first file
that exists from.

```
"/etc/grub2-efi.cfg",
"/boot/efi/EFI/#{os_name.downcase}/grub.cfg",
"/boot/grub2/grub.cfg",
"/boot/grub/grub.cfg"
```

So on a CentOS 7 system `grub2-efi.cfg` is generated only
from `/etc/default/grub`.

With an EFI system configured for bios boot the
`/boot/grub2/grub.cfg` is the important one so
 `kernel_parameter` updates are not applied.

Taking inspiration from [new-kernel-pkg](https://github.com/rhboot/grubby/blob/master/new-kernel-pkg)
to see what happens on kernel upgrade `grubby` is called for each of
these files that exists so emulating this logic make sense.

Fixes voxpupuli#4
traylenator added a commit to traylenator/augeasproviders_grub that referenced this issue May 14, 2020
Currently grub2-mkconfig is called on the first file
that exists from.

```
"/etc/grub2-efi.cfg",
"/boot/efi/EFI/#{os_name.downcase}/grub.cfg",
"/boot/grub2/grub.cfg",
"/boot/grub/grub.cfg"
```

So on a CentOS 7 system `grub2-efi.cfg` is generated only
from `/etc/default/grub`.

With an EFI system configured for bios boot the
`/boot/grub2/grub.cfg` is the important one so
 `kernel_parameter` updates are not applied.

Taking inspiration from [new-kernel-pkg](https://github.com/rhboot/grubby/blob/master/new-kernel-pkg)
to see what happens on kernel upgrade `grubby` is called for each of
these files that exists so emulating this logic make sense.

Fixes voxpupuli#4
raphink pushed a commit that referenced this issue May 21, 2020
* Call grub2-mkconfig on all targets

Currently grub2-mkconfig is called on the first file
that exists from.

```
"/etc/grub2-efi.cfg",
"/boot/efi/EFI/#{os_name.downcase}/grub.cfg",
"/boot/grub2/grub.cfg",
"/boot/grub/grub.cfg"
```

So on a CentOS 7 system `grub2-efi.cfg` is generated only
from `/etc/default/grub`.

With an EFI system configured for bios boot the
`/boot/grub2/grub.cfg` is the important one so
 `kernel_parameter` updates are not applied.

Taking inspiration from [new-kernel-pkg](https://github.com/rhboot/grubby/blob/master/new-kernel-pkg)
to see what happens on kernel upgrade `grubby` is called for each of
these files that exists so emulating this logic make sense.

Fixes #4

* fixup - push in a different way
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants