温馨提示×

如何导入debian到cobbler

小樊
48
2026-10-03 19:30:03
栏目: 智能运维

下面按常见场景说明如何把 Debian 系统导入 Cobbler(用于自动化安装)。


一、前提条件

  • 已安装并运行 Cobbler(2.x 或 3.x)
  • 能访问 Debian 安装源(ISO 或网络镜像)
  • root 或 sudo 权限

二、准备 Debian 安装源

方式 1:使用 Debian ISO

mkdir -p /mnt/debian-iso
mount -o loop debian-12.0.0-amd64-DVD-1.iso /mnt/debian-iso

方式 2:使用网络镜像(推荐)

mkdir -p /var/www/cobbler/debian
debootstrap bookworm /var/www/cobbler/debian http://deb.debian.org/debian

三、导入 Distro 到 Cobbler

1️⃣ 导入 ISO 内容

cobbler import \
  --path=/mnt/debian-iso \
  --name=debian12 \
  --arch=x86_64

Cobbler 会自动:

  • 识别 linux / initrd.gz
  • 创建 distro
  • 创建默认 profile

四、确认导入结果

cobbler distro list
cobbler profile list

示例输出:

debian12-x86_64
debian12-x86_64

五、配置网络安装(PXE)

1️⃣ 配置 DHCP(Cobbler 管理)

cobbler setting edit --name=manage_dhcp --value=1
cobbler sync

2️⃣ 确保 TFTP / HTTP 正常

systemctl enable --now tftp
systemctl enable --now httpd   # 或 nginx

六、使用 Preseed 实现自动安装(关键)

Debian 使用 preseed,不是 Kickstart。

1️⃣ 创建 preseed 文件

/var/lib/cobbler/kickstarts/debian.preseed

示例:

d-i debian-installer/locale string en_US
d-i keyboard-configuration/xkb-keymap select us
d-i netcfg/get_hostname string debian-client
d-i mirror/country string manual
d-i mirror/http/hostname string deb.debian.org
d-i mirror/http/directory string /debian
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select atomic

d-i passwd/root-password password cobbler
d-i passwd/root-password-again password cobbler
d-i passwd/user-fullname string cobbler
d-i passwd/username string cobbler
d-i passwd/user-password password cobbler
d-i passwd/user-password-again password cobbler

d-i pkgsel/include string openssh-server vim
d-i finish-install/reboot_in_progress note

2️⃣ 绑定 preseed 到 profile

cobbler profile edit \
  --name=debian12-x86_64 \
  --kickstart=/var/lib/cobbler/kickstarts/debian.preseed

七、添加内核参数(非常重要)

Debian 需要告知安装器使用 preseed:

cobbler profile edit \
  --name=debian12-x86_64 \
  --kopts="auto=true priority=critical url=http://<cobbler_ip>/cobbler/ks_mirror/debian12/preseed/debian.preseed"

或通过 Web UI 配置。


八、同步并测试

cobbler sync

从客户端:

  • 网络启动(PXE)
  • 自动进入 Debian 安装
  • 无需人工干预

九、常见问题

❌ Cobbler 不识别 Debian

  • 确保 ISO 包含 install.amd 或 install.386
  • 使用 DVD 而非 netinst

❌ preseed 不生效

  • auto=true priority=critical 必须加
  • URL 必须可访问

十、总结流程

ISO / Mirror
   ↓
cobbler import
   ↓
profile
   ↓
preseed
   ↓
PXE 自动安装

如果你愿意,我可以:

  • 给你 完整 Debian 12 preseed
  • 帮你 对接 UEFI / Legacy
  • 或写 Cobbler + Debian + Cloud-init 方案

0 踩