您尚未登录。

#1 2021-01-03 19:00:51

AegirVOD
会员
所在地: 斯特拉斯堡
注册时间: 2021-01-03
帖子: 7

[已解决]grub不显示所有内核

事先声明:我已经update了grub并且/boot/grub/grub.cfg已经显示多个内核了

安装了linux-lts之后,我按照正常流程update了grub,然而在grub菜单里依旧没有新安装的内核,并且在grub菜单按e编辑选项时显示的内容与/boot/grub/grub.cfg或/etc/default/grub的内容完全不一致
有遇到过这种情况的吗?
就因为这个问题之前更新5.10的kernel之后电脑直接找不到kernel,因为尽管grub已经被update了,引导时依旧只会引导5.9,直接导致无法启动,我进rescue手动把5.9装回来才解决了问题。

附:安装内核后uname -r只显示5.9, 即使我已经安装了5.9,5.10和lts。

我的/etc/default/grub

 # GRUB boot loader configuration

GRUB_DISABLE_SUBMENU=y
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 rescue"
GRUB_CMDLINE_LINUX=""

# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"

# Uncomment to enable booting from LUKS encrypted devices
#GRUB_ENABLE_CRYPTODISK=y

# Set to 'countdown' or 'hidden' to change timeout behavior,
# press ESC key to display menu.
GRUB_TIMEOUT_STYLE=menu

# Uncomment to use basic console
GRUB_TERMINAL_INPUT=console

# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=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=auto

# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment if you want GRUB to pass to the Linux kernel the old parameter
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
#GRUB_DISABLE_LINUX_UUID=true

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

# Uncomment and set to the desired menu colors.  Used by normal and wallpaper
# modes only.  Entries specified as foreground/background.
#GRUB_COLOR_NORMAL="light-blue/black"
#GRUB_COLOR_HIGHLIGHT="light-cyan/blue"

# Uncomment one of them for the gfx desired, a image background or a gfxtheme
#GRUB_BACKGROUND="/path/to/wallpaper"
#GRUB_THEME="/path/to/gfxtheme"

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

# Uncomment to make GRUB remember the last selection. This requires
# setting 'GRUB_DEFAULT=saved' above.
#GRUB_SAVEDEFAULT="true"

我的/boot/grub/grub.cfg

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
insmod part_gpt
insmod part_msdos
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="0"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_gpt
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root  14d44e03-023a-4c9a-8bd3-4e326116ac43
else
  search --no-floppy --fs-uuid --set=root 14d44e03-023a-4c9a-8bd3-4e326116ac43
fi
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_US
  insmod gettext
