首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Grub2中自动加载配置文件?

如何在Grub2中自动加载配置文件?
EN

Unix & Linux用户
提问于 2012-07-24 01:17:17
回答 3查看 10.4K关注 0票数 0

我已经安装了grub2,因为我的分区不再受遗留grub的支持,但是我不能让它显示一个像遗留grub中那样的文本菜单?当我启动我的pc,它给我的CLI,我需要手动加载我的configfile?因此,我的配置文件很好,但是如何使用grub2自动启动它呢?我的操作系统是openSUSE,我使用grub2-mkconfig --output=/boot/grub2/grub.conf创建我的配置文件。然后使用grub2-install /dev/sda2 2安装grub2。我还编辑了/etc/default/grub以显示菜单,并注释了隐藏菜单项行。请帮帮忙,因为这是一种非常令人讨厌的虫子吗?非常感谢!

更新:请阅读我有openSUSE和Linux是有点奇怪的问题。我已经尝试了grub2-mkconfig -o /boot/grub2/grub.conf。我也和grub.cfg试过了。不存在,只有grub2-mkconfig。也没有更新-grub(或update2-grub)。这是一个在openSUSE中不存在的脚本!

更新2:也许是显卡出了问题?从我的grub2-mkconfig:http://ubuntuforums.org/showthread.php?t=1485072&page=3中可以识别出Windows Os。

更新3:当我使用--强制时,我也会收到这个错误信息:

代码语言:javascript
复制
/usr/sbin/grub2-bios-setup: Warnung: Dateisystem »ext2« unterstützt keine   
Einbettungen.
/usr/sbin/grub2-bios-setup: Warnung: Einbettung ist nicht möglich. GRUB  
kann in dieser Konfiguration nur mittels Blocklisten installiert werden. 
Blocklisten sind allerdings UNZUVERLÄSSIG und deren Verwendung wird daher 
nicht empfohlen..
installation beendet. Keine Fehler aufgetreten.

更新4:

代码语言:javascript
复制
  grub2-mkconfig --output=/boot/grub2/grub.cfg
  grub.cfg wird erstellt …
  Linux-Abbild gefunden: /boot/vmlinuz-3.4.4-1.1-desktop
  initrd-Abbild gefunden: /boot/initrd-3.4.4-1.1-desktop
     No volume groups found
  Windows 7 (loader) auf /dev/sdc1 gefunden
  erledigt

更新5:根据请求,我使用/dev/sda而不是/dev/sda 2,它工作得更好,我不需要-force命令。

代码语言:javascript
复制
   grub2-install --boot-directory=/boot/grub2 /dev/sda
   installation beendet. Keine Fehler aufgetreten.

但是在这个自述文件中有脚本更新-grub2:https://build.opensuse.org/package/view_file?file=README.openSUSE&package=grub2&project=openSUSE%3AFactory&rev=c3401e0f5ec23451c03caa9b77fa0d99

但我没有?

更新6:

代码语言:javascript
复制
# If you change this file, run 'grub2-mkconfig -o /boot/grub2/grub.cfg'     
afterwards to update 
# /boot/grub2/grub.cfg.
GRUB_DISTRIBUTOR="openSUSE"

GRUB_DEFAULT=2
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=5
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash=silent"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=800x600

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to   
Linux
GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_LINUX_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
GRUB_BACKGROUND=/boot/grub2/themes/openSUSE/background.png
GRUB_THEME=/boot/grub2/themes/openSUSE/theme.txt

更新7:我的文件grub2_lib也在/usr/share/grub2中,而不是在/usr/lib/grub中:http://forums.opensuse.org/english/get-technical-help-here/pre-release-beta/476722-grub2-broken-12-2-rc1.html

更新和修正:

  1. 错误:在我的grub配置文件中,该行GRUB_HIDDEN_TIMEOUT_QUIET=true改为GRUB_HIDDEN_TIMEOUT_QUIET=false,并注释该行#GRUB_HIDDEN_TIMEOUT=0。
  2. 错误:它只在/boot中工作,而不是从/boot/grub2运行,尽管/boot/grub2在任何地方都是默认路径。真奇怪。也许是因为我在使用AHCI?
EN

回答 3

Unix & Linux用户

回答已采纳

发布于 2012-07-25 21:45:10

由于您没有使用默认的/boot/grub目录,所以需要告诉grub使用/boot/grub2:

代码语言:javascript
复制
grub-install --boot-directory=/boot/grub2 /dev/sda2
票数 2
EN

Unix & Linux用户

发布于 2012-07-24 04:41:52

您需要使用以下命令创建grub.cfg文件:

代码语言:javascript
复制
grub-mkconfig -o /boot/grub/grub.cfg

它使用/ etc /grub.d/和/etc/default/grub等中的各种grub.cfg文件来创建grub.cfg文件。

关于Grub的Arch Wiki文章彻底地解释了这个过程。虽然它是为Arch编写的,但我相信您可以很容易地将它用于您的系统。

票数 0
EN

Unix & Linux用户

发布于 2015-03-23 20:22:34

我也犯了同样的错误。配置文件是grub.cfg,而不是grub.conf

SUSE/OpenSUSE/RHEL/CentOS:

代码语言:javascript
复制
grub2-mkconfig --output=/boot/grub2/grub.cfg 

Debian/Ubuntu

代码语言:javascript
复制
grub2-mkconfig --output=/boot/grub/grub.cfg

定位grub.cfg?

不同的分布对grub.cfg使用不同的定位。Ubuntu使用/boot/grub/grub.cfg (文档),RHEL/CentOS 7在BIOS系统(文档)上使用/boot/grub2/grub.cfg,SUSE/OpenSUSE (文档)也是如此。

票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/43808

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档