博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

双系统安装完Centos7后找不到Windows10的引导信息的解决

Posted on 2020-05-17 14:50  cxysailor  阅读(876)  评论(0)    收藏  举报

双系统安装完Centos7后Windows10的引导信息没有的解决:

10年前的老笔记本,运行Windows10很慢很慢,于是又安装了Centos7系统。结果安装完成Centos7后,启动时找不到Windows10的引导信息了。下面是自己的解决方案:

1. 先查看grub内的信息,没有Windows的引导信息:

 
  1 [root@Centos7<21:31:31-10>~]# cat /boot/grub2/grub.cfg
  2  #
  3  # DO NOT EDIT THIS FILE
  4  #
  5  # It is automatically generated by grub2-mkconfig using templates
  6  # from /etc/grub.d and settings from /etc/default/grub
  7  #
  8   9  ### BEGIN /etc/grub.d/00_header ###
 10  set pager=1
 11  12  if [ -s $prefix/grubenv ]; then
 13    load_env
 14  fi
 15  if [ "${next_entry}" ] ; then
 16     set default="${next_entry}"
 17     set next_entry=
 18     save_env next_entry
 19     set boot_once=true
 20  else
 21     set default="${saved_entry}"
 22  fi
 23  24  if [ x"${feature_menuentry_id}" = xy ]; then
 25    menuentry_id_option="--id"
 26  else
 27    menuentry_id_option=""
 28  fi
 29  30  export menuentry_id_option
 31  32  if [ "${prev_saved_entry}" ]; then
 33    set saved_entry="${prev_saved_entry}"
 34    save_env saved_entry
 35    set prev_saved_entry=
 36    save_env prev_saved_entry
 37    set boot_once=true
 38  fi
 39  40  function savedefault {
 41    if [ -z "${boot_once}" ]; then
 42      saved_entry="${chosen}"
 43      save_env saved_entry
 44    fi
 45  }
 46  47  function load_video {
 48    if [ x$feature_all_video_module = xy ]; then
 49      insmod all_video
 50    else
 51      insmod efi_gop
 52      insmod efi_uga
 53      insmod ieee1275_fb
 54      insmod vbe
 55      insmod vga
 56      insmod video_bochs
 57      insmod video_cirrus
 58    fi
 59  }
 60  61  terminal_output console
 62  if [ x$feature_timeout_style = xy ] ; then
 63    set timeout_style=menu
 64    set timeout=5
 65  # Fallback normal timeout code in case the timeout_style feature is
 66  # unavailable.
 67  else
 68    set timeout=5
 69  fi
 70  ### END /etc/grub.d/00_header ###
 71  72  ### BEGIN /etc/grub.d/00_tuned ###
 73  set tuned_params=""
 74  set tuned_initrd=""
 75  ### END /etc/grub.d/00_tuned ###
 76  77  ### BEGIN /etc/grub.d/01_users ###
 78  if [ -f ${prefix}/user.cfg ]; then
 79    source ${prefix}/user.cfg
 80    if [ -n "${GRUB2_PASSWORD}" ]; then
 81      set superusers="root"
 82      export superusers
 83      password_pbkdf2 root ${GRUB2_PASSWORD}
 84    fi
 85  fi
 86  ### END /etc/grub.d/01_users ###
 87  88  ### BEGIN /etc/grub.d/10_linux ###
 89  menuentry 'CentOS Linux (3.10.0-1062.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-1062.el7.x86_64-advanced-8fae145c-1fb9-4762-afa7-c48c04d8476c' {
 90      load_video
 91      set gfxpayload=keep
 92      insmod gzio
 93      insmod part_msdos
 94      insmod xfs
 95      set root='hd0,msdos9'
 96      if [ x$feature_platform_search_hint = xy ]; then
 97        search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos9 --hint-efi=hd1,msdos9 --hint-baremetal=ahci1,msdos9 --hint='hd0,msdos9'  5db9c979-11bb-4030-8022-7a5dba6ad8a0
 98      else
 99        search --no-floppy --fs-uuid --set=root 5db9c979-11bb-4030-8022-7a5dba6ad8a0
100      fi
101      linux16 /vmlinuz-3.10.0-1062.el7.x86_64 root=/dev/mapper/centos_centos7-root ro crashkernel=auto rd.lvm.lv=centos_centos7/root rd.lvm.lv=centos_centos7/swap rhgb quiet LANG=zh_CN.UTF-8
102      initrd16 /initramfs-3.10.0-1062.el7.x86_64.img
103  }
104  menuentry 'CentOS Linux (0-rescue-02975b1e6081413ba80897bf0600a07e) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-02975b1e6081413ba80897bf0600a07e-advanced-8fae145c-1fb9-4762-afa7-c48c04d8476c' {
105      load_video
106      insmod gzio
107      insmod part_msdos
108      insmod xfs
109      set root='hd0,msdos9'
110      if [ x$feature_platform_search_hint = xy ]; then
111        search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos9 --hint-efi=hd1,msdos9 --hint-baremetal=ahci1,msdos9 --hint='hd0,msdos9'  5db9c979-11bb-4030-8022-7a5dba6ad8a0
112      else
113        search --no-floppy --fs-uuid --set=root 5db9c979-11bb-4030-8022-7a5dba6ad8a0
114      fi
115      linux16 /vmlinuz-0-rescue-02975b1e6081413ba80897bf0600a07e root=/dev/mapper/centos_centos7-root ro crashkernel=auto rd.lvm.lv=centos_centos7/root rd.lvm.lv=centos_centos7/swap rhgb quiet
116      initrd16 /initramfs-0-rescue-02975b1e6081413ba80897bf0600a07e.img
117  }
118 119  ### END /etc/grub.d/10_linux ###
120 121  ### BEGIN /etc/grub.d/20_linux_xen ###
122  ### END /etc/grub.d/20_linux_xen ###
123 124  ### BEGIN /etc/grub.d/20_ppc_terminfo ###
125  ### END /etc/grub.d/20_ppc_terminfo ###
126 127  ### BEGIN /etc/grub.d/30_os-prober ###
128  ### END /etc/grub.d/30_os-prober ###
129 130  ### BEGIN /etc/grub.d/40_custom ###
131  # This file provides an easy way to add custom menu entries.  Simply type the
132  # menu entries you want to add after this comment.  Be careful not to change
133  # the 'exec tail' line above.
134  ### END /etc/grub.d/40_custom ###
135 136  ### BEGIN /etc/grub.d/41_custom ###
137  if [ -f  ${config_directory}/custom.cfg ]; then
138    source ${config_directory}/custom.cfg
139  elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
140    source $prefix/custom.cfg;
141  fi
142  ### END /etc/grub.d/41_custom ###

 

