首页 > 志趣人生 > Ubuntu系统Ubuntu系统

修改GRUB 启动菜单的显示时间

Ubuntu系统 grub使用系列教程(one)

在使用Ubuntu系统的过程中,由于对系统的运行原理相关的知识存在一定的欠缺,难免会出现各种各样的错误。其中开机黑屏就是困扰我们的众多问题中的一类。

很多小伙伴需到这样的问题都感觉到无比棘手,不知道怎么办才好。很多情况下,他们可能会通过重新安装系统的方式来解决问题。但是,存在磁盘内的资料,安装的应用,系统的相关配置都会覆盖,无法找回。说实话,我以前也是这么做的,要不是对linux 开源系统的热爱,我可能早都转到window系统了。

废话不多说。只要系统内核完整,我们都可以通过grub启动菜单进入系统去尝试修复。但是,有些版本的Ubuntu系统默认跳过grub启动页面,本节文章就告诉小伙伴如何开启grub启动页。后续会陆续更新grub启动菜单的使用。当然,这需要在系统正常的情况下设置,未雨绸缪。

我们通过修改grub配置文件的方式来实现,最安全,最直接。

打开终端(快捷键:Ctrl + Alt + T):

image.png

    编辑GRUB配置文件,使用以下命令打开并编辑配置脚本

 sudo vim /etc/default/grub

image.png

进入脚本界面:

image.png

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=15
GRUB_DISTRIBUTOR=`( . /etc/os-release; echo ${NAME:-Ubuntu} ) 2>/dev/null || echo Ubuntu`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# If your computer has multiple operating systems installed, then you
# probably want to run os-prober. However, if your computer is a host
# for guest OSes installed via LVM or raw disk devices, running
# os-prober can cause damage to those guest OSes as it mounts
# filesystems to look for things.
#GRUB_DISABLE_OS_PROBER=false

# 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_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=640x480

# 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_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"


如果看到 GRUB_TIMEOUT=0GRUB_TIMEOUT_STYLE=hidden,就找到了问题的根源了。

首先:

GRUB_TIMEOUT=0表示接入GRUB界面后无需停留,直接引导进入系统,所以我们会看到GRUB界面一闪而过,根本无法选择菜单或进入GRUB命令行。应将GRUB_TIMEOUT=0 修改为正整数的值,如5,10,15等,这样出现GRUB界面后就有停留的时间供我们操作了。

GRUB_TIMEOUT_STYLE=hidden,需要修改为 GRUB_TIMEOUT_STYLE=menu

故需要修改的两处总结如下:

GRUB_TIMEOUT=10
GRUB_TIMEOUT_STYLE=menu

然后更新GRUB配置,终端输入以下命令执行:

sudo update-grub

最后就是验证设置的正确性:

sudo reboot


注意:

  • 如果修改后仍然不显示

    • 检查是否安装了多个系统(Windows 双系统可能会覆盖 GRUB)

    • 检查 /etc/default/grub 中是否有 GRUB_HIDDEN_TIMEOUT=0,如果有请删除或注释掉这行

  • 恢复 GRUB 菜单(如果修改无效):

    bash
  • sudo grub-install /dev/sda   # 请将 sda 替换为你的实际启动磁盘sudo update-grub
  • 检查是否使用了快速启动

    • 某些主板/UEFI 设置中有 "Fast Boot" 选项,这可能会跳过 GRUB

    • 进入 BIOS/UEFI 设置,禁用快速启动选项



0
0

共有 0 条热心评论

快快抢占沙发吧!

发表评论

安全验证
Top