温馨提示×

ubuntu fromscratch需啥工具

小樊
44
2026-09-07 12:43:41
栏目: 智能运维

“Ubuntu From Scratch”(或者更广义的“从零构建 Ubuntu / Linux 系统”)并不是像 LFS(Linux From Scratch) 那样有一个官方统一书名,但通常指:不装官方 ISO,而是用 debootstrap / 自己拼 rootfs 的方式构建一个 Ubuntu 系统

下面按“用 Ubuntu 官方工具从零做一个 Ubuntu rootfs”来说明需要什么。


一、核心工具(必须)

1. 宿主机系统

  • 一个已运行的 Linux(推荐 Ubuntu / Debian)
  • 架构一致或支持交叉(amd64 / arm64 等)

2. debootstrap

最关键的工具,用来拉取 Ubuntu 基础包:

sudo apt install debootstrap

示例:

debootstrap noble /mnt/ubuntu http://archive.ubuntu.com/ubuntu

3. chroot / systemd-nspawn

进入并配置新系统:

sudo chroot /mnt/ubuntu
# 或
systemd-nspawn -D /mnt/ubuntu

4. 内核(重要)

Ubuntu From Scratch 不包含内核,你需要:

  • 用 Ubuntu 内核包:
    apt install linux-image-generic
    
  • 或自己编译内核

二、辅助工具(通常都需要)

5. 分区 & 文件系统

fdisk / gdisk / parted
mkfs.ext4
mount

6. Bootloader

  • grub / grub2
apt install grub-pc  # BIOS
apt install grub-efi # UEFI

7. 网络配置

  • netplan
  • systemd-networkd
  • NetworkManager

8. 基础系统组件

apt install systemd sudo nano vim bash

三、如果你想“完全从源码”(像 LFS)

那就不是 Ubuntu 了,而是 类 Ubuntu 的发行版,需要:

  • gcc, make, binutils
  • glibc
  • busyboxcoreutils
  • 自己打包 .deb 或不用 deb

⚠️ 这已经偏离“Ubuntu From Scratch”的通常含义。


四、最简流程示例(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

如果你愿意,我可以:

  • 给你 一步一步 Ubuntu From Scratch 教程
  • 或针对 ARM / 树莓派 / 容器 rootfs 给方案

0