2. 搜索epel并安装

 
 1 [root@Centos7<21:13:54-2>~]# yum search epel
 2  已加载插件:fastestmirror, langpacks
 3  Loading mirror speeds from cached hostfile
 4   * base: mirrors.cqu.edu.cn
 5   * extras: mirrors.aliyun.com
 6   * updates: mirrors.cqu.edu.cn
 7  ========================================================== N/S matched: epel ==========================================================
 8  epel-release.noarch : Extra Packages for Enterprise Linux repository configuration
 9 10    名称和简介匹配 only,使用“search all”试试。
11  [root@Centos7<21:14:47-3>~]# yum -y install epel-release.noarch
12  已加载插件:fastestmirror, langpacks
13  Loading mirror speeds from cached hostfile
14   * base: mirrors.cqu.edu.cn
15   * extras: mirrors.aliyun.com
16   * updates: mirrors.cqu.edu.cn
17  正在解决依赖关系
18  --> 正在检查事务
19  ---> 软件包 epel-release.noarch.0.7-11 将被 安装
20  --> 解决依赖关系完成
21 22  依赖关系解决
23 24  =======================================================================================================================================
25   Package                              架构                           版本                         源                              大小
26  =======================================================================================================================================
27  正在安装:
28   epel-release                         noarch                         7-11                         extras                          15 k
29 30  事务概要
31  =======================================================================================================================================
32  安装  1 软件包
33 34  总下载量:15 k
35  安装大小:24 k
36  Downloading packages:
37  epel-release-7-11.noarch.rpm                                                                                    |  15 kB  00:00:00     
38  Running transaction check
39  Running transaction test
40  Transaction test succeeded
41  Running transaction
42    正在安装    : epel-release-7-11.noarch                                                                                           1/1 
43    验证中      : epel-release-7-11.noarch                                                                                           1/1 
44 45  已安装:
46    epel-release.noarch 0:7-11                                                                                                           
47 48  完毕!

 

3. 安装ntfs-3g

 
 1 [root@Centos7<21:15:17-4>~]# yum -y install ntfs-3g
 2  已加载插件:fastestmirror, langpacks
 3  Loading mirror speeds from cached hostfile
 4  epel/x86_64/metalink                                                                                            | 5.0 kB  00:00:00     
 5   * base: mirrors.cqu.edu.cn
 6   * epel: ftp.yz.yamagata-u.ac.jp
 7   * extras: mirrors.aliyun.com
 8   * updates: mirrors.cqu.edu.cn
 9  epel                                                                                                            | 5.3 kB  00:00:00     
