{"id":3413,"date":"2025-10-05T01:26:29","date_gmt":"2025-10-04T17:26:29","guid":{"rendered":"https:\/\/yowlab.idv.tw\/wordpress\/?p=3413"},"modified":"2025-10-05T01:26:29","modified_gmt":"2025-10-04T17:26:29","slug":"%e6%90%b6%e6%95%91%e4%b8%a6%e9%87%8d%e5%bb%ba%e7%a1%ac%e7%a2%9f%e7%9a%84-grub","status":"publish","type":"post","link":"https:\/\/yowlab.idv.tw\/wordpress\/?p=3413","title":{"rendered":"\u6436\u6551\u4e26\u91cd\u5efa\u786c\u789f\u7684 grub"},"content":{"rendered":"<p>\u524d\u5e7e\u9031\uff0c\u4e0d\u77e5\u4f55\u6545\uff0c\u96fb\u8166\u7684 Grub \u6bc0\u640d\uff0c\u6240\u4ee5\u5c0e\u81f4\u96fb\u8166\u7121\u6cd5\u958b\u6a5f\u3002<\/p>\n<style type=\"text\/css\">\n    li.present01 {line-height:1.5em; background-color:#F5E5C9; padding:5px; border-radius:10px; font-weight:bold; margin:5px;}\n    li.present02 {line-height:1.5em; background-color:#D1EC87; padding:5px; border-radius:10px; font-weight:bold; margin:5px;}\n    li.present03 {line-height:1.5em; background-color:#b3dffa; padding:5px; border-radius:10px; font-weight:bold; margin:5px;}\n    li.present04 {line-height:1.5em; background-color:#FDF6FF; padding:10px; border-radius:10px; font-weight:bold; margin:5px;}\n    ol.lower-alpha {list-style-type:lower-alpha;}\n    ol.lower-roman {list-style-type:lower-roman;}\n    ul.none {list-style-type:none;line-height:1.5em; padding:10px;}\n    ul.note {line-height:1.5em; padding:10px;}\n    .highlight01 {font-weight:bold; line-height:1.5em; background-color:#e7f49c; padding:0px 2px; border:1px; border-radius:10px;}\n    .highlight02 {font-weight:bold; line-height:1.5em; background-color:#F2F26B; padding:1px 1px; border:1px;}\n    .highlight03 {font-weight:bold; line-height:1.5em; background-color:#F9BF72; padding:3px 10px; border:2px; border-radius:10px;}\n   .box01 {margin: 5px; border:1px #19130B solid; border-radius:5px; padding:10px;}\n   .box02 {margin: 10px; font-weight:bold; line-height:1.5em; padding:10px; border:1px #19130B solid; border-radius:10px;}\n    h3 {border:2px #000 solid; border-width:0px 0px 1px 0px; padding-width:0px 0px 3px 0px;}\n    h5 {border:2px #000 solid; border-width:0px 0px 1px 0px; padding-width:0px 0px 3px 0px;}\n<\/style>\n<p>\u6436\u6551\u7684\u539f\u7406\uff0c(1)\u5148\u60f3\u8fa6\u6cd5\u958b\u6a5f\uff0c(2)\u639b\u8f09\u539f\u78c1\u789f\u76ee\u9304\u9032\u884c\u6aa2\u67e5\uff0c\u770b\u8cc7\u6599\u6709\u7121\u640d\u6bc0\uff0c(3)\u82e5\u8cc7\u6599\u7121\u554f\u984c\uff0c\u5229\u7528 chroot \u539f\u7406\uff0c\u5207\u56de\u539f\u7cfb\u7d71\uff0c\u9032\u884c grub \u91cd\u5efa\u3002<\/p>\n<p>\u904e\u7a0b\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li class=\"present01\">\u60f3\u8fa6\u6cd5\u958b\u6a5f\u3002<\/li>\n<p>    \u53ef\u4ee5\u4f7f\u7528\u5b89\u88dd\u5149\u789f\u7247\u6216\u662f \u5b89\u88dd USB \uff0cLive CD\/USB \u7b49\u7b49\uff0c\u958b\u6a5f\u5f8c\uff0c\u9032\u5165\u300cRescue\u300d\u6a21\u5f0f\u3002<\/li>\n<li class=\"present01\">\u639b\u8f09\u539f\u78c1\u789f\u76ee\u9304\u9032\u884c\u6aa2\u67e5\uff0c\u770b\u8cc7\u6599\u6709\u7121\u640d\u6bc0\u3002<\/li>\n<p>    \u6211\u7684\u786c\u789f\u5206\u5272\u6210\u56db\u5340\uff0c\u5206\u5225\u70ba\uff1a<\/p>\n<div class=\"box01\">\n    \/dev\/nvme0n1p1 ==> \/boot\/efi<br \/>\n    \/dev\/nvme0n1p2 ==> \/home<br \/>\n    \/dev\/nvme0n1p3 ==> swap<br \/>\n    \/dev\/nvme0n1p4 ==> \/\n   <\/div>\n<p>&nbsp;<\/p>\n<p>    \u53c8\uff0c\u6211\u7684\u786c\u789f\u70ba\u300c\u56fa\u614b\u786c\u789f\u300d\uff0c\u63a1\u7528 Btrfs \u6a94\u6848\u7cfb\u7d71\u7684\u6b21\u78c1\u789f\u5340\uff08subvolume\uff09\u7d50\u69cb\uff0c\u56e0\u6b64\u6703\u4ee5<span class=\"highlight01\"> @ \u958b\u982d\u7684\u6b21\u78c1\u789f\u5340\u4f86\u5340\u5206\u6839\u76ee\u9304\u548c\u5bb6\u76ee\u9304\u3002<\/span><\/p>\n<p>    \u53ef\u7528\u4ee5\u4e0b\u65b9\u6cd5\u4f86\u78ba\u8a8d\u6839\u76ee\u9304\u6b21\u78c1\u789f\u5340\u540d\u7a31\u3002<br \/>\n    <span class=\"highlight01\">sudo btrfs subvolume list \/dev\/nvme0n1p4 <\/span><\/p>\n<p>    \u5982\u679c\u7d50\u679c\u986f\u793a @rootfs\uff0c\u5247\u8b49\u660e\u6839\u76ee\u9304\u6b21\u78c1\u789f\u5340\u540d\u7a31\u662f @rootfs\u3002<\/p>\n<p>    \u78ba\u8a8d\u6839\u76ee\u9304\u5f8c\uff0c\u5728\u6551\u63f4\u7cfb\u7d71\u88e1\u627e\u500b\u76ee\u9304\uff0c\u4f8b\u5982 \/mnt \uff0c\u5728\u5176\u5e95\u4e0b\u76ee\u9304\u4e0b\u5efa\u500b\u7a7a\u7684\u76ee\u9304\uff0c\u518d\u5c07\u539f\u786c\u789f\u6839\u76ee\u9304\u639b\u8f09\u4e0a\u4f86\uff0c\u6b64\u6642\u53ef\u4ee5\u8003\u616e\u7528\u78c1\u5340\u540d\u7a31\u4f86\u547d\u540d\uff0c\u4ee5\u514d\u639b\u8f09\u4e0a\u4f86\u6642\uff0c\u641e\u6df7\u4e86\u3002\u6240\u4ee5\uff1a<\/p>\n<div class=\"box01\">\n    sudo mkdir \/mnt\/nvme0n1p4 <\/p>\n<p>    ## \/dev\/nvme0n1p4 \u70ba \u6839\u76ee\u9304<br \/>\n    sudo mount -o subvol=@rootfs \/dev\/nvme0n1p4 \/mnt\/nvme0n1p4<\/p>\n<p>    ## \/dev\/nvme0n1p2 \u70ba \/boot\/efi \uff0c\u6240\u4ee5\u8981\u639b\u8f09\u5230 \/mnt\/nvme0n1p4\/boot\/efi<br \/>\n    sudo mount -o subvol=@rootfs \/dev\/nvme0n1p1 \/mnt\/nvme0n1p4\/boot\/efi\n    <\/p><\/div>\n<p>&nbsp;<\/p>\n<li class=\"present01\">\u5229\u7528 chroot \u5207\u56de\u539f\u7cfb\u7d71<\/li>\n<p>    \u56e0\u70ba\u8981\u5229\u7528 chroot \u4f86\u5207\u63db\u56de\u539f\u4f86\u7cfb\u7d71\uff0c\u6240\u4ee5\u8981\u639b\u8f09\u5fc5\u8981\u6a94\u6848\u7cfb\u7d71\uff0c\u518d chroot \u904e\u53bb\uff1a<\/p>\n<div class=\"box01\">\n         ##\u5148\u639b\u8f09\u5fc5\u8981\u6a94\u6848\u7cfb\u7d71<br \/>\n         sudo mount &#8211;bind \/dev \/mnt\/nvme0n1p4\/dev<br \/>\n         sudo mount &#8211;bind \/proc \/mnt\/nvme0n1p4\/proc<br \/>\n         sudo mount &#8211;bind \/sys \/mnt\/nvme0n1p4\/sys<\/p>\n<p>         ##\u518dchroot \u904e\u53bb\u539f\u7cfb\u7d71<br \/>\n         sudo chroot \/mnt\/nvme0n1p4<\/p><\/div>\n<p>&nbsp;<\/p>\n<li class=\"present01\">\u91cd\u5efa grub \u7cfb\u7d71\u8207\u9078\u55ae\u3002<\/li>\n<div class=\"box01\">\n    ##\u56e0\u70ba\u7cfb\u7d71\u662f UEFI\uff0c\u6240\u4ee5\u6307\u4ee4\u5982\u4e0b\uff1a<br \/>\n    grub-install &#8211;target=x86_64-efi &#8211;efi-directory=\/boot\/efi &#8211;bootloader-id=debian<\/p>\n<p>    ##\u66f4\u65b0 GRUB \u914d\u7f6e\u6587\u4ef6\uff0c\u8b93\u5b83\u80fd\u5075\u6e2c\u5230\u7cfb\u7d71\u6838\u5fc3\u3002<br \/>\n    update-grub<\/p><\/div>\n<p>&nbsp;<\/p>\n<li class=\"present01\">\u5b8c\u6210\u4e0a\u8ff0\u5de5\u4f5c\u5f8c\uff0c\u5378\u8f09\u525b\u525b\u639b\u8f09\u4e0a\u7684\u6240\u6709\u76ee\u9304\uff0c\u91cd\u65b0\u958b\u6a5f\u3002<\/li>\n<p>&nbsp;<\/p>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u5e7e\u9031\uff0c\u4e0d\u77e5\u4f55\u6545\uff0c\u96fb\u8166\u7684 Grub \u6bc0\u640d\uff0c\u6240\u4ee5\u5c0e\u81f4\u96fb\u8166\u7121\u6cd5\u958b\u6a5f\u3002 \u6436\u6551\u7684\u539f\u7406\uff0c(1 <a class=\"more-link\" href=\"https:\/\/yowlab.idv.tw\/wordpress\/?p=3413\">Continue reading <span class=\"screen-reader-text\">  \u6436\u6551\u4e26\u91cd\u5efa\u786c\u789f\u7684 grub<\/span><span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[120,121],"class_list":["post-3413","post","type-post","status-publish","format-standard","hentry","category-3","tag-chroot","tag-grub"],"_links":{"self":[{"href":"https:\/\/yowlab.idv.tw\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yowlab.idv.tw\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yowlab.idv.tw\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yowlab.idv.tw\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/yowlab.idv.tw\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3413"}],"version-history":[{"count":14,"href":"https:\/\/yowlab.idv.tw\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3413\/revisions"}],"predecessor-version":[{"id":3427,"href":"https:\/\/yowlab.idv.tw\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3413\/revisions\/3427"}],"wp:attachment":[{"href":"https:\/\/yowlab.idv.tw\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yowlab.idv.tw\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yowlab.idv.tw\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}