安装 arch linux 后不显示 Grub 菜单

安装 arch linux 后不显示 Grub 菜单

我第一次尝试在 Windows 和双启动中安装 Arch Linux,但遇到了一个小问题。我正在尝试设置 GRUB,但是当我启动 PC 时,Windows 会加载,但不会显示 GRUB 菜单。我尝试了互联网上的一些解决方案,但没有一个对我有帮助。

这是我尝试做的:

  1. 我安装了根分区
    mount /dev/nvme0n1p6 /mnt
    
  2. 我挂载了EFI分区
    mount /dev/nvme0n1p2 /mnt/efi
    
  3. 我登录了系统
    arch-root /mnt
    
  4. 我安装了grub
    grub-install --target=x86_64-efi --efi-directory=/efi/ --bootloader-id=GRUB
    
  5. 并生成grub配置
    grub-mkconfig -o /boot/grub/grub.cfg
    

这是安装程序生成的内容,与 Windows 无关:

#
# 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 btrfs
search --no-floppy --fs-uuid --set=root e5bb549c-2301-4d33-a4ca-f7be8fa28d1a
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
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' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-e5bb549c-2301-4d33-a4ca-f7be8fa28d1a' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod btrfs
    search --no-floppy --fs-uuid --set=root e5bb549c-2301-4d33-a4ca-f7be8fa28d1a
    echo    'Loading Linux linux ...'
    linux   /boot/vmlinuz-linux root=UUID=e5bb549c-2301-4d33-a4ca-f7be8fa28d1a rw  loglevel=3 quiet
    echo    'Loading initial ramdisk ...'
    initrd  /boot/initramfs-linux.img
}
submenu 'Advanced options for Arch Linux' $menuentry_id_option 'gnulinux-advanced-e5bb549c-2301-4d33-a4ca-f7be8fa28d1a' {
    menuentry 'Arch Linux, with Linux linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-linux-advanced-e5bb549c-2301-4d33-a4ca-f7be8fa28d1a' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod btrfs
        search --no-floppy --fs-uuid --set=root e5bb549c-2301-4d33-a4ca-f7be8fa28d1a
        echo    'Loading Linux linux ...'
        linux   /boot/vmlinuz-linux root=UUID=e5bb549c-2301-4d33-a4ca-f7be8fa28d1a rw  loglevel=3 quiet
        echo    'Loading initial ramdisk ...'
        initrd  /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-e5bb549c-2301-4d33-a4ca-f7be8fa28d1a' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod btrfs
        search --no-floppy --fs-uuid --set=root e5bb549c-2301-4d33-a4ca-f7be8fa28d1a
        echo    'Loading Linux linux ...'
        linux   /boot/vmlinuz-linux root=UUID=e5bb549c-2301-4d33-a4ca-f7be8fa28d1a rw  loglevel=3 quiet
        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/25_bli ###
if [ "$grub_platform" = "efi" ]; then
  insmod bli
fi
### END /etc/grub.d/25_bli ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
if [ "$grub_platform" = "efi" ]; then
    fwsetup --is-supported
    if [ "$?" = 0 ]; then
        menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
            fwsetup
        }
    fi
fi
### 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.
### 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 ###

然后我也尝试取消注释行/etc/default/grub

GRUB_DISABLE_OS_PROBER=false 

做了同样的事情,但无论如何它都没有检测到 Windows。这是我生成 GRUB 配置后收到的消息:

Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot:  initramfs-linux-fallback.img
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Adding boot menu entry for UEFI Firmware Settings ...
done

但结果是一样的。

另外,这是我的所有分区:

Device              Start        End    Sectors   Size Type
/dev/nvme0n1p1       2048    1023999    1021952   499M Windows recovery environment
/dev/nvme0n1p2    1024000    1228799     204800   100M EFI System
/dev/nvme0n1p3    1228800    1261567      32768    16M Microsoft reserved
/dev/nvme0n1p4    1261568 1409193983 1407932416 671.4G Microsoft basic data
/dev/nvme0n1p5 1952376832 1953521663    1144832   559M Windows recovery environment
/dev/nvme0n1p6 1409193984 1948162047  538968064   257G Linux filesystem
/dev/nvme0n1p7 1948162048 1952376831    4214784     2G Linux swap

Windows 启动位于/efi/EFI/Microsoft/Boot该目录。

efibootmgr这是命令的结果

BootCurrent: 0005
Timeout: 1 seconds
BootOrder: 0005,0004,0001
Boot0001* Windows Boot Manager  HD(2,GPT,da178692-f29b-4f3d-acbf-e3259f35817a,0xfa000,0x32000)/File(\EFI\GRUB\GRUBX64.EFI)57494e444f5753000100000088000000780000004200430044004f0042004a004500430054003d007b00390064006500610038003600320063002d0035006300640064002d0034006500370030002d0061006300630031002d006600330032006200330034003400640034003700390035007d00000061000100000010000000040000007fff0400
Boot0004* Windows Boot Manager  HD(2,GPT,da178692-f29b-4f3d-acbf-e3259f35817a,0xfa000,0x32000)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)0000424f
Boot0005* UEFI:  USB DISK 2.0 PMAP, Partition 1 PciRoot(0x0)/Pci(0x1,0x2)/Pci(0x0,0x0)/USB(6,0)/HD(1,MBR,0x36f5a9fc,0x800,0x39d1800)0000424f

因此,如果您知道可能出现什么问题,请告诉我。

相关内容