10  (1/3): epel/x86_64/group_gz                                                                                     |  90 kB  00:00:05     
11  (2/3): epel/x86_64/updateinfo                                                                                   | 1.0 MB  00:01:32     
12  (3/3): epel/x86_64/primary_db                                                                                   | 6.9 MB  00:06:11     
13  正在解决依赖关系
14  --> 正在检查事务
15  ---> 软件包 ntfs-3g.x86_64.2.2017.3.23-11.el7 将被 安装
16  --> 解决依赖关系完成
17 18  依赖关系解决
19 20  =======================================================================================================================================
21   Package                       架构                         版本                                      源                          大小
22  =======================================================================================================================================
23  正在安装:
24   ntfs-3g                       x86_64                       2:2017.3.23-11.el7                        epel                       265 k
25 26  事务概要
27  =======================================================================================================================================
28  安装  1 软件包
29 30  总下载量:265 k
31  安装大小:612 k
32  Downloading packages:
33  警告:/var/cache/yum/x86_64/7/epel/packages/ntfs-3g-2017.3.23-11.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEYETA 
34  ntfs-3g-2017.3.23-11.el7.x86_64.rpm 的公钥尚未安装
35  ntfs-3g-2017.3.23-11.el7.x86_64.rpm                                                                             | 265 kB  00:00:57     
36file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 检索密钥
37  导入 GPG key 0x352C64E5:
38   用户ID     : "Fedora EPEL (7) <epel@fedoraproject.org>"
39   指纹       : 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
40   软件包     : epel-release-7-11.noarch (@extras)
41   来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
42  Running transaction check
43  Running transaction test
44  Transaction test succeeded
45  Running transaction
46    正在安装    : 2:ntfs-3g-2017.3.23-11.el7.x86_64                                                                                  1/1 
47    验证中      : 2:ntfs-3g-2017.3.23-11.el7.x86_64                                                                                  1/1 
48 49  已安装:
50    ntfs-3g.x86_64 2:2017.3.23-11.el7                                                                                                    
51 52  完毕!

 

4. 重新建立grub.cfg文件,这个过程中会自动搜索到Windows10并将其添加进去

 
1 [root@Centos7<21:36:17-11>~]# grub2-mkconfig -o /boot/grub2/grub.cfg
2  Generating grub configuration file ...
3  Found linux image: /boot/vmlinuz-3.10.0-1062.el7.x86_64
4  Found initrd image: /boot/initramfs-3.10.0-1062.el7.x86_64.img
5  Found linux image: /boot/vmlinuz-0-rescue-02975b1e6081413ba80897bf0600a07e
6  Found initrd image: /boot/initramfs-0-rescue-02975b1e6081413ba80897bf0600a07e.img
7  Found Windows 10 (loader) on /dev/sda1
8  done

 

