{"id":297,"date":"2025-06-26T10:42:05","date_gmt":"2025-06-26T02:42:05","guid":{"rendered":"https:\/\/qkd.koudaipc.com\/?p=297"},"modified":"2025-06-26T10:42:05","modified_gmt":"2025-06-26T02:42:05","slug":"%e4%bd%bf%e7%94%a8-qemubuilder-%e6%9e%84%e5%bb%ba%e4%b8%8d%e5%90%8c%e6%9e%b6%e6%9e%84%e7%9a%84-debian-%e8%bd%af%e4%bb%b6%e5%8c%85","status":"publish","type":"post","link":"https:\/\/qkd.koudaipc.com\/en\/2025\/06\/26\/%e4%bd%bf%e7%94%a8-qemubuilder-%e6%9e%84%e5%bb%ba%e4%b8%8d%e5%90%8c%e6%9e%b6%e6%9e%84%e7%9a%84-debian-%e8%bd%af%e4%bb%b6%e5%8c%85\/","title":{"rendered":"\u4f7f\u7528 qemubuilder \u6784\u5efa\u4e0d\u540c\u67b6\u6784\u7684 Debian \u8f6f\u4ef6\u5305"},"content":{"rendered":"<h1>\u4f7f\u7528 qemubuilder \u6784\u5efa\u4e0d\u540c\u67b6\u6784\u7684 Debian \u8f6f\u4ef6\u5305<\/h1>\n<p><code>qemubuilder<\/code> \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u5141\u8bb8\u5728 x86\/x86_64 \u4e3b\u673a\u4e0a\u4e3a\u5176\u4ed6\u67b6\u6784\uff08\u5982 arm64\u3001armhf\u3001ppc64el \u7b49\uff09\u6784\u5efa Debian \u8f6f\u4ef6\u5305\u3002\u5b83\u4f7f\u7528 QEMU \u6a21\u62df\u76ee\u6807\u67b6\u6784\uff0c\u5e76\u7ed3\u5408 pbuilder \u63d0\u4f9b\u7eaf\u51c0\u7684\u6784\u5efa\u73af\u5883\u3002<\/p>\n<h2>\u5b89\u88c5\u548c\u914d\u7f6e qemubuilder<\/h2>\n<h3>1. \u5b89\u88c5\u5fc5\u8981\u8f6f\u4ef6\u5305<\/h3>\n<pre><code class=\"language-bash\">sudo apt update\nsudo apt install qemubuilder qemu-user-static binfmt-support debootstrap<\/code><\/pre>\n<h3>2. \u914d\u7f6e binfmt \u652f\u6301<\/h3>\n<p>\u786e\u4fdd binfmt \u652f\u6301\u5df2\u542f\u7528\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo update-binfmts --enable<\/code><\/pre>\n<h3>3. \u521b\u5efa\u57fa\u7840\u73af\u5883<\/h3>\n<p>\u4e3a\u7279\u5b9a\u67b6\u6784\u521b\u5efa\u57fa\u7840\u73af\u5883\uff08\u4ee5 arm64 \u4e3a\u4f8b\uff09\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo DIST=bookworm ARCH=arm64 qemubuilder create<\/code><\/pre>\n<h2>\u6784\u5efa\u4e0d\u540c\u67b6\u6784\u7684\u8f6f\u4ef6\u5305<\/h2>\n<h3>1. \u66f4\u65b0\u6784\u5efa\u73af\u5883<\/h3>\n<pre><code class=\"language-bash\">sudo DIST=bookworm ARCH=arm64 qemubuilder update<\/code><\/pre>\n<h3>2. \u51c6\u5907\u6e90\u4ee3\u7801\u5305<\/h3>\n<p>\u5728\u6e90\u4ee3\u7801\u76ee\u5f55\u4e2d\uff1a<\/p>\n<pre><code class=\"language-bash\">dpkg-source -b .<\/code><\/pre>\n<h3>3. \u6784\u5efa\u8f6f\u4ef6\u5305<\/h3>\n<pre><code class=\"language-bash\">sudo DIST=bookworm ARCH=arm64 qemubuilder build *.dsc<\/code><\/pre>\n<h3>4. \u83b7\u53d6\u6784\u5efa\u7ed3\u679c<\/h3>\n<p>\u6784\u5efa\u5b8c\u6210\u7684\u8f6f\u4ef6\u5305\u4f4d\u4e8e\uff1a<\/p>\n<pre><code>\/var\/cache\/pbuilder\/result\/<\/code><\/pre>\n<h2>\u652f\u6301\u7684\u5176\u4ed6\u67b6\u6784<\/h2>\n<p>qemubuilder \u652f\u6301\u591a\u79cd\u67b6\u6784\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u67b6\u6784<\/th>\n<th>\u547d\u4ee4\u793a\u4f8b<\/th>\n<th>\u5e38\u89c1\u8bbe\u5907<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>arm64<\/td>\n<td><code>ARCH=arm64 qemubuilder build ...<\/code><\/td>\n<td>Raspberry Pi 4, AWS Graviton<\/td>\n<\/tr>\n<tr>\n<td>armhf<\/td>\n<td><code>ARCH=armhf qemubuilder build ...<\/code><\/td>\n<td>Raspberry Pi 2\/3, Chromebooks<\/td>\n<\/tr>\n<tr>\n<td>ppc64el<\/td>\n<td><code>ARCH=ppc64el qemubuilder build ...<\/code><\/td>\n<td>IBM Power Systems<\/td>\n<\/tr>\n<tr>\n<td>mips<\/td>\n<td><code>ARCH=mips qemubuilder build ...<\/code><\/td>\n<td>\u5d4c\u5165\u5f0f\u8bbe\u5907<\/td>\n<\/tr>\n<tr>\n<td>mipsel<\/td>\n<td><code>ARCH=mipsel qemubuilder build ...<\/code><\/td>\n<td>\u5d4c\u5165\u5f0f\u8bbe\u5907<\/td>\n<\/tr>\n<tr>\n<td>s390x<\/td>\n<td><code>ARCH=s390x qemubuilder build ...<\/code><\/td>\n<td>IBM Z Systems<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u9ad8\u7ea7\u7528\u6cd5<\/h2>\n<h3>1. \u81ea\u5b9a\u4e49\u955c\u50cf\u6e90<\/h3>\n<pre><code class=\"language-bash\">sudo DIST=bookworm ARCH=arm64 MIRROR=&quot;http:\/\/deb.debian.org\/debian&quot; qemubuilder create<\/code><\/pre>\n<h3>2. \u6dfb\u52a0\u989d\u5916\u8f6f\u4ef6\u4ed3\u5e93<\/h3>\n<pre><code class=\"language-bash\">sudo DIST=bookworm ARCH=arm64 qemubuilder create --othermirror &quot;deb http:\/\/example.com\/repo bookworm main&quot;<\/code><\/pre>\n<h3>3. \u767b\u5f55\u5230\u6784\u5efa\u73af\u5883<\/h3>\n<pre><code class=\"language-bash\">sudo DIST=bookworm ARCH=arm64 qemubuilder login<\/code><\/pre>\n<h3>4. \u5b89\u88c5\u989d\u5916\u4f9d\u8d56<\/h3>\n<p>\u5728\u767b\u5f55\u73af\u5883\u4e2d\uff1a<\/p>\n<pre><code class=\"language-bash\">apt install build-essential devscripts fakeroot<\/code><\/pre>\n<h3>5. \u624b\u52a8\u6784\u5efa\u8f6f\u4ef6\u5305<\/h3>\n<p>\u5728\u767b\u5f55\u73af\u5883\u4e2d\uff1a<\/p>\n<pre><code class=\"language-bash\">cd \/path\/to\/source\ndpkg-buildpackage -us -uc<\/code><\/pre>\n<h2>\u6027\u80fd\u4f18\u5316\u6280\u5de7<\/h2>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528 cowbuilder \u540e\u7aef<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo apt install cowbuilder\nsudo DIST=bookworm ARCH=arm64 qemubuilder create --builder cowbuilder<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u542f\u7528 ccache<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo DIST=bookworm ARCH=arm64 qemubuilder login\napt install ccache\necho 'export PATH=\"\/usr\/lib\/ccache:$PATH\"' >> ~\/.bashrc<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u589e\u52a0\u5185\u5b58\u9650\u5236<\/strong>\uff1a<br \/>\n\u7f16\u8f91 <code>\/etc\/qemubuilder\/pbuilderrc<\/code>\uff1a<\/p>\n<pre><code class=\"language-bash\">MEMORY=2048  # \u589e\u52a0 QEMU \u5185\u5b58\u5230 2GB<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528 tmpfs<\/strong>\uff1a<br \/>\n\u5728 <code>\/etc\/fstab<\/code> \u6dfb\u52a0\uff1a<\/p>\n<pre><code class=\"language-bash\">tmpfs \/var\/cache\/pbuilder\/build tmpfs defaults,size=4G 0 0<\/code><\/pre>\n<\/li>\n<\/ol>\n<h2>\u5e38\u89c1\u95ee\u9898\u89e3\u51b3<\/h2>\n<p><strong>\u95ee\u9898\uff1a<\/strong> \u6784\u5efa\u8fc7\u7a0b\u975e\u5e38\u7f13\u6162<br \/>\n<strong>\u89e3\u51b3\uff1a<\/strong>  <\/p>\n<ul>\n<li>\u4f7f\u7528 <code>cowbuilder<\/code> \u4ee3\u66ff\u9ed8\u8ba4\u6784\u5efa\u5668<\/li>\n<li>\u589e\u52a0 QEMU \u5185\u5b58\u9650\u5236<\/li>\n<li>\u786e\u4fdd\u4e3b\u673a\u6709\u8db3\u591f\u5185\u5b58\u548c\u4ea4\u6362\u7a7a\u95f4<\/li>\n<\/ul>\n<p><strong>\u95ee\u9898\uff1a<\/strong> <code>binfmt_misc<\/code> \u6ce8\u518c\u5931\u8d25<br \/>\n<strong>\u89e3\u51b3\uff1a<\/strong>  <\/p>\n<pre><code class=\"language-bash\">sudo systemctl restart systemd-binfmt\nsudo service binfmt-support restart<\/code><\/pre>\n<p><strong>\u95ee\u9898\uff1a<\/strong> \u4f9d\u8d56\u5173\u7cfb\u89e3\u6790\u5931\u8d25<br \/>\n<strong>\u89e3\u51b3\uff1a<\/strong>  <\/p>\n<ol>\n<li>\u767b\u5f55\u5230\u6784\u5efa\u73af\u5883\uff1a\n<pre><code class=\"language-bash\">sudo DIST=bookworm ARCH=arm64 qemubuilder login<\/code><\/pre>\n<\/li>\n<li>\u624b\u52a8\u5b89\u88c5\u7f3a\u5931\u4f9d\u8d56\uff1a\n<pre><code class=\"language-bash\">apt update\napt install -f<\/code><\/pre>\n<\/li>\n<\/ol>\n<p><strong>\u95ee\u9898\uff1a<\/strong> QEMU \u5d29\u6e83\u6216\u6bb5\u9519\u8bef<br \/>\n<strong>\u89e3\u51b3\uff1a<\/strong>  <\/p>\n<ol>\n<li>\u66f4\u65b0 QEMU \u5230\u6700\u65b0\u7248\u672c\uff1a\n<pre><code class=\"language-bash\">sudo apt install --only-upgrade qemu-user-static<\/code><\/pre>\n<\/li>\n<li>\u5c1d\u8bd5\u4f7f\u7528\u4e0d\u540c\u7684 QEMU \u7b56\u7565\uff1a\n<pre><code class=\"language-bash\">echo \"QEMU_MODE=system\" | sudo tee -a \/etc\/qemubuilder\/pbuilderrc<\/code><\/pre>\n<\/li>\n<\/ol>\n<h2>\u5b8c\u6574\u793a\u4f8b\u5de5\u4f5c\u6d41<\/h2>\n<pre><code class=\"language-bash\"># \u521b\u5efa arm64 \u6784\u5efa\u73af\u5883\nsudo DIST=bookworm ARCH=arm64 qemubuilder create\n\n# \u66f4\u65b0\u73af\u5883\nsudo DIST=bookworm ARCH=arm64 qemubuilder update\n\n# \u83b7\u53d6\u6e90\u4ee3\u7801\ngit clone https:\/\/salsa.debian.org\/debian\/hello.git\ncd hello\n\n# \u5b89\u88c5\u6784\u5efa\u4f9d\u8d56\nsudo mk-build-deps -i -r\n\n# \u751f\u6210\u6e90\u4ee3\u7801\u5305\ndpkg-source -b .\n\n# \u6784\u5efa\u8f6f\u4ef6\u5305\nsudo DIST=bookworm ARCH=arm64 qemubuilder build ..\/hello_*.dsc\n\n# \u68c0\u67e5\u6784\u5efa\u7ed3\u679c\nls -l \/var\/cache\/pbuilder\/result\/<\/code><\/pre>\n<h2>\u6e05\u7406\u73af\u5883<\/h2>\n<pre><code class=\"language-bash\"># \u5220\u9664\u7279\u5b9a\u67b6\u6784\u73af\u5883\nsudo DIST=bookworm ARCH=arm64 qemubuilder clean\n\n# \u5220\u9664\u6240\u6709 qemubuilder \u73af\u5883\nsudo rm -rf \/var\/cache\/pbuilder\/base-*.cow<\/code><\/pre>\n<p>\u4f7f\u7528 <code>qemubuilder<\/code> \u53ef\u4ee5\u5728\u5355\u4e00\u4e3b\u673a\u4e0a\u4e3a\u591a\u79cd\u67b6\u6784\u6784\u5efa Debian \u8f6f\u4ef6\u5305\uff0c\u65e0\u9700\u7ef4\u62a4\u591a\u4e2a\u7269\u7406\u8bbe\u5907\uff0c\u5927\u5927\u7b80\u5316\u4e86\u8de8\u67b6\u6784\u5f00\u53d1\u6d41\u7a0b\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 qemubuilder \u6784\u5efa\u4e0d\u540c\u67b6\u6784\u7684 Debian \u8f6f\u4ef6\u5305 qemubuilder \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pmpro_default_level":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-297","post","type-post","status-publish","format-standard","hentry","category-uncategorized","pmpro-has-access"],"_links":{"self":[{"href":"https:\/\/qkd.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qkd.koudaipc.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qkd.koudaipc.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qkd.koudaipc.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/qkd.koudaipc.com\/en\/wp-json\/wp\/v2\/comments?post=297"}],"version-history":[{"count":1,"href":"https:\/\/qkd.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/297\/revisions"}],"predecessor-version":[{"id":298,"href":"https:\/\/qkd.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/297\/revisions\/298"}],"wp:attachment":[{"href":"https:\/\/qkd.koudaipc.com\/en\/wp-json\/wp\/v2\/media?parent=297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qkd.koudaipc.com\/en\/wp-json\/wp\/v2\/categories?post=297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qkd.koudaipc.com\/en\/wp-json\/wp\/v2\/tags?post=297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}