{"id":1536,"date":"2026-04-16T07:28:57","date_gmt":"2026-04-15T23:28:57","guid":{"rendered":"https:\/\/blog.guguan.us.kg\/?p=1536"},"modified":"2026-04-20T06:45:30","modified_gmt":"2026-04-19T22:45:30","slug":"%e5%9c%a8chroot%e9%87%8c%e4%bd%bf%e7%94%a8alpine-linux","status":"publish","type":"post","link":"https:\/\/blog.guguan.us.kg\/?p=1536","title":{"rendered":"\u5728chroot\u91cc\u4f7f\u7528Alpine Linux"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4e0b\u8f7d\u5e76\u89e3\u538brootfs<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir -p \/var\/lib\/machines\/alpine &amp;&amp; cd \/var\/lib\/machines\/alpine\nwget https:\/\/dl-cdn.alpinelinux.org\/alpine\/v3.23\/releases\/x86_64\/alpine-minirootfs-3.23.4-x86_64.tar.gz\ntar -xzvf alpine-minirootfs-3.23.4-x86_64.tar.gz<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6302\u8f7d\u57fa\u7840\u8def\u5f84<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cp -L \/etc\/resolv.conf etc\/\nmount --bind \/proc proc\nmount --bind \/sys sys\nmount --bind \/dev dev\nmount --bind \/dev\/shm dev\/shm\nmount --bind \/dev\/mqueue dev\/mqueue\nmount --bind \/dev\/pts dev\/pts<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fdb\u5165\u5bb9\u5668<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chroot . \/usr\/bin\/env -i LOGNAME=root USER=root HOME=\/root TERM=$TERM \/bin\/ash -l<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u9000\u51fa\u5bb9\u5668\u540e\u89e3\u9664\u6302\u8f7d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>umount dev\/pts\numount dev\/mqueue\numount dev\/shm\numount dev\numount sys\numount proc<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u68c0\u67e5\u662f\u5426\u8fd8\u6709\u672a\u5378\u8f7d\u7684\u6b8b\u7559<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mount | grep $(pwd)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fee\u6539 Alpine \u7684\u8f6f\u4ef6\u6e90<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sed -i 's\/dl-cdn.alpinelinux.org\/mirrors.aliyun.com\/g' \/etc\/apk\/repositories<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u8f7d\u5e76\u89e3\u538brootfs \u6302\u8f7d\u57fa\u7840\u8def\u5f84 \u8fdb\u5165\u5bb9\u5668 \u9000\u51fa\u5bb9\u5668\u540e\u89e3\u9664\u6302\u8f7d \u68c0\u67e5\u662f\u5426\u8fd8\u6709\u672a\u5378\u8f7d\u7684\u6b8b\u7559 \u4fee\u6539 Alpin [&hellip;]<\/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":[],"class_list":["post-1536","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/posts\/1536","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=1536"}],"version-history":[{"count":6,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/posts\/1536\/revisions"}],"predecessor-version":[{"id":1560,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=\/wp\/v2\/posts\/1536\/revisions\/1560"}],"wp:attachment":[{"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.guguan.us.kg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}