grub-install生成的grubx64.efi却去读取EFI/ubuntu/grub.cfg
Tofloor
poster avatar
shimeng2012
deepin
2019-03-28 19:41
Author
本帖最后由 shimeng2012 于 2019-3-28 16:09 编辑

1. 问题/建议描述
grub-install生成的grubx64.efi却去读取EFI/ubuntu/grub.cfg
2. 问题如何重现
先安装的deepin,后安装的ubuntu18.04,中间ubuntu安装引导时出错,只有在修改EFI/ubuntu/grub.cfg中的uuid为deepin所在盘才能用uefi加载的deepin/grubx64.efi读取到deepin的配置文件,重复多次,也进入了grub shell,发现efi文件被加载(ubuntu的grub和deepin的grub版本不同,可在grub shell的头部区分),但是好像是去ubunt/grub.cfg读取配置。猜测可能grub-install内部调取的grub-mkimage的 -p参数问题,问题是安装deepin没问题(efi文件读取同目录下的grub.cfg),进入deepin后直接用grub-install好像有这个问题,也使用了deepin的修复工具repair tool,看程序详情好像也是用grub-istall直接安装,然后grub2-update。很是疑惑问题出在哪了,还是电脑UEFI有bug,电脑联想G480,2012年的电脑。目前了解知识:EFI/deepin/grub.cfg是设置root变量读取deepin系统盘先的真正boot/grub/grub.cfg。
3. 问题重现频率
绝对会出现。
操作系统 :deepin

另外GNU的grub手册里有这段介绍

6.4 Embedding a configuration file into GRUB
GRUB supports embedding a configuration file directly into the core image, so that it is loaded before entering normal mode. This is useful, for example, when it is not straightforward to find the real configuration file, or when you need to debug problems with loading that file. grub-install uses this feature when it is not using BIOS disk functions or when installing to a different disk from the one containing /boot/grub, in which case it needs to use the search command (see search) to find /boot/grub.
To embed a configuration file, use the -c option to grub-mkimage. The file is copied into the core image, so it may reside anywhere on the file system, and may be removed after running grub-mkimage.
After the embedded configuration file (if any) is executed, GRUB will load the ‘normal’ module (see normal), which will then read the real configuration file from $prefix/grub.cfg. By this point, the root variable will also have been set to the root device name. For example, prefix might be set to ‘(hd0,1)/boot/grub’, and root might be set to ‘hd0,1’. Thus, in most cases, the embedded configuration file only needs to set the prefix and root variables, and then drop through to GRUB’s normal processing. A typical example of this might look like this:
search.fs_uuid 01234567-89ab-cdef-0123-456789abcdef rootset prefix=($root)/boot/grub
(The ‘search_fs_uuid’ module must be included in the core image for this example to work.)
In more complex cases, it may be useful to read other configuration files directly from the embedded configuration file. This allows such things as reading files not called grub.cfg, or reading files from a directory other than that where GRUB’s loadable modules are installed. To do this, include the ‘configfile’ and ‘normal’ modules in the core image, and embed a configuration file that uses the configfile command to load another file. The following example of this also requires the echo, search_label, and testmodules to be included in the core image:
search.fs_label grub rootif [ -e /boot/grub/example/test1.cfg ]; then    set prefix=($root)/boot/grub    configfile /boot/grub/example/test1.cfgelse    if [ -e /boot/grub/example/test2.cfg ]; then        set prefix=($root)/boot/grub        configfile /boot/grub/example/test2.cfg    else        echo "Could not find an example configuration file!"    fifi
The embedded configuration file may not contain menu entries directly, but may only read them from elsewhere using configfile.


Reply Favorite View the author
All Replies
avatar
DeepinOS
deepin
2019-03-29 06:00
#1
没看懂你叙述的,但是有一点是正确的。在deepin下,grubx64.efi是先读取自己同目录下的配置文件,这个配置文件指向下一个配置文件。可能在Ubuntu下,是不一样的设置。你选一个启动方案进行就行吧。
其实我还是没看懂你表达的意思,你可以用图来解释吗?
Reply View the author