{"id":4041,"date":"2014-01-09T10:44:57","date_gmt":"2014-01-09T02:44:57","guid":{"rendered":"https:\/\/www.icocean.com\/wp\/?p=4041"},"modified":"2014-01-09T10:44:57","modified_gmt":"2014-01-09T02:44:57","slug":"grub2%e7%9a%84%e9%85%8d%e7%bd%ae%e5%92%8c%e4%bf%ae%e5%a4%8d","status":"publish","type":"post","link":"https:\/\/www.icocean.com\/blog\/?p=4041","title":{"rendered":"Grub2\u7684\u914d\u7f6e\u548c\u4fee\u590d"},"content":{"rendered":"<p>    GNU GRUB \u548cGRUB\u662fGRand Unified Bootloader\u7684\u7f29\u5199\uff0c\u5b83\u662f\u4e00\u4e2a\u591a\u91cd\u64cd\u4f5c\u7cfb\u7edf\u542f\u52a8\u7ba1\u7406\u5668\u3002\u7528\u6765\u5f15\u5bfc\u4e0d\u540c\u7cfb\u7edf\uff0c\u5982windows\uff0clinux\u3002GRUB\u662f\u591a\u542f\u52a8\u89c4\u8303\u7684\u5b9e\u73b0\uff0c\u5b83\u5141\u8bb8\u7528\u6237\u53ef\u4ee5\u5728\u8ba1\u7b97\u673a\u5185\u540c\u65f6\u62e5\u6709\u591a\u4e2a\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5e76\u5728\u8ba1\u7b97\u673a\u542f\u52a8\u65f6\u9009\u62e9\u5e0c\u671b\u8fd0\u884c\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002GRUB\u53ef\u7528\u4e8e\u9009\u62e9\u64cd\u4f5c\u7cfb\u7edf\u5206\u533a\u4e0a\u7684\u4e0d\u540c\u5185\u6838\uff0c\u4e5f\u53ef\u7528\u4e8e\u5411\u8fd9\u4e9b\u5185\u6838\u4f20\u9012\u542f\u52a8\u53c2\u6570\u3002<\/p>\n<p>\u5b89\u88c5&#038;\u4fee\u590dGrub2<br \/>\n    \u5728\u4f7f\u7528\u5149\u76d8\u6216\u8005\u5176\u4ed6\u65b9\u5f0f\u5b89\u88c5Ubuntu\u65f6\u5019\u5df2\u7ecf\u81ea\u5e26\u4e86Grub2\uff0c\u4e0d\u9700\u8981\u989d\u5916\u5b89\u88c5\uff0c\u5982\u679cGrub2\u56e0\u914d\u7f6e\u9519\u8bef\u6216\u8005\u5176\u4ed6\u539f\u56e0\u800c\u65e0\u6cd5\u4f7f\u7528\uff0c\u4e5f\u53ef\u4e00\u4f7f\u7528livecd\u8fdb\u884c\u4fee\u590d\u3002<br \/>\n    \u7528Ubuntulive CD \u4fee\u590d Ubuntu 12.04 Grub \u5f15\u5bfc\u5177\u4f53\u4fee\u590d\u6b65\u9aa4\u5982\u4e0b\uff1a<!--more--><br \/>\n            1\u3001\u7528 Ubuntu 12.04 \u7684 Live CD \u5149\u76d8\u542f\u52a8\u7cfb\u7edf\uff0c\u542f\u52a8\u5149\u76d8\u540e\u4e0d\u8981\u9009\u5b89\u88c5\u800c\u9009\u8bd5\u7528\uff1b<br \/>\n            2\u3001\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165\u7ec8\u7aef\u547d\u4ee4\uff1a sudo fdisk -l \u6b64\u65f6\u53ef\u4ee5\u770b\u5230\u663e\u793a\u51fa\u6765\u7684\u6574\u4e2a\u786c\u76d8\u4e0a\u6240\u6709\u5206\u533a\u7684\u5217\u8868\uff0c\u8bf7\u8bb0\u5f55\u4e0b Ubuntu \u6839\u5206\u533a \/ \u548c\/boot\u5206\u533a\u5b89\u88c5\u7684\u4f4d\u7f6e\uff1b<br \/>\n            3\u3001\u5728\u7ec8\u7aef\u8f93\u5165\u547d\u4ee4\uff1a<br \/>\n            sudo -i  (\u53d6\u5f97root\u7279\u6743\uff09<br \/>\n            mount  \/dev\/sdaX  \/mnt \uff08X \u4e3a\u8bb0\u5f55\u4e0b\u7684 Ubuntu \u6839\u5206\u533a\uff09<br \/>\n            mount  \/dev\/sda*  \/mnt\/boot \uff08*\u4e3a Ubuntu \/boot\u5206\u533a\uff0c\/boot\u6ca1\u6709\u5355\u72ec\u5206\u533a\u5219\u4e0d\u8981\u6267\u884c\u8fd9\u4e2a\u547d\u4ee4\uff09<br \/>\n            grub- install  \u2013root-directory=\/mnt\/  \/dev\/sda  (\u6ce8\u610f\u6b64\u547d\u4ee4\u4e2d root \u524d\u9762\u662f\u4e24\u4e2a\u51cf\u53f7\u6a2a\u6760\uff09<br \/>\n            4.\u6267\u884c\u5b8c\u4ee5\u4e0a\u6b65\u9aa4\u548c\u547d\u4ee4\uff0c\u91cd\u65b0\u542f\u52a8\u7cfb\u7edf\uff0c\u8fd9\u65f6\u60a8\u4f1a\u770b\u5230\u719f\u6089\u7684Grub\u542f\u52a8\u83dc\u5355\u3002  <\/p>\n<p>\u4fee\u6539Grub2\u9ed8\u8ba4\u542f\u52a8<br \/>\n          \u5728\u672a\u4fee\u6539\u60c5\u51b5\u4e0b\uff0c\u6bcf\u6b21\u8fdb\u5165\u7cfb\u7edfGrub\u90fd\u9ed8\u8ba4\u4ece\u7b2c\u4e00\u9879\u8fdb\u5165\uff0c\u7136\u540e\u8fd9\u4e5f\u5bf9\u591a\u7cfb\u7edf\u7684\u7528\u6237\u5e76\u4e0d\u662f\u5f88\u4fbf\u5229\uff0c\u5176\u5b9e\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u5b9e\u73b0\u8bb0\u5fc6\u4e0a\u4e00\u6b21\u8fdb\u5165\u7684\u7cfb\u7edf\u3002<\/p>\n<p>    \u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\/etc\/default\/grub\u6587\u4ef6  \uff08\u8fd9\u4e2a\u6587\u4ef6\u91cc\u53c2\u6570\u8d1f\u8d23\u5b58\u6709\u5f00\u673a\u9ed8\u8ba4\u542f\u52a8\u9879\u3001\u5012\u8bb0\u65f6\u65f6\u95f4\u7b49\u7b49\u5185\u5bb9\uff09<\/p>\n<p>    1.\u5728\u7ec8\u7aef\u4e0b\u8f93\u5165<br \/>\n        sudo gedit \/etc\/default\/grub  <\/p>\n<p>    \u7136\u540e\u53ef\u4ee5\u770b\u5230<\/p>\n<p>    2.\u5728\u91cc\u9762\u627e\u5230\u5e76\u4fee\u6539\u6210\u5982\u4e0b<br \/>\n        GRUB_DEFAULT=&#8221;saved&#8221;\/\/\u4fee\u6539\u4e3asaved\u4e3a\u4e86\u8bb0\u5fc6\u4e0a\u4e00\u6b21\u8fdb\u5165\u7684\u7cfb\u7edf<br \/>\n        GRUB_SAVEDEFAULT=&#8221;true&#8221;\/\/\u8fd9\u884c\u4e00\u5b9a\u8981\u52a0\uff0c\u7f51\u4e0a\u53c8\u5f88\u591a\u4fdd\u5b58\u4e86saved\u4f46\u662f\u65e0\u6548\u56e0\u4e3a\u5c11\u4e86\u8fd9\u884c<br \/>\n        GRUB_HIDDEN_TIMEOUT=&#8221;0&#8243;<br \/>\n        GRUB_HIDDEN_TIMEOUT_QUIET=&#8221;true&#8221;<br \/>\n        GRUB_TIMEOUT=&#8221;3&#8243;<br \/>\n        GRUB_DISTRIBUTOR=&#8221;`lsb_release -i -s 2> \/dev\/null || echo Debian`&#8221;<br \/>\n        GRUB_CMDLINE_LINUX_DEFAULT=&#8221;quiet splash&#8221;<br \/>\n        GRUB_CMDLINE_LINUX=&#8221;&#8221;  <\/p>\n<p>    3.\u7136\u540e\u4fdd\u5b58\uff0c\u51fa\u6765\u8fd8\u8981\u66f4\u65b0\u4e00\u4e0b<br \/>\n        sudo update-grub<br \/>\n    4.\u91cd\u542f\u5c31\u53ef\u4ee5\u770b\u5230\u6548\u679c\u4e86<\/p>\n<p>Grub2\u914d\u7f6e\u8be6\u89e3<br \/>\n        : \/etc\/default\/grub<br \/>\n        # \u8bbe\u5b9a\u9ed8\u8ba4\u542f\u52a8\u9879\uff0c\u63a8\u8350\u4f7f\u7528\u6570\u5b57<br \/>\n        GRUB_DEFAULT=0<br \/>\n        # \u6ce8\u91ca\u6389\u4e0b\u9762\u8fd9\u884c\u5c06\u4f1a\u663e\u793a\u5f15\u5bfc\u83dc\u5355<br \/>\n        #GRUB_HIDDEN_TIMEOUT=0<br \/>\n        # \u9ed1\u5c4f\uff0c\u5e76\u4e14\u4e0d\u663e\u793aGRUB_HIDDEN_TIMEOUT\u8fc7\u7a0b\u4e2d\u7684\u5012\u8ba1\u65f6<br \/>\n        GRUB_HIDDEN_TIMEOUT_QUIET=true<br \/>\n        # \u8bbe\u5b9a\u8d85\u65f6\u65f6\u95f4\uff0c\u9ed8\u8ba4\u4e3a10\u79d2<br \/>\n        # \u8bbe\u5b9a\u4e3a-1\u53d6\u6d88\u5012\u8ba1\u65f6<br \/>\n        GRUB_TIMEOUT=10<br \/>\n        # \u83b7\u5f97\u53d1\u884c\u7248\u540d\u79f0\uff08\u6bd4\u5982Ubuntu, Debian\uff09<br \/>\n        GRUB_DISTRIBUTOR=`lsb_release -i -s 2> \/dev\/null || echo Debian`<br \/>\n        # \u5c06\u4f1a\u5bfc\u5165\u5230\u6bcf\u4e2a\u542f\u52a8\u9879\uff08\u5305\u62ecrecovery mode\u542f\u52a8\u9879)\u7684&#8217;linux&#8217;\u547d\u4ee4\u884c<br \/>\n        GRUB_CMDLINE_LINUX=&#8221;&#8221;<br \/>\n        # \u540c\u4e0a\uff0c\u4f46\u662f\u53ea\u4f1a\u6dfb\u52a0\u5230 normal mode \u7684\u542f\u52a8\u9879<br \/>\n        GRUB_CMDLINE_LINUX_DEFAULT=&#8221;quiet splash&#8221;<br \/>\n        # \u53d6\u6d88\u6ce8\u91ca\u4ee5\u5141\u8bb8\u56fe\u5f62\u7ec8\u7aef\uff08\u53ea\u9002\u5408grub-pc\uff09<br \/>\n        #GRUB_TERMINAL=console<br \/>\n        # \u5206\u8fa8\u7387\u8bbe\u5b9a\uff0c\u5426\u5219\u91c7\u7528\u9ed8\u8ba4\u503c<br \/>\n        #GRUB_GFXMODE=640&#215;480<br \/>\n        # \u53d6\u6d88\u6ce8\u91ca\u4ee5\u963b\u6b62GRUB\u5c06\u4f20\u9012\u53c2\u6570 &#8220;root=UUID=xxx&#8221; \u4f20\u9012\u7ed9 Linux<br \/>\n        #GRUB_DISABLE_LINUX_UUID=true<br \/>\n        # \u53d6\u6d88\u542f\u52a8\u83dc\u5355\u4e2d\u7684\u201cRecovery Mode\u201d\u9009\u9879<br \/>\n        #GRUB_DISABLE_LINUX_RECOVERY=&#8221;true&#8221;<br \/>\n        # \u5f53GRUB\u83dc\u5355\u51fa\u73b0\u65f6\u53d1\u51fa\u9e23\u97f3\u63d0\u9192<br \/>\n        #GRUB_INIT_TUNE=&#8221;480 440 1&#8243;<br \/>\n        \u914d\u7f6e\u8fdb\u9636<br \/>\n        \u83b7\u5f97\u5f53\u524dGRUB2\u6709\u6548\u7684\u542f\u52a8\u9879<br \/>\n        $ grep menuentry \/boot\/grub\/grub.cfg<br \/>\n        \u914d\u7f6e\u9ed8\u8ba4\u542f\u52a8\u9879<br \/>\n        GRUB_DEFAULT=x<br \/>\n        \u6ce8\u91ca\uff1ax\u4e3a\u6570\u5b57\uff0c\u4ee5\u6307\u5b9a\u542f\u52a8\u5217\u8868\u4e2d\u7b2cx\u9879\u4e3a\u542f\u52a8\u9879\uff0cx\u4ece0\u5f00\u59cb\u8ba1\u6570<br \/>\n        GRUB_DEFAULT=\u201dxxxx\u201d<br \/>\n        \u6ce8\u91ca\uff1a\u6307\u51fa\u5177\u4f53\u7684\u542f\u52a8\u9879\u540d\u79f0\uff0c\u4f8b\u5982GRUB_DEFAULT=\u201dUbuntu, Linux 2.6.31-9-generic\u201d<br \/>\n        GRUB_DEFAULT=saved<br \/>\n        \u6ce8\u91ca\uff1a\u8be5\u9879\u5c06\u4f7f\u7528grub-set-default\u548cgrub-reboot\u547d\u4ee4\u6765\u914d\u7f6e\u9ed8\u8ba4\u542f\u52a8\u9879<br \/>\n        \u4f8b\u5982\uff1a<br \/>\n        $ sudo grub-set-default 0<br \/>\n        \u4e0a\u9762\u8fd9\u6761\u8bed\u53e5\u5c06\u4f1a\u6301\u7eed\u6709\u6548\uff0c\u76f4\u5230\u4e0b\u4e00\u6b21\u4fee\u6539\uff1b\u4e0b\u9762\u7684\u547d\u4ee4\u5219\u53ea\u6709\u4e0b\u4e00\u6b21\u542f\u52a8\u7684\u65f6\u5019\u751f\u6548\uff1a<br \/>\n        $ sudo grub-reboot 0<br \/>\n        \u5c06\u4e0b\u6b21\u9009\u62e9\u7684\u542f\u52a8\u9879\u8bbe\u4e3a\u9ed8\u8ba4<br \/>\n        \u53ea\u9700\u8981\u5728\/etc\/default\/grub\u4e2d\u6dfb\u52a0\u8fd9\u884c<br \/>\n        GRUB_SAVEDEFAULT=true<br \/>\n        \u9690\u85cf\u5f15\u5bfc\u83dc\u5355<br \/>\n        GRUB_HIDDEN_TIMEOUT=X<br \/>\n        \u6ce8\u91ca\uff1a\u542f\u52a8\u8fc7\u7a0b\u4e2d\uff0c\u9ed1\u5c4fX\u79d2\u540e\u5f15\u5bfc\u9ed8\u8ba4\u7684\u542f\u52a8\u9879<br \/>\n        \u6ce8\u610f1\uff1a\u542f\u52a8\u8fc7\u7a0b\u4e2d\u6309SHIFT\u53ef\u4ee5\u663e\u793a\u83dc\u5355<br \/>\n        \u6ce8\u610f2\uff1a\u5982\u679c\u7b49\u53f7\u540e\u9762\u4e0d\u8ddf\u4efb\u4f55\u503c\uff0c\u4e5f\u5c06\u4f1a\u663e\u793a\u5f15\u5bfc\u83dc\u5355<br \/>\n        \u53d6\u6d88\u5012\u8ba1\u65f6<br \/>\n        GRUB_TIMEOUT=-1  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>GNU GRUB \u548cGRUB\u662fGRand Unified Bootloader\u7684\u7f29\u5199\uff0c\u5b83\u662f\u4e00\u4e2a\u591a\u91cd\u64cd\u4f5c\u7cfb\u7edf\u542f\u52a8 <a href='https:\/\/www.icocean.com\/blog\/?p=4041' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[3922],"class_list":["post-4041","post","type-post","status-publish","format-standard","hentry","category-linuxunix","tag-grub","category-16-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4041"}],"version-history":[{"count":1,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4041\/revisions"}],"predecessor-version":[{"id":4042,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4041\/revisions\/4042"}],"wp:attachment":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}