{"id":301,"date":"2025-06-26T16:07:01","date_gmt":"2025-06-26T08:07:01","guid":{"rendered":"https:\/\/qkd.koudaipc.com\/?p=301"},"modified":"2025-06-26T16:07:01","modified_gmt":"2025-06-26T08:07:01","slug":"%e4%bd%bf%e7%94%a8-debootstrap-%e5%ae%89%e8%a3%85%e6%96%b0%e7%89%88-debian","status":"publish","type":"post","link":"https:\/\/ns1.koudaipc.com\/en\/2025\/06\/26\/%e4%bd%bf%e7%94%a8-debootstrap-%e5%ae%89%e8%a3%85%e6%96%b0%e7%89%88-debian\/","title":{"rendered":"\u4f7f\u7528 debootstrap \u5b89\u88c5\u65b0\u7248 Debian"},"content":{"rendered":"<p>\u4f7f\u7528 <code>debootstrap<\/code> \u5b89\u88c5\u65b0\u7248 Debian\uff08\u5982 Bookworm \u6216 Trixie\uff09\u662f\u4e00\u79cd\u9ad8\u6548\u7075\u6d3b\u7684\u65b9\u5f0f\uff0c\u5c24\u5176\u9002\u7528\u4e8e\u5b9a\u5236\u5316\u5b89\u88c5\u6216\u8de8\u67b6\u6784\u90e8\u7f72\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\u53ca\u5173\u952e\u6ce8\u610f\u4e8b\u9879\uff1a<\/p>\n<hr \/>\n<h3>\ud83d\udce6 <strong>\u4e00\u3001\u51c6\u5907\u5de5\u4f5c<\/strong><\/h3>\n<ol>\n<li>\n<p><strong>\u542f\u52a8\u73af\u5883<\/strong>  <\/p>\n<ul>\n<li>\u4ece Debian Live \u955c\u50cf\u6216\u73b0\u6709 Linux \u7cfb\u7edf\uff08\u5982 Ubuntu\uff09\u542f\u52a8\uff0c\u786e\u4fdd\u8054\u7f51\u3002<\/li>\n<li>\u66f4\u65b0\u8f6f\u4ef6\u6e90\u5e76\u5b89\u88c5\u4f9d\u8d56\uff1a\n<pre><code class=\"language-bash\">sudo apt update\nsudo apt install debootstrap btrfs-progs dosfstools grub-efi arch-install-scripts  # \u63a8\u8350\u5b89\u88c5\u7684\u5de5\u5177<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5206\u533a\u4e0e\u683c\u5f0f\u5316<\/strong>  <\/p>\n<ul>\n<li>\u4f7f\u7528 <code>cfdisk<\/code> \u6216 <code>parted<\/code> \u5206\u533a\uff08\u793a\u4f8b\u4e3a UEFI + Btrfs\uff09\uff1a\n<ul>\n<li><code>\/dev\/sda1<\/code>\uff1aBtrfs \u6839\u5206\u533a\uff08\u63a8\u8350 <code>compress=zstd<\/code> \u6302\u8f7d\uff09<\/li>\n<li><code>\/dev\/sda2<\/code>\uff1aSwap \u5206\u533a<\/li>\n<li><code>\/dev\/sda3<\/code>\uff1aFAT32 EFI \u5206\u533a\uff08\u9700 <code>mkfs.fat -F32<\/code>\uff09<\/li>\n<\/ul>\n<\/li>\n<li>\u6302\u8f7d\u5206\u533a\uff1a\n<pre><code class=\"language-bash\">sudo mount -t btrfs -o subvol=\/@,compress=zstd \/dev\/sda1 \/mnt\nsudo mkdir -p \/mnt\/{boot\/efi,home}\nsudo mount \/dev\/sda3 \/mnt\/boot\/efi\nsudo swapon \/dev\/sda2<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h3>\u2699\ufe0f <strong>\u4e8c\u3001\u5b89\u88c5\u57fa\u7840\u7cfb\u7edf<\/strong><\/h3>\n<ol>\n<li>\n<p><strong>\u8fd0\u884c debootstrap<\/strong>  <\/p>\n<ul>\n<li>\u6307\u5b9a\u7248\u672c\uff08\u5982 <code>bookworm<\/code>\uff09\u548c\u955c\u50cf\u6e90\uff08\u56fd\u5185\u6e90\u52a0\u901f\uff09\uff1a\n<pre><code class=\"language-bash\">sudo debootstrap bookworm \/mnt https:\/\/mirrors.ustc.edu.cn\/debian\/  # \u4e2d\u79d1\u5927\u6e90<\/code><\/pre>\n<\/li>\n<li>\u82e5\u9700\u5b89\u88c5\u7279\u5b9a\u5b50\u7248\u672c\uff08\u5982\u521d\u59cb\u7248\uff09\uff0c\u4f7f\u7528 Debian \u5feb\u7167\u4ed3\u5e93\uff1a\n<pre><code class=\"language-bash\">sudo debootstrap --arch=amd64 bookworm \/mnt http:\/\/snapshot.debian.org\/archive\/debian\/20230601T030639Z\/  # \u66ff\u6362\u4e3a\u5feb\u7167\u65e5\u671f<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u590d\u5236\u914d\u7f6e<\/strong>  <\/p>\n<ul>\n<li>\u5c06\u4e3b\u673a\u6e90\u5217\u8868\u590d\u5236\u5230\u65b0\u7cfb\u7edf\uff1a\n<pre><code class=\"language-bash\">sudo cp \/etc\/apt\/sources.list \/mnt\/etc\/apt\/  # \u786e\u4fdd\u65b0\u7cfb\u7edf\u4f7f\u7528\u6700\u65b0\u6e90<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h3>\ud83d\udd27 <strong>\u4e09\u3001\u8fdb\u5165 Chroot \u73af\u5883<\/strong><\/h3>\n<ol>\n<li><strong>\u6302\u8f7d\u865a\u62df\u6587\u4ef6\u7cfb\u7edf<\/strong>\n<pre><code class=\"language-bash\">sudo mount --bind \/dev \/mnt\/dev\nsudo mount --bind \/proc \/mnt\/proc\nsudo mount --bind \/sys \/mnt\/sys\nsudo mount --bind \/dev\/pts \/mnt\/dev\/pts<\/code><\/pre>\n<\/li>\n<li><strong>Chroot \u5e76\u914d\u7f6e\u7cfb\u7edf<\/strong>\n<pre><code class=\"language-bash\">sudo chroot \/mnt \/bin\/bash\nexport TERM=xterm-color  # \u907f\u514d\u7ec8\u7aef\u663e\u793a\u95ee\u9898<\/code><\/pre>\n<\/li>\n<\/ol>\n<hr \/>\n<h3>\u26a1 <strong>\u56db\u3001\u7cfb\u7edf\u914d\u7f6e<\/strong><\/h3>\n<ol>\n<li>\n<p><strong>\u57fa\u7840\u8bbe\u7f6e<\/strong>  <\/p>\n<ul>\n<li>\u66f4\u65b0\u8f6f\u4ef6\u5305\u5e76\u5b89\u88c5\u5185\u6838\uff1a\n<pre><code class=\"language-bash\">apt update && apt full-upgrade -y\napt install linux-image-amd64 firmware-linux  # \u5b89\u88c5\u5185\u6838\u53ca\u56fa\u4ef6<\/code><\/pre>\n<\/li>\n<li>\u8bbe\u7f6e\u65f6\u533a\u3001\u8bed\u8a00\uff1a\n<pre><code class=\"language-bash\">dpkg-reconfigure tzdata\napt install locales && dpkg-reconfigure locales<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u7f51\u7edc\u4e0e\u7528\u6237<\/strong>  <\/p>\n<ul>\n<li>\u914d\u7f6e\u7f51\u7edc\uff08DHCP \u793a\u4f8b\uff09\uff1a\n<pre><code class=\"language-bash\">echo \"auto eth0\" >> \/etc\/network\/interfaces\necho \"iface eth0 inet dhcp\" >> \/etc\/network\/interfaces<\/code><\/pre>\n<\/li>\n<li>\u8bbe\u7f6e root \u5bc6\u7801\u53ca\u521b\u5efa\u7528\u6237\uff1a\n<pre><code class=\"language-bash\">passwd root\nadduser yourusername && usermod -aG sudo yourusername  # \u6dfb\u52a0 sudo \u7528\u6237<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u751f\u6210 fstab \u6587\u4ef6<\/strong>  <\/p>\n<ul>\n<li>\u4f7f\u7528 <code>genfstab<\/code>\uff08\u9700\u5b89\u88c5 <code>arch-install-scripts<\/code>\uff09\u6216\u624b\u52a8\u7f16\u5199\uff1a\n<pre><code class=\"language-bash\">genfstab -U \/mnt >> \/etc\/fstab  # \u81ea\u52a8\u751f\u6210 UUID \u6302\u8f7d\u9879<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h3>\ud83d\udda5\ufe0f <strong>\u4e94\u3001\u5b89\u88c5\u5f15\u5bfc\u7a0b\u5e8f<\/strong><\/h3>\n<ol>\n<li><strong>GRUB \u914d\u7f6e\uff08UEFI\uff09<\/strong>\n<pre><code class=\"language-bash\">apt install grub-efi  # UEFI \u7cfb\u7edf\ngrub-install --target=x86_64-efi --efi-directory=\/boot\/efi --bootloader-id=Debian\nupdate-grub  # \u751f\u6210 GRUB \u914d\u7f6e\u6587\u4ef6<\/code><\/pre>\n<\/li>\n<li><strong>BIOS \u7cfb\u7edf<\/strong>\n<pre><code class=\"language-bash\">apt install grub-pc\ngrub-install \/dev\/sda  # \u76ee\u6807\u78c1\u76d8\nupdate-grub<\/code><\/pre>\n<\/li>\n<\/ol>\n<hr \/>\n<h3>\ud83d\ude80 <strong>\u516d\u3001\u6536\u5c3e\u5de5\u4f5c<\/strong><\/h3>\n<ol>\n<li><strong>\u5378\u8f7d\u5e76\u91cd\u542f<\/strong>\n<pre><code class=\"language-bash\">exit  # \u9000\u51fa chroot\nsudo umount -R \/mnt  # \u5378\u8f7d\u6240\u6709\u6302\u8f7d\u70b9\nsudo reboot<\/code><\/pre>\n<\/li>\n<li><strong>\u9996\u6b21\u542f\u52a8\u540e\u4efb\u52a1<\/strong>\n<ul>\n<li>\u5b89\u88c5\u5fc5\u8981\u8f6f\u4ef6\uff08\u5982 SSH\u3001\u7f51\u7edc\u7ba1\u7406\uff09\uff1a\n<pre><code class=\"language-bash\">apt install openssh-server network-manager<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<hr \/>\n<h3>\u26a0\ufe0f <strong>\u5173\u952e\u95ee\u9898\u5904\u7406<\/strong><\/h3>\n<ul>\n<li><strong>\u4f9d\u8d56\u9519\u8bef<\/strong>\uff1a\u786e\u4fdd <code>debootstrap<\/code> \u65f6\u4f7f\u7528\u53ef\u9760\u7684\u955c\u50cf\u6e90\uff08\u5982 <code>http:\/\/ftp.debian.org<\/code>\uff09\uff0c\u907f\u514d\u635f\u574f\u7684\u6e90\u5bfc\u81f4\u5931\u8d25\u3002<\/li>\n<li><strong>\u65e0\u6cd5\u786e\u5b9a\u53d1\u884c\u7248\u4ee3\u53f7<\/strong>\uff1a\u68c0\u67e5\u5206\u533a\u662f\u5426\u6302\u8f7d\u6b63\u786e\uff0c\u6216\u91cd\u65b0\u6302\u8f7d\u5b89\u88c5\u4ecb\u8d28\uff08\u5e38\u89c1\u4e8e USB \u5b89\u88c5\uff09\u3002<\/li>\n<li><strong>\u8de8\u67b6\u6784\u5b89\u88c5<\/strong>\uff08\u5982 ARM\uff09\uff1a<br \/>\n\u9700\u6dfb\u52a0 <code>qemu-user-static<\/code> \u5e76\u5206\u9636\u6bb5\u6267\u884c\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo debootstrap --arch=armhf --foreign bookworm \/mnt http:\/\/ftp.de.debian.org\/debian\ncp \/usr\/bin\/qemu-arm-static \/mnt\/usr\/bin\/\nchroot \/mnt \/debootstrap\/debootstrap --second-stage  # \u5b8c\u6210\u89e3\u538b<\/code><\/pre>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>\ud83d\udc8e <strong>Debian \u7248\u672c\u4e0e\u6e90\u5bf9\u7167\u8868<\/strong><\/h3>\n<table>\n<thead>\n<tr>\n<th><strong>\u7248\u672c\u4ee3\u53f7<\/strong><\/th>\n<th><strong>\u72b6\u6001<\/strong><\/th>\n<th><strong>APT \u6e90\u793a\u4f8b<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>bookworm<\/code><\/td>\n<td>Stable (12)<\/td>\n<td><code>https:\/\/deb.debian.org\/debian<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>trixie<\/code><\/td>\n<td>Testing (13)<\/td>\n<td><code>http:\/\/deb.debian.org\/debian testing main<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>sid<\/code><\/td>\n<td>Unstable<\/td>\n<td><code>http:\/\/deb.debian.org\/debian sid main<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\ud83d\udca1 \u603b\u7ed3\uff1adebootstrap \u7684\u6838\u5fc3\u4f18\u52bf<\/h3>\n<ul>\n<li><strong>\u65e0\u5b89\u88c5\u7a0b\u5e8f\u4f9d\u8d56<\/strong>\uff1a\u76f4\u63a5\u901a\u8fc7\u5bbf\u4e3b\u7cfb\u7edf\u90e8\u7f72\uff0c\u9002\u5408\u6551\u63f4\u3001\u5bb9\u5668\u6216\u5b9a\u5236\u5316\u73af\u5883\u3002<\/li>\n<li><strong>\u6587\u4ef6\u7cfb\u7edf\u81ea\u7531<\/strong>\uff1a\u652f\u6301 Btrfs \u5b50\u5377\u3001LVM \u52a0\u5bc6\u7b49\u590d\u6742\u5e03\u5c40\u3002<\/li>\n<li><strong>\u7248\u672c\u7cbe\u786e\u63a7\u5236<\/strong>\uff1a\u7ed3\u5408\u5feb\u7167\u4ed3\u5e93\uff08<code>snapshot.debian.org<\/code>\uff09\u53ef\u5b89\u88c5\u4efb\u610f\u5386\u53f2\u7248\u672c\u3002<\/li>\n<\/ul>\n<blockquote>\n<p>\u6267\u884c\u524d\u52a1\u5fc5\u5907\u4efd\u6570\u636e\uff01\u5173\u952e\u64cd\u4f5c\uff08\u5982\u5206\u533a\u3001GRUB \u5b89\u88c5\uff09\u9519\u8bef\u53ef\u80fd\u5bfc\u81f4\u7cfb\u7edf\u65e0\u6cd5\u542f\u52a8\u3002<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 debootstrap \u5b89\u88c5\u65b0\u7248 Debian\uff08\u5982 Bookworm \u6216 Trixie\uff09\u662f\u4e00\u79cd\u9ad8\u6548\u7075\u6d3b\u7684 [&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-301","post","type-post","status-publish","format-standard","hentry","category-uncategorized","pmpro-has-access"],"_links":{"self":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/comments?post=301"}],"version-history":[{"count":1,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/301\/revisions"}],"predecessor-version":[{"id":302,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/posts\/301\/revisions\/302"}],"wp:attachment":[{"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/media?parent=301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/categories?post=301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ns1.koudaipc.com\/en\/wp-json\/wp\/v2\/tags?post=301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}