“Ubuntu From Scratch”(或者更广义的“从零构建 Ubuntu / Linux 系统”)并不是像 LFS(Linux From Scratch) 那样有一个官方统一书名,但通常指:不装官方 ISO,而是用 debootstrap / 自己拼 rootfs 的方式构建一个 Ubuntu 系统。
下面按“用 Ubuntu 官方工具从零做一个 Ubuntu rootfs”来说明需要什么。
debootstrap最关键的工具,用来拉取 Ubuntu 基础包:
sudo apt install debootstrap
示例:
debootstrap noble /mnt/ubuntu http://archive.ubuntu.com/ubuntu
chroot / systemd-nspawn进入并配置新系统:
sudo chroot /mnt/ubuntu
# 或
systemd-nspawn -D /mnt/ubuntu
Ubuntu From Scratch 不包含内核,你需要:
apt install linux-image-generic
fdisk / gdisk / parted
mkfs.ext4
mount
grub / grub2apt install grub-pc # BIOS
apt install grub-efi # UEFI
netplansystemd-networkdNetworkManagerapt install systemd sudo nano vim bash
那就不是 Ubuntu 了,而是 类 Ubuntu 的发行版,需要:
gcc, make, binutilsglibcbusybox 或 coreutils.deb 或不用 deb⚠️ 这已经偏离“Ubuntu From Scratch”的通常含义。
# 1. 建目录
mkdir /mnt/ubuntu
# 2. 拉基础系统
debootstrap noble /mnt/ubuntu
# 3. 进系统
chroot /mnt/ubuntu
# 4. 装内核和引导
apt update
apt install linux-image-generic grub-pc
# 5. 配置后退出,装引导
grub-install /dev/sdX
Ubuntu From Scratch 核心只需:
debootstrap + chroot + 内核 + grub
如果你愿意,我可以: