Window10和Ubuntu 18.04双系统安装的引导问题解决

  作为码农

  首先,建议了解下grub2的启动顺序和逻辑。可以参考这篇文章,grub.cfg详解

  从执行顺序倒推,如下如果全部执行成功,则会进入grub的启动菜单;如果最后一步,没有找到grub.cfg或者执行grub.cfg出错,则进入grub普通模式;如果倒数第二步,家在normal.mod模块失败,则进入grub secure模式。

GRUB2在BIOS平台上的常规启动步骤是这样的:BIOS --> boot.img[MBR] --> core.img[MBR gap/embedding area/BIOS Boot Partition] --> 设置"prefix root cmdpath"环境变量 --> 加载"normal.mod"模块[同时还包括它所依赖的 terminal crypto extcmd boot gettext 模块] --> 执行"normal $prefix/grub.cfg"命令

GRUB2在UEFI平台上的常规启动步骤是这样的:UEFI --> core.img[BOOTX64.EFI/BOOTX86.EFI] --> 设置"prefix root cmdpath"环境变量 --> 加载"normal.mod"模块[同时还包括它所依赖的 terminal crypto extcmd boot gettext 模块] --> 执行"normal $prefix/grub.cfg"命令

  

  这里我们分别介绍两种模式下的解决方式:

  • Grub普通模式
    • 手动引导进入系统
      • ls 可以看到形如 (hd0, gpt2)之类的硬盘分区, ls (hd0,gpt2)/root/之类的可以看到文件系统结构;
      • 找到要启动的系统路径,主要是grub目录、vmlinux、initrd,如下图
        •   
          # ll /boot/
          总用量 135336
          drwxr-xr-x  4 root root     4096 7月  10 22:22 ./
          drwxr-xr-x 24 root root     4096 7月  10 22:20 ../
          -rw-r--r--  1 root root  1536934 4月  24 12:56 abi-4.15.0-20-generic
          -rw-r--r--  1 root root  1537050 5月  24 00:54 abi-4.15.0-23-generic
          -rw-r--r--  1 root root   216807 4月  24 12:56 config-4.15.0-20-generic
          -rw-r--r--  1 root root   216807 5月  24 00:54 config-4.15.0-23-generic
          drwxr-xr-x  3 root root     4096 1月   1  1970 efi/
          drwxr-xr-x  5 root root     4096 8月   5 07:38 grub/
          -rw-r--r--  1 root root 55988734 7月  10 22:20 initrd.img-4.15.0-20-generic
          -rw-r--r--  1 root root 53910349 7月  10 22:22 initrd.img-4.15.0-23-generic
          -rw-r--r--  1 root root   182704 1月  28  2016 memtest86+.bin
          -rw-r--r--  1 root root   184380 1月  28  2016 memtest86+.elf
          -rw-r--r--  1 root root   184840 1月  28  2016 memtest86+_multiboot.bin
          -rw-r--r--  1 root root        0 4月  24 12:56 retpoline-4.15.0-20-generic
          -rw-r--r--  1 root root        0 5月  24 00:54 retpoline-4.15.0-23-generic
          -rw-------  1 root root  4038188 4月  24 12:56 System.map-4.15.0-20-generic
          -rw-------  1 root root  4039393 5月  24 00:54 System.map-4.15.0-23-generic
          -rw-r--r--  1 root root  8249080 4月  27 10:40 vmlinuz-4.15.0-20-generic
          -rw-------  1 root root  8257272 5月  24 01:49 vmlinuz-4.15.0-23-generic
      • 设置grub boot环境,其中root的地址为要启动的linux系统(如Ubuntu)所在的硬盘分区节点名。hd0对应sda,hd1对应sdb,以此类推。。。(hd0,gpt1)对应sda1,(hd1, gpt2)对应sdb2以此类推。。。
        • set boot=(hd0,gpt2)
          linux /boot/vmlinuz-4.15.0-23-generic root=/dev/sda2
          initrd /boot/initrd.img-4.15.0-23-generic
    • 修复引导
  • Grub Secure模式
    • 手动引导进入系统, LInk
    • 修复引导

猜你喜欢

转载自www.cnblogs.com/icxy/p/9420885.html