“Debian From Scratch”(通常简称 DFS)在开源社区里一般有两种理解:
下面我按**“从零构建一个最小 Debian 系统”的入门路径**来讲,这也是最常见、最有学习价值的方式。
入门前先问自己:
如果是前两者,继续往下看。
sudo apt install debootstrap binutils gcc make grub-pc qemu-system-x86
这是最标准、最推荐的入门方式。
mkdir -p ~/debian-root
sudo debootstrap --arch=amd64 stable ~/debian-root http://deb.debian.org/debian
这会得到一个最小 Debian 用户空间。
sudo chroot ~/debian-root
apt update
apt install vim bash-completion
passwd root
echo mydebian > /etc/hostname
apt install linux-image-amd64 grub-pc
cat > /etc/fstab <<EOF
/dev/sda1 / ext4 defaults 0 1
EOF
⚠️ 实际设备名要看你用的磁盘
常见做法:
debootstrap + qemu-img + grub-installmmdebstrap(更现代)示例(简化):
qemu-img create -f raw debian.img 2G
mkfs.ext4 debian.img
mount debian.img /mnt
debootstrap stable /mnt
grub-install --root-directory=/mnt /dev/loopX
❌ 以为 DFS = 从源码编译所有软件
✅ 实际上 Debian 的哲学是:用 Debian 的包,从零组装系统
❌ 一上来就做 ISO
✅ 先做一个能 chroot 的系统
如果你愿意,我可以:
你更想从哪一步开始?