5. 再次查看grub.cfg的内容,Windows10已经被加入。重启就能看到Windows10的选项了。

 
  1 [root@Centos7<21:38:05-12>~]# grub2catt/grub2/grub.cfg
  2  #
  3  # DO NOT EDIT THIS FILE
  4  #
  5  # It is automatically generated by grub2-mkconfig using templates
  6  # from /etc/grub.d and settings from /etc/default/grub
  7  #
  8   9  ### BEGIN /etc/grub.d/00_header ###
 10  set pager=1
 11  12  if [ -s $prefix/grubenv ]; then
 13    load_env
 14  fi
 15  if [ "${next_entry}" ] ; then
 16     set default="${next_entry}"
 17     set next_entry=
 18     save_env next_entry
 19     set boot_once=true
 20  else
 21     set default="${saved_entry}"
 22  fi
 23  24  if [ x"${feature_menuentry_id}" = xy ]; then
 25    menuentry_id_option="--id"
 26  else
 27    menuentry_id_option=""
 28  fi
 29  30  export menuentry_id_option
 31  32  if [ "${prev_saved_entry}" ]; then
 33    set saved_entry="${prev_saved_entry}"
 34    save_env saved_entry
 35    set prev_saved_entry=
 36    save_env prev_saved_entry
 37    set boot_once=true
 38  fi
 39  40  function savedefault {
 41    if [ -z "${boot_once}" ]; then
 42      saved_entry="${chosen}"
 43      save_env saved_entry
 44    fi
 45  }
 46  47  function load_video {
 48    if [ x$feature_all_video_module = xy ]; then
 49      insmod all_video
 50    else
 51      insmod efi_gop
 52      insmod efi_uga
 53      insmod ieee1275_fb
 54      insmod vbe
 55      insmod vga
 56      insmod video_bochs
 57      insmod video_cirrus
 58    fi
 59  }
 60  61  terminal_output console
 62  if [ x$feature_timeout_style = xy ] ; then
 63    set timeout_style=menu
 64    set timeout=5
 65  # Fallback normal timeout code in case the timeout_style feature is
 66  # unavailable.
 67  else
 68    set timeout=5
 69  fi
 70  ### END /etc/grub.d/00_header ###
 71  72  ### BEGIN /etc/grub.d/00_tuned ###
 73  set tuned_params=""
 74  set tuned_initrd=""
 75  ### END /etc/grub.d/00_tuned ###
 76  77  ### BEGIN /etc/grub.d/01_users ###
 78  if [ -f ${prefix}/user.cfg ]; then
 79    source ${prefix}/user.cfg
 80    if [ -n "${GRUB2_PASSWORD}" ]; then
 81      set superusers="root"
 82      export superusers
 83      password_pbkdf2 root ${GRUB2_PASSWORD}
 84    fi
 85  fi
 86  ### END /etc/grub.d/01_users ###
 87  88  ### BEGIN /etc/grub.d/10_linux ###
 89  menuentry 'CentOS Linux (3.10.0-1062.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-1062.el7.x86_64-advanced-8fae145c-1fb9-4762-afa7-c48c04d8476c' {
 90      load_video
 91      set gfxpayload=keep
 92      insmod gzio
 93      insmod part_msdos
 94      insmod xfs
 95      set root='hd0,msdos9'
 96      if [ x$feature_platform_search_hint = xy ]; then
 97        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9  5db9c979-11bb-4030-8022-7a5dba6ad8a0
 98      else
 99        search --no-floppy --fs-uuid --set=root 5db9c979-11bb-4030-8022-7a5dba6ad8a0
100      fi
101      linux16 /vmlinuz-3.10.0-1062.el7.x86_64 root=/dev/mapper/centos_centos7-root ro crashkernel=auto rd.lvm.lv=centos_centos7/root rd.lvm.lv=centos_centos7/swap rhgb quiet 
102      initrd16 /initramfs-3.10.0-1062.el7.x86_64.img
103  }
104  menuentry 'CentOS Linux (0-rescue-02975b1e6081413ba80897bf0600a07e) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-02975b1e6081413ba80897bf0600a07e-advanced-8fae145c-1fb9-4762-afa7-c48c04d8476c' {
105      load_video
106      insmod gzio
107      insmod part_msdos
108      insmod xfs
109      set root='hd0,msdos9'
110      if [ x$feature_platform_search_hint = xy ]; then
111        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9  5db9c979-11bb-4030-8022-7a5dba6ad8a0
112      else
113        search --no-floppy --fs-uuid --set=root 5db9c979-11bb-4030-8022-7a5dba6ad8a0
114      fi
115      linux16 /vmlinuz-0-rescue-02975b1e6081413ba80897bf0600a07e root=/dev/mapper/centos_centos7-root ro crashkernel=auto rd.lvm.lv=centos_centos7/root rd.lvm.lv=centos_centos7/swap rhgb quiet 
116      initrd16 /initramfs-0-rescue-02975b1e6081413ba80897bf0600a07e.img
117  }
118  if [ "x$default" = 'CentOS Linux (3.10.0-1062.el7.x86_64) 7 (Core)' ]; then default='Advanced options for CentOS Linux>CentOS Linux (3.10.0-1062.el7.x86_64) 7 (Core)'; fi;
119  ### END /etc/grub.d/10_linux ###
120 121  ### BEGIN /etc/grub.d/20_linux_xen ###
122  ### END /etc/grub.d/20_linux_xen ###
123 124  ### BEGIN /etc/grub.d/20_ppc_terminfo ###
125  ### END /etc/grub.d/20_ppc_terminfo ###
126 127  ### BEGIN /etc/grub.d/30_os-prober ###
128  menuentry 'Windows 10 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-D440386240384D8C' {
129      insmod part_msdos
130      insmod ntfs
131      set root='hd0,msdos1'
132      if [ x$feature_platform_search_hint = xy ]; then
133        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  D440386240384D8C
134      else
135        search --no-floppy --fs-uuid --set=root D440386240384D8C
136      fi
137      parttool ${root} hidden-
138      drivemap -s (hd0) ${root}
139      chainloader +1
140  }
141  ### END /etc/grub.d/30_os-prober ###
142 143  ### BEGIN /etc/grub.d/40_custom ###
144  # This file provides an easy way to add custom menu entries.  Simply type the
145  # menu entries you want to add after this comment.  Be careful not to change
146  # the 'exec tail' line above.
147  ### END /etc/grub.d/40_custom ###
148 149  ### BEGIN /etc/grub.d/41_custom ###
150  if [ -f  ${config_directory}/custom.cfg ]; then
151    source ${config_directory}/custom.cfg
152  elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
153    source $prefix/custom.cfg;
154  fi 
155 ### END /etc/grub.d/41_custom ###