温馨提示×

debian cobbler怎么用

小樊
49
2026-10-24 08:24:51
栏目: 智能运维

下面给你一个从零到可用的 Debian + Cobbler 自动化装机实战指南,偏“怎么用”,不堆概念。


一、Cobbler 是什么(一句话)

Cobbler 是一个 Linux 批量装机/PXE 管理工具,帮你统一管理:

  • DHCP / TFTP / PXE
  • 系统镜像(ISO)
  • Kickstart / Preseed(自动应答)
  • 多系统、多主机批量部署

Debian 上 Cobbler 官方支持,但默认用 preseed(不是 kickstart)。


二、环境准备

1. 系统要求

  • Debian 11 / 12(推荐)
  • 静态 IP
  • 关闭冲突服务(dnsmasq 等)

2. 安装 Cobbler

apt update
apt install cobbler cobbler-web

安装后关键目录:

/etc/cobbler/
/var/lib/cobbler/
/var/www/cobbler/

三、基础配置

1. 修改 cobbler 设置

编辑:

vim /etc/cobbler/settings.yaml

重点:

server: 192.168.1.10
next_server: 192.168.1.10
manage_dhcp: true

2. 启动服务

systemctl enable --now cobblerd
systemctl enable --now apache2

3. 检查配置

cobbler check

按提示修复(通常是权限、SELinux、DHCP 模板)


四、配置 DHCP(Cobbler 托管)

编辑:

vim /etc/cobbler/dhcp.template

示例:

subnet 192.168.1.0 netmask 255.255.255.0 {
     option routers 192.168.1.1;
     option domain-name-servers 8.8.8.8;
     range 192.168.1.100 192.168.1.200;
}

同步:

cobbler sync

五、导入 Debian 镜像

1. 挂载 ISO

mount -o loop debian-12.iso /mnt

2. 导入

cobbler import --path=/mnt --name=debian12 --arch=amd64

查看:

cobbler distro list

六、Debian 自动安装(preseed)

1. 创建 preseed

vim /var/lib/cobbler/templates/debian12.preseed

最小示例:

d-i debian-installer/locale string en_US
d-i keyboard-configuration/xkb-keymap select us
d-i mirror/country string manual
d-i mirror/http/hostname string ftp.debian.org
d-i passwd/root-password password rootpwd
d-i passwd/root-password-again password rootpwd
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select atomic

2. 绑定 profile

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

七、添加装机主机(可选)

cobbler system add --name=node01 \
--profile=debian12-x86_64 \
--mac=00:11:22:33:44:55 \
--ip-address=192.168.1.101

八、开始 PXE 装机

  1. 客户端:
    • BIOS 设置为 PXE Boot
  2. 启动后:
    • 自动进入 Cobbler 菜单
    • 选择 Debian
    • 自动 preseed 安装

九、Web 界面(可选)

http://192.168.1.10/cobbler_web

默认账号:

cobbler / cobbler

十、常用命令速查

cobbler distro list
cobbler profile list
cobbler sync
cobbler system list
cobbler repo add

十一、常见坑

❌ Debian 用 kickstart → 必须用 preseed
❌ DHCP 冲突 → 关掉系统 dnsmasq
❌ 装机卡住 → 看 /var/log/cobbler/


如果你愿意,我可以:

  • 给你一个 完整 Debian preseed
  • 教你 Cobbler + UEFI
  • 或 Cobbler 批量装 100 台

你现在是 测试环境还是生产?

0 踩