{"id":5909,"date":"2022-06-15T17:42:38","date_gmt":"2022-06-15T09:42:38","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=5909"},"modified":"2022-06-16T01:08:38","modified_gmt":"2022-06-15T17:08:38","slug":"let-grub2-save-bootloader","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/let-grub2-save-bootloader.html","title":{"rendered":"\u8ba9Grub 2\u6765\u62ef\u6551\u4f60\u7684 bootloader"},"content":{"rendered":"
\n

\u672c\u6587\u7531lrxjmw.cn\u56e2\u961f\u6210\u5458\u9b4f\u4e3d\u733f<\/span>\u6574\u7406\u53d1\u5e03\uff0c\u70b9\u6b64\u67e5\u770b\u6700\u65b0Linux\u8d44\u8baf<\/a><\/span><\/strong>\u3002<\/p>\n<\/div>\n

\u6ca1\u6709\u4ec0\u4e48\u4e8b\u60c5\u6bd4 bootloader \u574f\u6389\u66f4\u6c14\u4eba\u7684\u4e86\uff0c\u5145\u5206\u53d1\u6325 Grub 2 \u7684\u4f5c\u7528\uff0c\u8ba9 bootloader \u5b89\u5206\u5de5\u4f5c\u5427\u3002\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u8bf4\uff1f<\/p>\n

    \n
  1. Grub 2 \u662f\u6700\u53d7\u6b22\u8fce\u7684 bootloader \uff0c\u51e0\u4e4e\u7528\u5728\u6240\u6709 Linux \u53d1\u884c\u7248\u4e0a\u3002<\/strong><\/li>\n
  2. bootloader \u662f\u4e00\u4e2a\u81f3\u5173\u91cd\u8981\u7684\u8f6f\u4ef6\uff0c\u4f46\u662f\u975e\u5e38\u5bb9\u6613\u635f\u574f\u3002<\/strong><\/li>\n
  3. Grub 2 \u662f\u517c\u5177\u6269\u5c55\u6027\u548c\u7075\u6d3b\u6027\u7684\u4e00\u6b3e\u5f15\u5bfc\u52a0\u8f7d\u7a0b\u5e8f\uff0c\u63d0\u4f9b\u4e86\u5927\u91cf\u53ef\u5b9a\u5236\u9009\u9879\u3002<\/strong><\/li>\n<\/ol>\n

    Grub 2 \u662f\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684\u8f6f\u4ef6\uff0c\u5b83\u4e0d\u662f bootloader \u754c\u7684\u552f\u4e00\uff0c\u4f46\u5374\u6700\u53d7\u6b22\u8fce\uff0c\u51e0\u4e4e\u6240\u6709\u4e3b\u6d41\u7684\u684c\u9762\u53d1\u884c\u7248\u90fd\u5728\u4f7f\u7528\u5b83\u3002<\/p>\n

    Grub \u7684\u5de5\u4f5c\u6709\u4e24\u4e2a\uff1a\u9996\u5148\uff0c\u5b83\u7528\u4e00\u4e2a\u83dc\u5355\u5c55\u793a\u8ba1\u7b97\u673a\u4e0a\u6240\u6709\u5df2\u7ecf\u5b89\u88c5\u7684\u64cd\u4f5c\u7cfb\u7edf\u4f9b\u4f60\u9009\u62e9\uff1b\u5176\u6b21\uff0c\u5f53\u4f60\u4ece\u542f\u52a8\u83dc\u5355\u4e2d\u9009\u62e9\u4e86\u4e00\u4e2a Linux \u64cd\u4f5c\u7cfb\u7edf\u540e\uff0c Grub \u4fbf\u52a0\u8f7d\u5bf9\u5e94\u7248\u672cLinux \u7684\u5185\u6838\uff0c\u4f17\u6240\u5468\u77e5\uff0c\u4f7f\u7528 Linux \u5c31\u79bb\u4e0d\u5f00 bootloader \uff0c\u7136\u800c\u5b83\u5374\u662f Linux \u53d1\u884c\u7248\u5185\u90e8\u5f88\u5c11\u6709\u4eba\u5145\u5206\u4e86\u89e3\u7684\u90e8\u5206\u3002<\/p>\n

      1\u3001Grub 2 \u6700\u91cd\u8981\u7684\u90e8\u5206\u662f\u4e00\u5806\u6587\u672c\u6587\u4ef6\u548c\u4e24\u4e2a\u811a\u672c\u6587\u4ef6\uff0c\u9996\u5148\u9700\u8981\u4e86\u89e3\u7684\u662f<\/ol>\n

      \/etc\/default\/grub<\/strong><\/p>\n

        ,\u8fd9\u662f\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u5728\u91cc\u9762\u8bbe\u7f6e\u901a\u7528\u914d\u7f6e\u53d8\u91cf\u548c Grub 2 \u83dc\u5355\uff08\u89c1\u4e0b\u65b9 \u201c\u5e38\u89c1\u7528\u6237\u8bbe\u7f6e\u201d \uff09\u7684\u5176\u5b83\u7279\u6027\u3002<\/ol>\n
          2\u3001Grub 2 \u53e6\u4e00\u4e2a\u91cd\u8981\u7684\u90e8\u5206\u662f<\/ol>\n

          \/etc\/grub.d<\/strong><\/p>\n

            \u6587\u4ef6\u5939\uff0c\u5b9a\u4e49\u6bcf\u4e2a\u83dc\u5355\u9879\u7684\u6240\u6709\u811a\u672c\u90fd\u653e\u7f6e\u5728\u8fd9\u91cc\uff0c\u8fd9\u4e9b\u811a\u672c\u7684\u540d\u79f0\u5fc5\u987b\u6709\u4e24\u4f4d\u7684\u6570\u5b57\u524d\u7f00\uff0c\u5176\u76ee\u7684\u662f\uff1a\u5728\u6784\u5efa Grub 2 \u83dc\u5355\u65f6\u5b9a\u4e49\u811a\u672c\u7684\u6267\u884c\u987a\u5e8f\u4ee5\u53ca\u76f8\u5e94\u83dc\u5355\u9879\u7684\u987a\u5e8f\u3002\u4e3e\u4e2a\u6817\u5b50\uff1a\u6587\u4ef6 00_header \u9996\u5148\u88ab\u8bfb\u53d6\uff0c\u8d1f\u8d23\u89e3\u6790<\/ol>\n

            \/etc\/default\/grub<\/strong><\/p>\n

              \u914d\u7f6e\u6587\u4ef6,\u7136\u540e\u662f Linux \u5185\u6838\u7684\u83dc\u5355\u9879\uff0c\u4f4d\u4e8e 10_linux \u6587\u4ef6\u4e2d,\u8fd9\u4e2a\u811a\u672c\u5728\u9ed8\u8ba4\u7684<\/ol>\n

              \/boot<\/strong><\/p>\n

                \u5206\u533a\u4e3a\u6bcf\u4e2a\u5185\u6838\u521b\u5efa\u4e00\u4e2a\u6b63\u89c4\u83dc\u5355\u9879\u548c\u4e00\u4e2a\u6062\u590d\u83dc\u5355\u9879\u3002<\/ol>\n
                  3\u3001\u7d27\u63a5\u7740\u7684\u662f\u88ab\u7b2c\u4e09\u65b9\u5e94\u7528\u6240\u8c03\u7528\u7684\u811a\u672c\uff0c\u5982 30_os-prober \u548c 40_custom \uff0c os-prober \u811a\u672c\u4e3a\u5185\u6838\u548c\u5176\u5b83\u5206\u533a\u91cc\u7684\u64cd\u4f5c\u7cfb\u7edf\u521b\u5efa\u83dc\u5355\u9879\uff0c\u5b83\u80fd\u8bc6\u522b\u5b89\u88c5\u7684<\/ol>\n

                  Linux\u3001 Windows\u3001 BSD<\/strong><\/p>\n

                    \u4ee5\u53ca<\/ol>\n

                    Mac OS X<\/strong><\/p>\n

                      ,\u5f53\u7136\u5982\u679c\u4f60\u7684\u786c\u76d8\u5e03\u5c40\u6bd4\u8f83\u72ec\u7279\uff0c\u4f7f\u5f97 os-prober \u65e0\u6cd5\u627e\u5230\u5df2\u7ecf\u5b89\u88c5\u7684\u53d1\u884c\u7248\uff0c\u4f60\u53ef\u4ee5\u5728 40_custom \u6587\u4ef6\uff08\u89c1\u4e0b\u65b9 \u201c\u6dfb\u52a0\u81ea\u5b9a\u4e49\u83dc\u5355\u9879\u201d\uff09\u4e2d\u6dfb\u52a0\u83dc\u5355\u9879\u3002<\/ol>\n
                        4\u3001Grub 2 \u4e0d\u9700\u8981\u4f60\u624b\u52a8\u7ef4\u62a4\u4f60\u7684\u542f\u52a8\u9009\u9879\u7684\u914d\u7f6e\u6587\u4ef6\uff1a\u53d6\u800c\u4ee3\u4e4b\u7684\u662f\u4f7f\u7528 grub2-mkconfig \u547d\u4ee4\u4ea7\u751f<\/ol>\n

                        \/boot\/grub\/grub.cfg <\/strong><\/p>\n

                          \u6587\u4ef6\u3002\u8fd9\u4e2a\u529f\u80fd\u4f1a\u89e3\u6790<\/ol>\n

                          \/etc\/grub.d<\/strong><\/p>\n

                            \u76ee\u5f55\u4e2d\u7684\u811a\u672c\u4ee5\u53ca<\/ol>\n

                            \/etc\/default\/grub<\/strong><\/p>\n

                              \u8bbe\u7f6e\u6587\u4ef6\u6765\u5b9a\u4e49\u4f60\u7684\u8bbe\u7f6e\u60c5\u51b5\u3002<\/ol>\n
                              \u56fe\u5f62\u5316\u7684\u5f15\u5bfc\u4fee\u590d<\/strong><\/div>\n

                              \u591a\u4e8f\u4e86 Boot Repair\u7684\u5e94\u7528\uff0c\u6211\u4eec\u53ea\u9700\u8981\u70b9\u51fb\u6309\u94ae\uff0cGrub 2 \u5c31\u80fd\u5e2e\u6211\u4eec\u8f7b\u6613\u89e3\u51b3\u5f88\u591a\u95ee\u9898\uff0c\u8fd9\u4e2a\u6f02\u4eae\u800c\u5c0f\u5de7\u7684\u5e94\u7528\u6709\u4e00\u4e2a\u6bd4\u8f83\u76f4\u89c2\u7684\u7528\u6237\u754c\u9762\uff0c\u53ef\u4ee5\u626b\u63cf\u5e76\u8bc6\u522b\u591a\u79cd\u786c\u76d8\u5e03\u5c40\u548c\u5206\u533a\u65b9\u6848\uff0c\u8fd8\u80fd\u53d1\u73b0\u5e76\u6b63\u786e\u8bc6\u522b\u5b89\u88c5\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u8fd9\u4e2a\u5e94\u7528\u65e2\u53ef\u4ee5\u5904\u7406\u4f20\u7edf\u8ba1\u7b97\u673a\u91cc\u7684\u4e3b\u5f15\u5bfc\u8bb0\u5f55Master Boot Record (MBR)<\/strong>\uff0c\u4e5f\u53ef\u4ee5\u5904\u7406\u65b0\u578b UEFI \u8ba1\u7b97\u673a\u4e2d\u7684GUID \u5206\u533a\u8868GUID Partition Table\uff08GPT\uff09<\/strong>\u3002
                              \nBoot Repair \u6700\u7b80\u5355\u7684\u4f7f\u7528\u65b9\u5f0f\u662f\u5b89\u88c5\u5230 Live Ubuntu \u4f1a\u8bdd\u4e2d,\u5728\u4e00\u4e2a bootloader \u635f\u574f\u7684\u673a\u5668\u4e0a\u542f\u52a8 Ubuntu Live \u53d1\u884c\u7248\uff0c\u5148\u901a\u8fc7\u6dfb\u52a0\u5b83\u7684 PPA \u7248\u672c\u5e93\u6765\u5b89\u88c5 Boot Repair \uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n

                              sudo add-apt-repository ppa:yannubuntu\/Boot Repair\r\n<\/pre>\n

                              \u7136\u540e\u5237\u65b0\u7248\u672c\u5e93\u5217\u8868\uff1a<\/p>\n

                              sudo apt-get update\r\n<\/pre>\n

                              \u5b89\u88c5\u5e94\u7528\uff0c\u5982\u4e0b\uff1a<\/p>\n

                              sudo apt-get install -y Boot Repair\r\n<\/pre>\n

                              \u5b89\u88c5\u5b8c\u6bd5\u540e\u5c31\u542f\u52a8\u5e94\u7528,\u5728\u663e\u793a\u5b83\u7684\u754c\u9762\uff08\u7531\u4e00\u5bf9\u6309\u952e\u7ec4\u6210\uff09\u4e4b\u524d\u5b83\u5c06\u4f1a\u626b\u63cf\u4f60\u7684\u786c\u76d8\uff0c\u63a5\u4e0b\u6765\u7528\u6237\u53ef\u4ee5\u6839\u636e\u5de5\u5177\u7684\u6307\u793a\uff0c\u53ea\u9700\u6309\u4e0b Recommended Repair\u63a8\u8350\u7684\u4fee\u590d\u6309\u94ae\uff0c\u5373\u53ef\u4fee\u590d\u5927\u90e8\u5206\u574f\u6389\u7684 bootloader \uff0c\u4fee\u590d bootloader \u4e4b\u540e\uff0c\u8fd9\u4e2a\u5de5\u5177\u4f1a\u8f93\u51fa\u4e00\u4e2a\u77ed\u5c0f\u7684 URL \uff08\u5efa\u8bae\u628a\u5b83\u8bb0\u5f55\u4e0b\u6765\uff09\uff0c\u8fd9\u4e2a URL \u5305\u542b\u4e86\u786c\u76d8\u8be6\u5c3d\u7684\u4fe1\u606f\uff1a\u5206\u533a\u4fe1\u606f\u4ee5\u53ca\u91cd\u8981\u7684 Grub 2 \u6587\u4ef6\uff08\u5982\/etc\/default\/grub \u548c \/boot\/grub\/grub.cfg \uff09\u7684\u5185\u5bb9\uff0c\u5982\u679c\u5de5\u5177\u4e0d\u80fd\u89e3\u51b3 bootloader \u7684\u95ee\u9898\uff0c\u53ef\u4ee5\u628a\u4f60\u8fd9\u4e2a URL \u5171\u4eab\u5728\u4f60\u7684\u53d1\u884c\u7248\u7684\u8bba\u575b\u4e0a\uff0c\u8ba9\u5176\u4ed6\u4eba\u53ef\u4ee5\u5206\u6790\u4f60\u7684\u786c\u76d8\u5e03\u5c40\u4ee5\u4fbf\u7ed9\u4f60\u5efa\u8bae\u3002<\/p>\n

                              Bootloader \u6025\u6551<\/strong><\/div>\n

                              Grub 2 \u5f15\u5bfc\u95ee\u9898\u4f1a\u8ba9\u7cfb\u7edf\u5904\u4e8e\u51e0\u79cd\u4e0d\u540c\u72b6\u6001\uff0c\u5c4f\u5e55\uff08\u672c\u8be5\u663e\u793a bootloader \u83dc\u5355\u7684\u5730\u65b9\uff09\u6240\u5c55\u793a\u7684\u6587\u672c\u4f1a\u6307\u793a\u51fa\u7cfb\u7edf\u7684\u5f53\u524d\u72b6\u6001\uff1a<\/p>\n

                                \n
                              • \u5982\u679c\u7cfb\u7edf\u4e2d\u6b62\u4e8e grub> \u63d0\u793a\u7b26\uff0c\u8868\u660e Grub 2 \u6a21\u5757\u5df2\u7ecf\u88ab\u52a0\u8f7d\uff0c\u4f46\u662f\u627e\u4e0d\u5230 grub.cfg \u6587\u4ef6\u3002<\/li>\n
                              • \u5f53\u524d\u662f\u5b8c\u5168\u7248\u7684 Grub 2 \u547d\u4ee4\u884c shell\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u89e3\u51b3\u6b64\u95ee\u9898\u3002\u5982\u679c\u4f60\u770b\u5230\u7684\u662f grub rescue> \u63d0\u793a\u7b26\uff0c\u8868\u660e bootloader \u4e0d\u80fd\u627e\u5230 Grub 2 \u6a21\u5757\u6216\u8005\u627e\u4e0d\u5230\u4efb\u4f55\u5f15\u5bfc\u6587\u4ef6boot files\u3002<\/li>\n
                              • \u5982\u679c\u4f60\u7684\u5c4f\u5e55\u53ea\u663e\u793a \u2018GRUB\u2019 \u4e00\u8bcd\uff0c\u8868\u660e bootloader \u627e\u4e0d\u5230\u901a\u5e38\u4f4d\u4e8e\u4e3b\u5f15\u5bfc\u8bb0\u5f55Master Boot Record\u91cc\u7684\u6700\u57fa\u672c\u7684\u4fe1\u606f\u3002<\/li>\n<\/ul>\n

                                \u4f60\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 live CD \u6216\u8005\u5728 Grub 2 shell \u4e2d\u4fee\u6b63\u6b64\u7c7b\u9519\u8bef,\u5982\u679c\u4f60\u591f\u5e78\u8fd0\uff0c bootloader \u51fa\u73b0\u4e86 grub> \u63d0\u793a\u7b26\uff0c\u4f60\u5c31\u80fd\u83b7\u5f97 Grub 2 shell \u7684\u652f\u914d\u6743\uff0c\u6765\u5e2e\u52a9\u4f60\u6392\u9519,\u63a5\u4e0b\u6765\u51e0\u4e2a\u547d\u4ee4\u5de5\u4f5c\u5728 grub> \u548c grub rescue> \u63d0\u793a\u7b26\u4e0b, set pager=1 \u547d\u4ee4\u8bbe\u7f6e\u663e\u793a\u5206\u9875pager\uff0c\u9632\u6b62\u6587\u672c\u5728\u5c4f\u5e55\u4e0a\u4e00\u6eda\u800c\u8fc7,\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528 ls \u547d\u4ee4\u5217\u51fa Grub \u8bc6\u522b\u51fa\u7684\u6240\u6709\u5206\u533a\uff0c\u5982\u4e0b\uff1a<\/p>\n

                                grub> ls\r\n(hd0) (hd0,msdos5) (hd0,msdos6) (hd1,msdos1)\r\n<\/pre>\n

                                \u5982\u4f60\u6240\u89c1\uff0c\u8fd9\u4e2a\u547d\u4ee4\u5217\u51fa\u5206\u533a\u7684\u540c\u65f6\u4e00\u5e76\u5217\u51fa\u4e86\u5206\u533a\u8868\u65b9\u6848\uff08\u5373 msdos\uff09\u3002
                                \n\u4f60\u8fd8\u53ef\u4ee5\u5728\u6bcf\u4e2a\u5206\u533a\u4e0a\u9762\u4f7f\u7528 ls \u6765\u67e5\u627e\u4f60\u7684\u6839\u6587\u4ef6\u7cfb\u7edf\uff1a<\/p>\n

                                grub> ls (hd0,5)\/\r\nlost+found\/ var\/ etc\/ media\/ bin\/ initrd.gz\r\nboot\/ dev\/ home\/ selinux\/ srv\/ tmp\/ vmlinuz\r\n<\/pre>\n

                                \u4f60\u53ef\u4ee5\u4e0d\u5199\u4e0a\u5206\u533a\u540d\u7684 msdos \u90e8\u5206,\u540c\u6837\uff0c\u5982\u679c\u4f60\u5fd8\u8bb0\u4e86\u5c3e\u90e8\u7684\u659c\u6760trailing slash\u53ea\u8f93\u5165 ls (hd0,5) \uff0c\u90a3\u4f60\u5c06\u83b7\u5f97\u5206\u533a\u7684\u4fe1\u606f\uff0c\u6bd4\u5982\u6587\u4ef6\u7cfb\u7edf\u7c7b\u578b\u3001\u603b\u4f53\u5927\u5c0f\u548c\u6700\u540e\u4fee\u6539\u65f6\u95f4,\u5982\u679c\u4f60\u6709\u591a\u4e2a\u5206\u533a\uff0c\u53ef\u4ee5\u4f7f\u7528 cat \u8bfb\u53d6 \/etc\/issue <\/strong>\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\uff0c\u6765\u786e\u5b9a\u53d1\u884c\u7248\uff0c\u683c\u5f0f\u5982 :<\/p>\n

                                cat (hd0,5)\/etc\/issue<\/pre>\n

                                \u5047\u8bbe\u4f60\u5728 (hd0,5) \u4e2d\u627e\u5230\u6839\u6587\u4ef6\u7cfb\u7edf\uff0c\u8bf7\u786e\u4fdd\u5b83\u5305\u542b \/boot\/grub<\/strong> \u76ee\u5f55\uff0c\u4ee5\u53ca\u4f60\u60f3\u5f15\u5bfc\u8fdb\u5165\u7684\u5185\u6838\u955c\u50cf\uff0c\u5982 vmlinuz-3.13.0-24-generic ,\u6b64\u65f6\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

                                grub> set root=(hd0,5)\r\ngrub> linux \/boot\/vmlinuz-3.13.0-24-generic root=\/dev\/sda5\r\ngrub> initrd \/boot\/initrd.img-3.13.0-24-generic\r\n<\/pre>\n

                                \u7b2c\u4e00\u4e2a\u547d\u4ee4\u628a Grub \u6307\u5411\u6211\u4eec\u60f3\u5f15\u5bfc\u8fdb\u5165\u7684\u53d1\u884c\u7248\u6240\u5728\u7684\u5206\u533a,\u63a5\u7740\u7b2c\u4e8c\u4e2a\u547d\u4ee4\u544a\u77e5 Grub \u5185\u6838\u955c\u50cf\u5728\u5206\u533a\u4e2d\u7684\u4f4d\u7f6e\uff0c\u4ee5\u53ca\u6839\u6587\u4ef6\u7cfb\u7edf\u7684\u4f4d\u7f6e,\u6700\u540e\u4e00\u884c\u8bbe\u7f6e\u865a\u62df\u6587\u4ef6\u7cfb\u7edfinitial ramdisk\u6587\u4ef6\u7684\u4f4d\u7f6e,\u4f60\u53ef\u4ee5\u4f7f\u7528 tab \u8865\u5168\u529f\u80fd\u8865\u5168\u5185\u6838\u540d\u5b57\u548c\u865a\u62df\u6587\u4ef6\u7cfb\u7edfinitrd: initial ramdisk\u7684\u540d\u5b57\uff0c\u8282\u7701\u65f6\u95f4\u548c\u7cbe\u529b,\u8f93\u5165\u5b8c\u6bd5\uff0c\u5728\u4e0b\u4e00\u4e2a grub> \u63d0\u793a\u7b26\u540e\u8f93\u5165 boot \uff0c Grub \u5c06\u4f1a\u5f15\u5bfc\u8fdb\u5165\u6307\u5b9a\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002
                                \n\u5982\u679c\u4f60\u5728 grub rescue> \u63d0\u793a\u7b26\u4e0b\uff0c\u60c5\u51b5\u4f1a\u6709\u4e9b\u8bb8\u4e0d\u540c\u3002\u56e0\u4e3a bootloader \u672a\u80fd\u591f\u627e\u5230\u5e76\u52a0\u8f7d\u4efb\u4f55\u5fc5\u9700\u7684\u6a21\u5757\uff0c\u4f60\u9700\u8981\u624b\u52a8\u6dfb\u52a0\u8fd9\u4e9b\u6a21\u5757\uff1a<\/p>\n

                                grub rescue> set root=(hd0,5)\r\ngrub rescue> insmod (hd0,5)\/boot\/grub\/normal.mod\r\ngrub rescue> normal\r\ngrub> insmod linux\r\n<\/pre>\n

                                \u5982\u4e0a\u6240\u793a\uff0c\u8ddf\u4e4b\u524d\u4e00\u6837\uff0c\u4f7f\u7528 ls \u547d\u4ee4\u5217\u51fa\u6240\u6709\u5206\u533a\u4e4b\u540e\uff0c\u4f7f\u7528 set \u547d\u4ee4\u6807\u8bb0\u8d77\u6765,\u7136\u540e\u6dfb\u52a0 normal \u6a21\u5757\uff0c\u6b64\u6a21\u5757\u6fc0\u6d3b\u65f6\u5c06\u4f1a\u6062\u590d\u5230\u6807\u51c6 grub> \u6a21\u5f0f,\u5982\u679c linux \u6a21\u5757\u6ca1\u52a0\u8f7d\uff0c\u63a5\u4e0b\u6765\u7684\u547d\u4ee4\u4f1a\u8fdb\u884c\u6dfb\u52a0,\u5982\u679c\u8fd9\u4e2a\u6a21\u5757\u5df2\u7ecf\u52a0\u8f7d\uff0c\u4f60\u53ef\u4ee5\u8ddf\u4e4b\u524d\u4e00\u6837\uff0c\u628a\u5f15\u5bfc\u52a0\u8f7d\u7a0b\u5e8f\u6307\u5411\u5185\u6838\u955c\u50cf\u548c\u865a\u62df\u6587\u4ef6\u7cfb\u7edfinitrd\u6587\u4ef6\uff0c\u7136\u540e\u4f7f\u7528 boot \u542f\u52a8\u53d1\u884c\u7248,prefect!
                                \n\u4e00\u65e6\u6210\u529f\u542f\u52a8\u53d1\u884c\u7248\uff0c\u522b\u5fd8\u4e86\u4e3a Grub \u91cd\u65b0\u4ea7\u751f\u65b0\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f7f\u7528\u547d\u4ee4\uff1a<\/p>\n

                                grub-mkconfig -o \/boot\/grub\/grub.cfg\r\n<\/pre>\n

                                \u4f60\u8fd8\u9700\u8981\u5f80 MBR \u91cc\u5b89\u88c5\u4e00\u4efd bootloader \u7684\u62f7\u8d1d\uff0c\u4f7f\u7528\u547d\u4ee4\uff1a<\/p>\n

                                sudo grub2-install \/dev\/sda\r\n<\/pre>\n

                                \u5982\u679c\u60f3\u8981\u7981\u7528 \/etc\/grub.d <\/strong>\u76ee\u5f55\u4e0b\u7684\u811a\u672c\uff0c\u4f60\u53ea\u9700\u79fb\u9664\u5176\u53ef\u6267\u884c\u4f4d\uff0c\u6bd4\u5982\u4f7f\u7528 chmod -x \/etc\/grub.d\/20_memtest86+ <\/strong>\u5c31\u80fd\u5c06 \u2018Memory Test\u2019 \u9009\u9879\u4ece\u83dc\u5355\u4e2d\u79fb\u9664\u3002<\/p>\n

                                Grub 2 \u548c UEFI<\/strong><\/div>\n

                                \u5728\u652f\u6301 UEFI \u7684\u673a\u5668\uff08\u6700\u8fd1\u51e0\u5e74\u4e0a\u5e02\u7684\u673a\u5668\u5927\u90e8\u5206\u90fd\u662f\uff09\u8c03\u8bd5\u574f\u6389\u7684 Grub 2 \u589e\u52a0\u4e86\u96be\u5ea6,\u6062\u590d\u5b89\u88c5\u5728 UEFI \u673a\u5668\u4e0a\u7684 Grub 2 \u7684\u548c\u5b89\u88c5\u5728\u975e UEFI \u673a\u5668\u4e0a\u7684\u5e76\u6ca1\u591a\u5927\u533a\u522b\uff0c\u53ea\u662f\u65b0\u7684\u56fa\u4ef6\u5904\u7406\u65b9\u5f0f\u4e0d\u4e00\u6837\uff0c\u4ece\u800c\u5bfc\u81f4\u4e86\u5f88\u591a\u79cd\u6062\u590d\u7ed3\u679c,\u5bf9\u4e8e\u57fa\u4e8e UEFI \u7684\u7cfb\u7edf\uff0c\u4e0d\u8981\u5728 MBR \u4e0a\u5b89\u88c5\u4efb\u4f55\u4e1c\u897f,\u76f8\u53cd\uff0c\u4f60\u8981\u5728EFI \u7cfb\u7edf\u5206\u533aEFI System Partition\uff08 ESP \uff09\u91cc\u5b89\u88c5 Linux EFI bootloader\uff0c\u5e76\u4e14\u501f\u52a9\u5de5\u5177\u628a\u5b83\u8bbe\u7f6e\u4e3a EFI \u7684\u9ed8\u8ba4\u542f\u52a8\u7a0b\u5e8f\uff0c\u8fd9\u4e2a\u5de5\u5177\u5bf9\u4e8e Linux \u7528\u6237\u662f efibootmgr<\/strong> \uff0c\u5bf9\u4e8e window \u7528\u6237\u5219\u662f bcdedit <\/strong>\u3002
                                \n\u7167\u76ee\u524d\u60c5\u51b5\u770b\uff0c\u5728\u5b89\u88c5\u4efb\u4f55\u4e0e Windows 8 \u517c\u5bb9\u7684\u4e3b\u6d41\u684c\u9762 Linux \u53d1\u884c\u7248\u524d\uff0c\u5e94\u8be5\u6b63\u786e\u5b89\u88c5\u597d Grub 2\uff0c\u5982\u679c bootloader \u635f\u574f\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 live \u53d1\u884c\u7248\u4fee\u590d\u673a\u5668,\u5728\u542f\u52a8 live \u4ecb\u8d28\u4e4b\u65f6\uff0c\u8bf7\u786e\u4fdd\u662f\u4ee5 UEFI \u6a21\u5f0f\u542f\u52a8,\u8ba1\u7b97\u673a\u6bcf\u4e2a\u53ef\u79fb\u52a8\u9a71\u52a8\u5668\u7684\u542f\u52a8\u83dc\u5355\u5c06\u4f1a\u6709\u4e24\u4e2a\uff1a \u4e00\u4e2a\u666e\u901a\u7684\u548c\u4e00\u4e2a\u4ee5 EFI \u6807\u8bb0\u7684,\u4f7f\u7528\u540e\u8005\u4f1a\u7528\u5230 \/sys\/firmware\/efi\/<\/strong> \u6587\u4ef6\u4e2d\u7684 EFI \u53d8\u91cf\u3002
                                \n\u5728 live \u73af\u5883\u4e2d\uff0c\u6302\u8f7d\u6559\u7a0b\u524d\u9762\u6240\u63d0\u7684\u5b89\u88c5\u6302\u6389\u7cfb\u7edf\u7684\u6839\u6587\u4ef6\u7cfb\u7edf,\u9664\u6b64\u4e4b\u5916\uff0c\u8fd8\u9700\u8981\u6302\u8f7d ESP \u5206\u533a,\u5047\u8bbe\u5206\u533a\u662f\/dev\/sda1 <\/strong>\uff0c\u4f60\u53ef\u4ee5\u5982\u4e0b\u6240\u793a\u6302\u8f7d\uff1a<\/p>\n

                                sudo mount \/dev\/sda1 \/mnt\/boot\/efi\r\n<\/pre>\n

                                \u63a5\u7740\u5728 chroot \u5230\u5b89\u88c5\u5b8c\u6bd5\u7684\u53d1\u884c\u7248\u524d\u4e4b\u524d\uff0c\u4f7f\u7528 modprobe efivars \u52a0\u8f7d efivars \u6a21\u5757\u3002
                                \nFedora \u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u91cd\u65b0\u5b89\u88c5 bootloader<\/strong><\/p>\n

                                grub2-mkconfig -o \/boot\/grub2\/grub.cfg\r\nyum reinstall grub2-efi shim\r\n<\/pre>\n

                                grub2-mkconfig -o \/boot\/grub2\/grub.cfg<\/strong>
                                \n\u547d\u4ee4\u662f\u6765\u4ea7\u751f\u65b0\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n

                                Ubuntu \u7528\u6237\u5219\u6539\u7528\u4ee5\u4e0b\u547d\u4ee4<\/strong><\/p>\n

                                apt-get install --reinstall grub-efi-amd64<\/pre>\n

                                \u4e00\u65e6 bootloader \u6b63\u786e\u5c31\u4f4d\uff0c\u9000\u51fa chroot \uff0c\u5378\u8f7d\u6240\u6709\u5206\u533a\uff0c\u91cd\u542f\u5230 Grub 2 \u83dc\u5355\u3002<\/p>\n

                                Grub \u4e22\u5931<\/strong><\/div>\n

                                Grub 2 \u6700\u597d\u7684\u7279\u6027\u662f\u53ef\u4ee5\u968f\u65f6\u91cd\u65b0\u5b89\u88c5\uff0c\u56e0\u6b64\uff0c\u5f53\u5176\u5b83\u50cf Windows \u4e4b\u7c7b\u7684\u7cfb\u7edf\u7528\u5b83\u4eec\u81ea\u5df1\u7684 bootloader \u66ff\u6362\u540e\uff0c\u5bfc\u81f4 Grub 2 \u4e22\u5931\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 live \u53d1\u884c\u7248\uff0c\u5be5\u5be5\u6570\u6b65\u5373\u53ef\u91cd\u88c5 Grub ,\u5047\u8bbe\u4f60\u5728 \/dev\/sda5<\/strong> \u5b89\u88c5\u4e86\u4e00\u4e2a\u53d1\u884c\u7248\uff0c\u82e5\u8981\u91cd\u88c5 Grub \uff0c\u4f60\u53ea\u9700\u9996\u5148\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4e3a\u53d1\u884c\u7248\u521b\u5efa\u4e00\u4e2a\u6302\u8f7d\u76ee\u5f55\uff1a<\/p>\n

                                sudo mkdir -p \/mnt\/distro\r\n<\/pre>\n

                                \u7136\u540e\u6302\u8f7d\u5206\u533a\uff0c\u5982\u4e0b\uff1a<\/p>\n

                                mount \/dev\/sda5 \/mnt\/distro\r\n<\/pre>\n

                                \u63a5\u7740\u5c31\u80fd\u91cd\u88c5 Grub \u4e86\uff0c\u5982\u4e0b\uff1a<\/p>\n

                                grub2-install --root-directory=\/mnt\/distro \/dev\/sda\r\n<\/pre>\n

                                \u8fd9\u4e2a\u547d\u4ee4\u4f1a\u6539\u5199 \/dev\/sda <\/strong>\u8bbe\u5907\u4e0a\u7684 MBR \u4fe1\u606f\uff0c\u6307\u5411\u5f53\u524d Linux \u7cfb\u7edf\uff0c\u5e76\u91cd\u5199\u4e00\u4e9b Grub 2 \u6587\u4ef6\uff0c\u5982 grubenv \u548cdevice.map ,\u53e6\u4e00\u4e2a\u95ee\u9898\u5e38\u89c1\u4e8e\u88c5\u6709\u591a\u4e2a\u53d1\u884c\u7248\u7684\u8ba1\u7b97\u673a\u4e0a:\u5f53\u4f60\u5b89\u88c5\u4e86\u65b0\u7684 Linux \u53d1\u884c\u7248\uff0c\u5b83\u7684 bootloader \u5e94\u5f53\u8981\u80fd\u627e\u5230\u6240\u6709\u5df2\u7ecf\u5b89\u88c5\u7684\u53d1\u884c\u7248,\u4e00\u65e6\u4e0d\u884c\uff0c\u53ea\u8981\u5f15\u5bfc\u8fdb\u5165\u65b0\u5b89\u88c5\u7684\u53d1\u884c\u7248\uff0c\u5e76\u8fd0\u884c<\/p>\n

                                grub2-mkconfig\r\n<\/pre>\n

                                \u5728\u8fd0\u884c\u8fd9\u4e2a\u547d\u4ee4\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u542f\u52a8\u83dc\u5355\u4e2d\u7f3a\u5931\u7684\u53d1\u884c\u7248\u7684 root \u5206\u533a\u5df2\u7ecf\u6302\u8f7d,\u5982\u679c\u4f60\u60f3\u6dfb\u52a0\u7684\u53d1\u884c\u7248\u6709\u5355\u72ec\u7684 \/root<\/strong>\u548c \/home<\/strong> \u5206\u533a\uff0c\u5728\u8fd0\u884c grub2-mkconfig \u4e4b\u524d\uff0c\u53ea\u9700\u6302\u8f7d\u5305\u542b \/root <\/strong>\u7684\u5206\u533a,\u867d\u7136 Grub 2 \u80fd\u591f\u627e\u5230\u5927\u90e8\u5206\u53d1\u884c\u7248\uff0c\u4f46\u662f\u5728 Ubuntu \u4e2d\u5c1d\u8bd5\u6dfb\u52a0\u5b89\u88c5\u7684 Fedora \u7cfb\u7edf\u9700\u8981\u989d\u5916\u7684\u4e00\u4e2a\u6b65\u9aa4:\u5982\u679c\u4f60\u4ee5\u9ed8\u8ba4\u8bbe\u7f6e\u5b89\u88c5\u4e86 Fedora \uff0c\u5219\u53d1\u884c\u7248\u7684\u5b89\u88c5\u5668\u5df2\u7ecf\u521b\u5efa\u4e86 LVM \u5206\u533a,\u6b64\u65f6\u4f60\u9700\u8981\u4f7f\u7528\u53d1\u884c\u7248\u7684\u5305\u7ba1\u7406\u7cfb\u7edf\u5b89\u88c5 lvm2 \u9a71\u52a8\uff0c\u5982\u4e0b<\/p>\n

                                sudo apt-get install lvm2\r\n<\/pre>\n

                                \u6267\u884c\u4e4b\u540e\u624d\u80fd\u4f7f\u5f97 Grub 2 \u7684 os-prober \u811a\u672c\u80fd\u591f\u627e\u5230\u5e76\u5c06 Fedora \u6dfb\u52a0\u8fdb\u542f\u52a8\u83dc\u5355\u3002<\/p>\n

                                \u5e38\u89c1\u7528\u6237\u8bbe\u7f6e<\/strong><\/div>\n

                                Grub 2 \u6709\u5f88\u591a\u53ef\u914d\u7f6e\u53d8\u91cf\uff0c \u8fd9\u91cc\u6709\u4e00\u4e9b \/etc\/default\/grub<\/strong> \u6587\u4ef6\u4e2d\u4f60\u6700\u53ef\u80fd\u4f1a\u4fee\u6539\u5230\u7684\u5e38\u89c1\u53d8\u91cf:<\/p>\n