Centos7 和 Window7 grub 重启后不起作用

Centos7 和 Window7 grub 重启后不起作用

我在台式电脑上安装了Centos7和Windows,我的电脑最初启动成功。

但是最近我从 Windows 7 中删除了一个文件分区,该分区是我安装 Centos7 的,由于 Centos7 运行良好,所以我删除了它,现在我将空间合并到一个现有的 Windows 分区。

从那时起,每次我启动(或重新启动)计算机时都会收到以下错误消息:

error:unknown filesystem.
Entering resuce mode
grub resuce>

使用set将获得以下消息:

>set
prefix=(hd0,msdos9)/boot/grub2
root=hd0,msdos9

现在我找到了问题的根源:msdos8应该改为msdos9,所以我输入了下面的代码:

>set prefix=(hd0,msdos8)/boot/grub2
>set root=hd0,msdos8
>insmod normal
>normal

完成此操作后,系统可以成功启动,我可以选择启动Windows还是Linux。

但问题是:如果我下次重新启动或启动计算机,我仍然会收到上述错误列表,并且我必须set再次执行此操作

我想知道是否有办法永久解决此问题,这样我就不需要set每次都使用它来纠正它。提前谢谢!

我尝试过修改grub配置文件在下面/启动/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/01_users ###
if [ -f ${prefix}/user.cfg ]; then
  source ${prefix}/user.cfg
  if [ -n "${GRUB2_PASSWORD}" ]; then
    set superusers="root"
    export superusers
    password_pbkdf2 root ${GRUB2_PASSWORD}
  fi
fi
### END /etc/grub.d/01_users ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'CentOS Linux  7' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.21.1.el7.x86_64-advanced-ec143453-515a-4bc9-b17b-6bd33f305e3a' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos8'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos8 --hint-efi=hd0,msdos8 --hint-baremetal=ahci0,msdos8 --hint='hd0,msdos8'  1f858d09-5ce8-435e-9aba-7f48c3100abe
        else
          search --no-floppy --fs-uuid --set=root 1f858d09-5ce8-435e-9aba-7f48c3100abe
        fi
        linux16 /vmlinuz-3.10.0-693.21.1.el7.x86_64 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/swap vconsole.keymap=us rd.lvm.lv=centos/usr crashkernel=auto  vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root rhgb quiet 
        initrd16 /initramfs-3.10.0-693.21.1.el7.x86_64.img
}
if [ "x$default" = 'CentOS Linux 7' ]; then default='Advanced options for CentOS Linux>CentOS Linux (3.10.0-693.21.1.el7.x86_64) 7 (Core)'; 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 7' --class windows --class os $menuentry_id_option 'osprober-chain-C4DC2ACFDC2ABB94' {
        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'  C4DC2ACFDC2ABB94
        else
          search --no-floppy --fs-uuid --set=root C4DC2ACFDC2ABB94
        fi
        parttool ${root} hidden-
        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 ###

答案1

最后我发现使用grub2-installwithroot可以解决这个问题:

grub2-install /dev/sda

相关内容