{"id":730,"date":"2025-05-18T12:54:59","date_gmt":"2025-05-18T04:54:59","guid":{"rendered":"https:\/\/blog.guguan.dpdns.org\/?p=730"},"modified":"2025-05-24T14:47:18","modified_gmt":"2025-05-24T06:47:18","slug":"%e5%9c%a8-debian-%e4%bd%bf%e7%94%a8-chroot-%e5%ae%89%e8%a3%85-arch-linux","status":"publish","type":"post","link":"https:\/\/blog.guguan.us.kg\/?p=730","title":{"rendered":"\u5728 Debian \u4f7f\u7528 chroot \u5b89\u88c5 Arch Linux"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">\u5b89\u88c5\u65b9\u6cd5<\/h4>\n\n\n\n<p class=\"has-small-font-size wp-block-paragraph\">\u6765\u81ea\u5b98\u65b9Wiki\uff1a<a href=\"https:\/\/wiki.archlinux.org.cn\/title\/Install_Arch_Linux_from_existing_Linux#From_a_host_running_another_Linux_distribution\">\u4ece\u73b0\u6709 Linux \u5b89\u88c5 Arch Linux &#8211; ArchWiki &#8211; Arch Linux \u767e\u79d1<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u521b\u5efa\u5e76\u8fdb\u5165\u4e00\u4e2a\u76ee\u5f55\uff08\u54ea\u91cc\u90fd\u53ef\u4ee5\uff09\nmkdir \/var\/archlinux &amp;&amp; cd \/var\/archlinux\n\n# \u4e0b\u8f7d\u5f15\u5bfc tarball \u548c\u6821\u9a8c\u6587\u4ef6\nwget https:\/\/mirrors.ustc.edu.cn\/archlinux\/iso\/latest\/archlinux-bootstrap-x86_64.tar.zst\nwget https:\/\/archlinux.org\/iso\/latest\/sha256sums.txt\n\n# \u6821\u9a8c\u5f15\u5bfc tarball \u6587\u4ef6\u662f\u5426\u635f\u574f\nsha256sum -c sha256sums.txt\n\n# \u89e3\u538b\ntar xf archlinux-bootstrap-x86_64.tar.zst --numeric-owner\n\n# \u7ed1\u5b9a\u6302\u8f7d\u76ee\u5f55\u5230\u81ea\u8eab\nmount --bind root.x86_64\/ root.x86_64\/\n\n# \u542f\u52a8\u5bb9\u5668\n.\/root.x86_64\/bin\/arch-chroot .\/root.x86_64\/\n\n# \u9000\u51fa\u5bb9\u5668\u540e\uff0c\u5378\u8f7d\u7ed1\u5b9a\u6302\u8f7d\numount root.x86_64\/<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u811a\u672c\u6765\u542f\u52a8\u5bb9\u5668<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\n# \u83b7\u53d6\u5f53\u524d\u811a\u672c\u6240\u5728\u76ee\u5f55\nSHELL_FOLDER=$(dirname $(readlink -f \"$0\"))\n\n# \u5b9a\u4e49 chroot \u76ee\u5f55\nCHROOT_DIR=\"$SHELL_FOLDER\/root.x86_64\"\n\n# \u7ed1\u5b9a\u6302\u8f7d\u76ee\u5f55\u5230\u81ea\u8eab\nmount --bind \"$CHROOT_DIR\" \"$CHROOT_DIR\" || exit 1\n\n# \u8fdb\u5165 chroot \u73af\u5883\n\"$CHROOT_DIR\/bin\/arch-chroot\" \"$CHROOT_DIR\"\n\n# \u5b9a\u4e49\u9000\u51fa\u65f6\u7684\u6e05\u7406\u51fd\u6570\ncleanup() {\n  echo \"Cleaning up...\"\n  umount \"$CHROOT_DIR\"\n  echo \"Unmounted $CHROOT_DIR\"\n}\n\n# \u6355\u83b7 EXIT \u4fe1\u53f7\u5e76\u5728\u9000\u51fa\u65f6\u8c03\u7528 cleanup \u51fd\u6570\ntrap cleanup EXIT\n\n# \u4fdd\u6301\u811a\u672c\u8fd0\u884c\u76f4\u5230 chroot \u73af\u5883\u9000\u51fa\nwait<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">\u8bbe\u7f6e\u4e3a\u4e2d\u6587<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u6765\u81ea\u5b98\u65b9Wiki\uff1a<a href=\"https:\/\/wiki.archlinuxcn.org\/zh-hans\/%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87%E6%9C%AC%E5%9C%B0%E5%8C%96#%E5%AE%89%E8%A3%85%E4%B8%AD%E6%96%87_locale\">\u7b80\u4f53\u4e2d\u6587\u672c\u5730\u5316 &#8211; Arch Linux \u4e2d\u6587\u7ef4\u57fa<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fee\u6539 <code>\/etc\/locale.gen<\/code>\u00a0\u6587\u4ef6\uff08\u53d6\u6d88\u5bf9\u5e94\u9879\u524d\u7684\u6ce8\u91ca\u7b26\u53f7\u201c<code>#<\/code>\u201d\u5373\u53ef\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>en_US.UTF-8 UTF-8\nzh_CN.UTF-8 UTF-8<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6267\u884c\u547d\u4ee4 <code>locale-gen<\/code> \u5373\u53ef<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 chroot \u5b89\u88c5 Arch Linux \u7684\u8be6\u7ec6\u8fc7\u7a0b<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[101,102,14,28],"class_list":["post-730","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-arch-linux","tag-chroot","tag-debian","tag-linux"],"_links":{"self":[{"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/posts\/730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=730"}],"version-history":[{"count":5,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/posts\/730\/revisions"}],"predecessor-version":[{"id":740,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/posts\/730\/revisions\/740"}],"wp:attachment":[{"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}