您尚未登录。

#1 2021-07-02 09:25:17

Sloclee
会员
注册时间: 2021-07-02
帖子: 9

无法显示自定义menuentry

这是我的 /etc/grub.d/40_custom

#!/bin/sh
  1 exec tail -n +3 $0
  2 # This file provides an easy way to add custom menu entries.  Simply type the
  3 # menu entries you want to add after this comment.  Be careful not to change
  4 # the 'exec tail' line above.
  5
  6 menuentry 'Windows 10' {
  7         set root='hd0,gpt1'
  8         chainloader /efi/Microsoft/Boot/bootmgfw.efi
  9         boot
 10 }
 11 menuentry "System shutdown" {
 12         echo "System shutting down..."
 13         halt
 14 }
 15 menuentry "System shutdown" {
 16         echo "System shutting down..."
 17         halt
 18 }

执行 grub-mkconfig -o /boot/grub/grub.cfg重启之后无法显示自定义启动项
这是我的/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
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  4498e802-074f-4a7b-a8b0-407f3b82d253
else
  search --no-floppy --fs-uuid --set=root 4498e802-074f-4a7b-a8b0-407f3b82d253
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 ###

### 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 ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
	fwsetup
}
### END /etc/grub.d/30_uefi-firmware ###

### 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.

menuentry 'Windows 10' {
        set root='hd0,gpt1'
        chainloader /efi/Microsoft/Boot/bootmgfw.efi
        boot
}
menuentry "System shutdown" {
	echo "System shutting down..."
	halt
}
menuentry "System shutdown" {
	echo "System shutting down..."
	halt
}
### 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 ###

顺带一提(可能有用的信息):
我是kali转来的额,有两块硬盘,一块windows一块kali,其中windows的引导项在kali硬盘上,kali重装arch之后我把之前kali上的windows启动项整到了现在的启动分区的EFI路径下,长这样:

➜  ~ sudo mount /dev/sda1 /mnt
➜  ~ ls /mnt/EFI/Microsoft/Boot/bootmgfw.efi
/mnt/EFI/Microsoft/Boot/bootmgfw.efi

并且从grub shell里是可以启动的
请问大佬们如何解决? mad

离线

#2 2021-07-02 09:55:26

Sloclee
会员
注册时间: 2021-07-02
帖子: 9

Re: 无法显示自定义menuentry

ok./etc/grub.d/40_custom shutdown 重复了,但是问题不在这

离线

#3 2021-07-02 17:56:48

Sloclee
会员
注册时间: 2021-07-02
帖子: 9

Re: 无法显示自定义menuentry

mad

离线

#4 2021-07-03 09:40:21

Sloclee
会员
注册时间: 2021-07-02
帖子: 9

Re: 无法显示自定义menuentry

我的/etc/fstab文件是空的,会不会跟这个有关系

离线

#5 2021-07-03 11:30:26

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

Re: 无法显示自定义menuentry

Sloclee 说:

我的/etc/fstab文件是空的,会不会跟这个有关系

不会。

离线

#6 2021-07-07 11:59:06

Sloclee
会员
注册时间: 2021-07-02
帖子: 9

Re: 无法显示自定义menuentry

依云 说:
Sloclee 说:

我的/etc/fstab文件是空的,会不会跟这个有关系

不会。

额。。。应该是有关系的
fstab文件是空的意味着boot分区没有自动挂载,否则grub-mkconfig没有实际写入boot分区

离线

#7 2021-07-07 12:13:13

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

Re: 无法显示自定义menuentry

Sloclee 说:
依云 说:
Sloclee 说:

我的/etc/fstab文件是空的,会不会跟这个有关系

不会。

额。。。应该是有关系的
fstab文件是空的意味着boot分区没有自动挂载,否则grub-mkconfig没有实际写入boot分区

呃,好吧……每一个神奇的问题背后都有一个神奇的原因……

所以你是新装的系统?不然早出各种问题了。

离线

#8 2021-07-07 13:20:16

Sloclee
会员
注册时间: 2021-07-02
帖子: 9

Re: 无法显示自定义menuentry

依云 说:
Sloclee 说:
依云 说:
Sloclee 说:

我的/etc/fstab文件是空的,会不会跟这个有关系

不会。

额。。。应该是有关系的
fstab文件是空的意味着boot分区没有自动挂载,否则grub-mkconfig没有实际写入boot分区

呃,好吧……每一个神奇的问题背后都有一个神奇的原因……

所以你是新装的系统?不然早出各种问题了。

发这篇贴的时候装的 big_smile

离线

页脚