在 Debian 上使用 Cobbler 进行“同步”(sync),通常指的是把你在 Cobbler 中配置的 distro / profile / system / repo / kickstart 等,真正写入到 DHCP / TFTP / PXE / DNS 等服务的配置中,并让客户端可以网络引导安装。
下面按常见使用场景说明。
最常用、最关键的同步命令:
cobbler sync
作用:
pxelinux.cfgmanage_dhcp)manage_dns)✅ 每次修改 Cobbler 配置后,都应执行一次 cobbler sync
sudo apt update
sudo apt install cobbler cobbler-web
相关服务:
systemctl status cobblerd
systemctl status tftpd-hpa
systemctl status apache2
例如挂载 ISO:
mount -o loop debian-12-netinst.iso /mnt
导入:
cobbler import \
--path=/mnt \
--name=debian12 \
--arch=amd64
查看:
cobbler distro list
cobbler profile list
编辑:
/etc/cobbler/settings.yaml
(旧版是 settings)
manage_dhcp: true
示例 DHCP 模板:
/etc/cobbler/dhcp.template
然后:
cobbler sync
Cobbler 会自动生成:
/var/lib/tftpboot/pxelinux.cfg/default
/etc/dhcp/dhcpd.conf
Debian 默认用 tftpd-hpa:
systemctl enable --now tftpd-hpa
TFTP 根目录:
/var/lib/tftpboot
Cobbler 的 repo sync 和 cobbler sync 不是一回事。
cobbler repo add \
--name=debian12-main \
--apt-mirror=http://deb.debian.org/debian \
--arch=amd64 \
--breed=apt
同步仓库(真正下载):
cobbler reposync
⚠️ 这可能需要很长时间,取决于带宽和仓库大小。
cobbler profile edit \
--name=debian12-x86_64 \
--kickstart=/var/lib/cobbler/kickstarts/debian.preseed
cobbler system add \
--name=node01 \
--mac=52:54:00:11:22:33 \
--profile=debian12-x86_64
然后:
cobbler sync
PXE 菜单和 DHCP 就会包含这台机器。
✅ 忘记 cobbler sync
检查:
/var/lib/tftpboot/pxelinux.0
/var/lib/tftpboot/pxelinux.cfg/default
确认:
manage_dhcp: true
cobbler sync
systemctl restart isc-dhcp-server
Web 只是写数据库,必须 CLI 执行:
cobbler sync
# 1. 导入系统
cobbler import --path=/mnt --name=debian12 --arch=amd64
# 2. 添加 repo
cobbler repo add --name=debian12-main \
--apt-mirror=http://deb.debian.org/debian \
--breed=apt
# 3. 同步 repo
cobbler reposync
# 4. 添加主机
cobbler system add --name=node01 \
--mac=52:54:00:11:22:33 \
--profile=debian12-x86_64
# 5. 同步配置
cobbler sync
如果你能补充说明:
cobbler-web我可以给你更精确的配置示例。