Linux

Grub 在啟動時未載入

  • January 7, 2017

我剛剛安裝了 Fedora,在 Windows 10 之前我只有一個分區。

當我執行 grub2-mkconfig 時,它會辨識我的所有分區,包括 Windows,但是在啟動時 grub 沒有載入,我不知道為什麼。

這是 bootinfoscript 的結果:

[root@localhost Téléchargements]# cat RESULTS1.txt 
                 Boot Info Script 0.61      [1 April 2012]


============================= Boot Info Summary: ===============================

=> Grub2 (v1.99) is installed in the MBR of /dev/sda and looks at sector 1 of 
   the same hard drive for core.img, but core.img can not be found at this 
   location.

sda1: __________________________________________________________________________

   File system:       ntfs
   Boot sector type:  Windows Vista/7: NTFS
   Boot sector info:  No errors found in the Boot Parameter Block.
   Operating System:  
   Boot files:        /bootmgr /Boot/BCD

sda2: __________________________________________________________________________

   File system:       ntfs
   Boot sector type:  Windows Vista/7: NTFS
   Boot sector info:  No errors found in the Boot Parameter Block.
   Operating System:  
   Boot files:        /bootmgr /Windows/System32/winload.exe

sda3: __________________________________________________________________________

   File system:       ext4
   Boot sector type:  -
   Boot sector info: 
   Operating System:  
   Boot files:        /grub2/grub.cfg

sda4: __________________________________________________________________________

   File system:       Extended Partition
   Boot sector type:  -
   Boot sector info: 

sda5: __________________________________________________________________________

   File system:       LVM2_member
   Boot sector type:  -
   Boot sector info: 

fedora-root': __________________________________________________________________

   File system:       
   Boot sector type:  Unknown
   Boot sector info: 
   Mounting failed:   mount: type de système de fichiers «  » inconnu

fedora-home': __________________________________________________________________

   File system:       
   Boot sector type:  Unknown
   Boot sector info: 
   Mounting failed:   mount: type de système de fichiers «  » inconnu
mount: type de système de fichiers «  » inconnu

fedora-swap': __________________________________________________________________

   File system:       
   Boot sector type:  Unknown
   Boot sector info: 
   Mounting failed:   mount: type de système de fichiers «  » inconnu
mount: type de système de fichiers «  » inconnu
mount: type de système de fichiers «  » inconnu

============================ Drive/Partition Info: =============================

Drive: sda _____________________________________________________________________
Disque /dev/sda : 465,8 GiB, 500107862016 octets, 976773168 secteurs
Unités : secteur de 1 × 512 = 512 octets
Taille de secteur (logique / physique) : 512 octets / 4096 octets
taille d'E/S (minimale / optimale) : 4096 octets / 4096 octets
Type d'étiquette de disque : dos

Partition  Boot  Start Sector    End Sector  # of Sectors  Id System

/dev/sda1    *          2,048     1,026,047     1,024,000   7 NTFS / exFAT / HPFS
/dev/sda2           1,026,048   567,171,071   566,145,024   7 NTFS / exFAT / HPFS
/dev/sda3         567,171,072   568,195,071     1,024,000  83 Linux
/dev/sda4         568,195,072   976,773,119   408,578,048   5 Extended
/dev/sda5         568,197,120   976,773,119   408,576,000  8e Linux LVM


"blkid" output: ________________________________________________________________

Device           UUID                                   TYPE       LABEL

/dev/mapper/fedora-home 00bfc56c-294f-4046-bba2-99fb30e4a4a8   ext4       
/dev/mapper/fedora-root ac8b6fdd-f61e-4d57-816d-e6c622da2bcf   ext4       
/dev/mapper/fedora-swap 3f5cc25c-8d06-4e62-9b82-60d22cd4f5a9   swap       
/dev/sda1        F0B493D7B4939EA2                       ntfs       System Reserved
/dev/sda2        0C289A0B2899F3C4                       ntfs       
/dev/sda3        fe45d0e2-0249-4a07-8b63-bc77355f0f36   ext4       
/dev/sda5        Zxdt6P-yzEx-TPNV-AL2Z-whcG-wmGd-TF7Zh1 LVM2_member 

========================= "ls -R /dev/mapper/" output: =========================

/dev/mapper:
control
fedora-home
fedora-root
fedora-swap

================================ Mount points: =================================

Device           Mount_Point              Type       Options

/dev/mapper/fedora-home /home                    ext4       (rw,relatime,seclabel,data=ordered)
/dev/mapper/fedora-root /                        ext4       (rw,relatime,seclabel,data=ordered)
/dev/sda3        /boot                    ext4       (rw,relatime,seclabel,stripe=4,data=ordered)


============================= sda3/grub2/grub.cfg: =============================

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

### BEGIN /etc/grub.d/00_header ###
set pager=1

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="${saved_entry}"
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
}