fi
terminal_input console
terminal_output gfxterm
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Arch Linux, with Linux linux-lts' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-lts-advanced-14d44e03-023a-4c9a-8bd3-4e326116ac43' {
	savedefault
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod ext2
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  14d44e03-023a-4c9a-8bd3-4e326116ac43
	else
	  search --no-floppy --fs-uuid --set=root 14d44e03-023a-4c9a-8bd3-4e326116ac43
	fi
	echo	'Loading Linux linux-lts ...'
	linux	/boot/vmlinuz-linux-lts root=UUID=14d44e03-023a-4c9a-8bd3-4e326116ac43 rw  loglevel=3 rescue
	echo	'Loading initial ramdisk ...'
	initrd	/boot/intel-ucode.img /boot/initramfs-linux-lts.img
}
menuentry 'Arch Linux, with Linux linux-lts (fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-lts-fallback-14d44e03-023a-4c9a-8bd3-4e326116ac43' {
	savedefault
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod ext2
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  14d44e03-023a-4c9a-8bd3-4e326116ac43
	else
	  search --no-floppy --fs-uuid --set=root 14d44e03-023a-4c9a-8bd3-4e326116ac43
	fi
	echo	'Loading Linux linux-lts ...'
	linux	/boot/vmlinuz-linux-lts root=UUID=14d44e03-023a-4c9a-8bd3-4e326116ac43 rw  loglevel=3 rescue
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initramfs-linux-lts-fallback.img
}
menuentry 'Arch Linux, with Linux linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-14d44e03-023a-4c9a-8bd3-4e326116ac43' {
	savedefault
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod ext2
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  14d44e03-023a-4c9a-8bd3-4e326116ac43
	else
	  search --no-floppy --fs-uuid --set=root 14d44e03-023a-4c9a-8bd3-4e326116ac43
	fi
	echo	'Loading Linux linux ...'
	linux	/boot/vmlinuz-linux root=UUID=14d44e03-023a-4c9a-8bd3-4e326116ac43 rw  loglevel=3 rescue
	echo	'Loading initial ramdisk ...'
	initrd	/boot/intel-ucode.img /boot/initramfs-linux.img
}
menuentry 'Arch Linux, with Linux linux (fallback initramfs)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-fallback-14d44e03-023a-4c9a-8bd3-4e326116ac43' {
	savedefault
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod ext2
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  14d44e03-023a-4c9a-8bd3-4e326116ac43
	else
	  search --no-floppy --fs-uuid --set=root 14d44e03-023a-4c9a-8bd3-4e326116ac43
	fi
	echo	'Loading Linux linux ...'
	linux	/boot/vmlinuz-linux root=UUID=14d44e03-023a-4c9a-8bd3-4e326116ac43 rw  loglevel=3 rescue
	echo	'Loading initial ramdisk ...'
	initrd	/boot/initramfs-linux-fallback.img
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (on /dev/nvme1n1p2)' --class windows --class os $menuentry_id_option 'osprober-efi-7099-39C2' {
	savedefault
	insmod part_gpt
	insmod fat
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  7099-39C2
	else
	  search --no-floppy --fs-uuid --set=root 7099-39C2
	fi
	chainloader /efi/Microsoft/Boot/bootmgfw.efi
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

最近编辑记录 AegirVOD (2021-01-04 18:22:30)

离线

#2 2021-01-03 19:15:01

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,368
个人网站

Re: [已解决]grub不显示所有内核

是不是有多个 grub.cfg 文件,grub 读到了没有更新的那一个?

离线

#3 2021-01-03 19:58:25

AegirVOD
会员
所在地: 斯特拉斯堡
注册时间: 2021-01-03
帖子: 7

Re: [已解决]grub不显示所有内核

依云 说:

是不是有多个 grub.cfg 文件,grub 读到了没有更新的那一个?

我现在也怀疑是这样 但是我并不知道除了/boot/grub之外还有哪里有grub.cfg

离线

#4 2021-01-03 20:13:17

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,368
个人网站

Re: [已解决]grub不显示所有内核

lsblk -o+FSTYPE,FSSIZE,PARTLABEL,LABEL 检查一下,说不定有好几个 /boot 一样的分区和目录呢。

离线

#5 2021-01-04 15:37:40

AegirVOD
会员
所在地: 斯特拉斯堡
注册时间: 2021-01-03
帖子: 7

Re: [已解决]grub不显示所有内核

答案是否定的

NAME     MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT FSTYPE FSSIZE PARTLABEL                  LABEL
nvme0n1  259:0    0 465.8G  0 disk                                                     
├─nvme0n1p1
│        259:1    0    16M  0 part                          Microsoft reserved partition
│                                                                                      
└─nvme0n1p2
         259:2    0 465.7G  0 part            ntfs          Basic data partition       外地磁盘
nvme1n1  259:3    0 238.5G  0 disk                                                     
├─nvme1n1p1
│        259:4    0   529M  0 part            ntfs          Basic data partition       恢复
├─nvme1n1p2
│        259:5    0   100M  0 part            vfat          EFI system partition       
├─nvme1n1p3
│        259:6    0    16M  0 part                          Microsoft reserved partition
│                                                                                      
├─nvme1n1p4
│        259:7    0 198.4G  0 part            ntfs          Basic data partition       
├─nvme1n1p5
│        259:8    0   775M  0 part            ntfs                                     
└─nvme1n1p6
         259:9    0  38.6G  0 part /          ext4    37.8G     

离线

#6 2021-01-04 16:12:47

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,368
个人网站

Re: [已解决]grub不显示所有内核

你看一下你的 EFI 分区?

离线

#7 2021-01-04 17:29:01

AegirVOD
会员
所在地: 斯特拉斯堡
注册时间: 2021-01-03
帖子: 7

Re: [已解决]grub不显示所有内核

破案了,EFI里有个grub
那么该怎么解决呢?我想保留/boot/grub删掉EFI里的grub,该怎么操作

离线

#8 2021-01-04 17:35:25

AegirVOD
会员
所在地: 斯特拉斯堡
注册时间: 2021-01-03
帖子: 7

Re: [已解决]grub不显示所有内核

我悟了,更新grub的时候目录写esp/EFI/grub/grub.cfg就好了 谢谢大佬

离线

#9 2021-01-04 17:40:40

AegirVOD
会员
所在地: 斯特拉斯堡
注册时间: 2021-01-03
帖子: 7

Re: [已解决]grub不显示所有内核

但是出现了一个新问题,更新内核的时候自会自动更新/boot/grub,但我目前使用的是efi分区里的grub,该怎么操作才能让pacman自动更新efi分区的grub呢?

离线

#10 2021-01-04 17:52:03

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,368
个人网站

Re: [已解决]grub不显示所有内核

并不会自动更新 /boot/grub 啊。

离线

#11 2021-01-04 18:22:07

AegirVOD
会员
所在地: 斯特拉斯堡
注册时间: 2021-01-03
帖子: 7

Re: [已解决]grub不显示所有内核

已经ok了,谢谢大佬。

依云 说:

并不会自动更新 /boot/grub 啊。

离线

页脚