terminal_output console
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 'Fedora (4.0.4-301.fc22.x86_64) 22 (Twenty Two)' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.0.4-301.fc22.x86_64-advanced-ac8b6fdd-f61e-4d57-816d-e6c622da2bcf' {
   load_video
   set gfxpayload=keep
   insmod gzio
   insmod part_msdos
   insmod ext2
   set root='hd0,msdos3'
   if [ x$feature_platform_search_hint = xy ]; then
     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 --hint='hd0,msdos3'  fe45d0e2-0249-4a07-8b63-bc77355f0f36
   else
     search --no-floppy --fs-uuid --set=root fe45d0e2-0249-4a07-8b63-bc77355f0f36
   fi
   linux16 /vmlinuz-4.0.4-301.fc22.x86_64 root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/swap rd.lvm.lv=fedora/root nomodeset rhgb quiet 
   initrd16 /initramfs-4.0.4-301.fc22.x86_64.img
}
menuentry 'Fedora (0-rescue-cd6ce6bdaccc46a5abc4622660518663) 22 (Twenty Two)' --class fedora --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-cd6ce6bdaccc46a5abc4622660518663-advanced-ac8b6fdd-f61e-4d57-816d-e6c622da2bcf' {
   load_video
   insmod gzio
   insmod part_msdos
   insmod ext2
   set root='hd0,msdos3'
   if [ x$feature_platform_search_hint = xy ]; then
     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 --hint='hd0,msdos3'  fe45d0e2-0249-4a07-8b63-bc77355f0f36
   else
     search --no-floppy --fs-uuid --set=root fe45d0e2-0249-4a07-8b63-bc77355f0f36
   fi
   linux16 /vmlinuz-0-rescue-cd6ce6bdaccc46a5abc4622660518663 root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/swap rd.lvm.lv=fedora/root nomodeset rhgb quiet 
   initrd16 /initramfs-0-rescue-cd6ce6bdaccc46a5abc4622660518663.img
}
if [ "x$default" = 'Fedora (4.0.4-301.fc22.x86_64) 22 (Twenty Two)' ]; then default='Advanced options for Fedora>Fedora (4.0.4-301.fc22.x86_64) 22 (Twenty Two)'; fi;
### END /etc/grub.d/10_linux ###

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

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

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

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Recovery Environment (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-F0B493D7B4939EA2' {
   insmod part_msdos
   insmod ntfs
   set root='hd0,msdos1'
   if [ x$feature_platform_search_hint = xy ]; then
     search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  F0B493D7B4939EA2
   else
     search --no-floppy --fs-uuid --set=root F0B493D7B4939EA2
   fi
   parttool ${root} hidden-
   drivemap -s (hd0) ${root}
   chainloader +1
}
### 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 ###
--------------------------------------------------------------------------------

=================== sda3: Location of files loaded by Grub: ====================

          GiB - GB             File                                 Fragment(s)


================= sda3: Location of files loaded by Syslinux: ==================

          GiB - GB             File                                 Fragment(s)


============== sda3: Version of COM32(R) files used by Syslinux: ===============

extlinux/cat.c32                   :  not a COM32/COM32R module
extlinux/chain.c32                 :  not a COM32/COM32R module
extlinux/cmd.c32                   :  not a COM32/COM32R module
extlinux/cmenu.c32                 :  not a COM32/COM32R module
extlinux/config.c32                :  not a COM32/COM32R module
extlinux/cptime.c32                :  not a COM32/COM32R module
extlinux/cpu.c32                   :  not a COM32/COM32R module
extlinux/cpuid.c32                 :  not a COM32/COM32R module
extlinux/cpuidtest.c32             :  not a COM32/COM32R module
extlinux/debug.c32                 :  not a COM32/COM32R module
extlinux/dhcp.c32                  :  not a COM32/COM32R module
extlinux/disk.c32                  :  not a COM32/COM32R module
extlinux/dmi.c32                   :  not a COM32/COM32R module
extlinux/dmitest.c32               :  not a COM32/COM32R module
extlinux/elf.c32                   :  not a COM32/COM32R module
extlinux/ethersel.c32              :  not a COM32/COM32R module
extlinux/gfxboot.c32               :  not a COM32/COM32R module
extlinux/gpxecmd.c32               :  not a COM32/COM32R module
extlinux/hdt.c32                   :  not a COM32/COM32R module
extlinux/hexdump.c32               :  not a COM32/COM32R module
extlinux/host.c32                  :  not a COM32/COM32R module
extlinux/ifcpu64.c32               :  not a COM32/COM32R module
extlinux/ifcpu.c32                 :  not a COM32/COM32R module
extlinux/ifmemdsk.c32              :  not a COM32/COM32R module
extlinux/ifplop.c32                :  not a COM32/COM32R module
extlinux/kbdmap.c32                :  not a COM32/COM32R module
extlinux/kontron_wdt.c32           :  not a COM32/COM32R module
extlinux/ldlinux.c32               :  not a COM32/COM32R module
extlinux/lfs.c32                   :  not a COM32/COM32R module
extlinux/libcom32.c32              :  not a COM32/COM32R module
extlinux/libgpl.c32                :  not a COM32/COM32R module
extlinux/liblua.c32                :  not a COM32/COM32R module
extlinux/libmenu.c32               :  not a COM32/COM32R module
extlinux/libutil.c32               :  not a COM32/COM32R module
extlinux/linux.c32                 :  not a COM32/COM32R module
extlinux/ls.c32                    :  not a COM32/COM32R module
extlinux/lua.c32                   :  not a COM32/COM32R module
extlinux/mboot.c32                 :  not a COM32/COM32R module
extlinux/meminfo.c32               :  not a COM32/COM32R module
extlinux/menu.c32                  :  not a COM32/COM32R module
extlinux/pci.c32                   :  not a COM32/COM32R module
extlinux/pcitest.c32               :  not a COM32/COM32R module
extlinux/pmload.c32                :  not a COM32/COM32R module
extlinux/poweroff.c32              :  not a COM32/COM32R module
extlinux/prdhcp.c32                :  not a COM32/COM32R module
extlinux/pwd.c32                   :  not a COM32/COM32R module
extlinux/pxechn.c32                :  not a COM32/COM32R module
extlinux/reboot.c32                :  not a COM32/COM32R module
extlinux/rosh.c32                  :  not a COM32/COM32R module
extlinux/sanboot.c32               :  not a COM32/COM32R module
extlinux/sdi.c32                   :  not a COM32/COM32R module
extlinux/sysdump.c32               :  not a COM32/COM32R module
extlinux/syslinux.c32              :  not a COM32/COM32R module
extlinux/vesa.c32                  :  not a COM32/COM32R module
extlinux/vesainfo.c32              :  not a COM32/COM32R module
extlinux/vesamenu.c32              :  not a COM32/COM32R module
extlinux/vpdtest.c32               :  not a COM32/COM32R module
extlinux/whichsys.c32              :  not a COM32/COM32R module
extlinux/zzjson.c32                :  not a COM32/COM32R module

======================== Unknown MBRs/Boot Sectors/etc: ========================

Unknown BootLoader on fedora-root'


Unknown BootLoader on fedora-home'


Unknown BootLoader on fedora-swap'



=============================== StdErr Messages: ===============================

cat: /tmp/BootInfo-u5y24xBB/Tmp_Log: Aucun fichier ou dossier de ce type
cat: /tmp/BootInfo-u5y24xBB/Tmp_Log: Aucun fichier ou dossier de ce type
 Failed to find logical volume "fedora/root'"
 Failed to find logical volume "fedora/root'"
 Failed to find logical volume "fedora/root'"
hexdump: /dev/mapper/fedora-root': Aucun fichier ou dossier de ce type
hexdump: stdin: Mauvais descripteur de fichier
hexdump: /dev/mapper/fedora-root': Aucun fichier ou dossier de ce type
hexdump: échec de tous les arguments de fichier d'entrée
 Failed to find logical volume "fedora/home'"
 Failed to find logical volume "fedora/home'"
 Failed to find logical volume "fedora/home'"
hexdump: /dev/mapper/fedora-home': Aucun fichier ou dossier de ce type
hexdump: stdin: Mauvais descripteur de fichier
hexdump: /dev/mapper/fedora-home': Aucun fichier ou dossier de ce type
hexdump: échec de tous les arguments de fichier d'entrée
 Failed to find logical volume "fedora/swap'"
 Failed to find logical volume "fedora/swap'"
 Failed to find logical volume "fedora/swap'"
hexdump: /dev/mapper/fedora-swap': Aucun fichier ou dossier de ce type
hexdump: stdin: Mauvais descripteur de fichier
hexdump: /dev/mapper/fedora-swap': Aucun fichier ou dossier de ce type
hexdump: échec de tous les arguments de fichier d'entrée
mdadm: No arrays found in config file or automatically

知道問題所在嗎?

問題似乎就在這裡:

=> Grub2 (v1.99) is installed in the MBR of /dev/sda and
looks at sector 1 of the same hard drive for core.img, but
core.img can not be found at this location.

您需要使用 grub-install 將 grub 重新安裝到 MBR 中。

該過程將根據您的特定設置而有所不同,但大致如下:

  • 使用安裝程序或救援 CD 啟動
  • 進入根外殼
  • 將根分區掛載為 /target
  • 將引導分區掛載為 /target/boot
  • 在 /target 下綁定掛載 /dev、/sys 和 /proc,例如:

for i in proc dev sys ; do mount -o bind /$i /target/$i ; done

  • chroot /target
  • grub-install /dev/sda
  • exit
  • for i in /proc /dev /sys /boot /; do umount /target$i ; done
  • 重啟

引用自:https://unix.stackexchange.com/questions/231162