自定义 Debian Cobbler 安装选项
一 核心思路与准备
二 创建并关联 Kickstart preseed
# 本地化
d-i debian-installer/locale string en_US.UTF-8
d-i keyboard-configuration/xkb-keymap select us
# 网络(DHCP 示例)
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string debian-host
d-i netcfg/get_domain string local
# 镜像源(使用 Cobbler 变量)
d-i mirror/country string manual
d-i mirror/http/hostname string $http_server
d-i mirror/http/directory string $tree
d-i mirror/http/proxy string
# 账户与认证
d-i passwd/root-login boolean true
d-i passwd/root-password-crypted password $6$DW7CxLkSBeC9.k.k3$S8G9s3/Y5LJ4dio....S5GS78p2laxALxaJ.lCN9tzKB1zIpYz38Fs9/
d-i passwd/make-user boolean false
# 时钟与时区
d-i clock-setup/utc boolean true
d-i time/zone string UTC
# 分区(示例:全盘清空后 LVM)
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-auto/choose_recipe select atomic
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
# 包选择(最小化 + 常用工具)
tasksel tasksel/first multiselect standard, ssh-server
d-i pkgsel/include string vim htop curl
# 引导加载器
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
# 完成安装后动作
d-i finish-install/reboot_in_progress note
三 导入镜像并绑定安装选项
sudo cobbler import --path=/tmp/debian-12.0.0-amd64/ --name=debian-12-amd64 --arch=amd64
sudo cobbler profile edit \
--name=debian-12-amd64 \
--kickstart=/var/lib/cobbler/kickstarts/debian-12.seed \
--kopts="netcfg/choose_interface=auto"
sudo cobbler distro add \
--name=debian-12-amd64 \
--arch=amd64 \
--kernel=/var/www/cobbler/ks_mirror/debian-12-amd64/install.amd/vmlinuz \
--initrd=/var/www/cobbler/ks_mirror/debian-12-amd64/install.amd/initrd.gz
sudo cobbler profile add \
--name=debian-12-custom \
--distro=debian-12-amd64 \
--kickstart=/var/lib/cobbler/kickstarts/debian-12.seed
sudo cobbler system add \
--name=host01 \
--profile=debian-12-custom \
--mac=00:11:22:33:44:55 \
--ip=192.168.1.100 \
--subnet=255.255.255.0 \
--gateway=192.168.1.1 \
--hostname=host01.local \
--interface=eth0 \
--bootproto=static
sudo cobbler check
sudo cobbler sync
四 网络引导与 DHCP 模板
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
filename "pxelinux.0";
next-server 192.168.1.2; # Cobbler 服务器 IP
}
sudo cobbler sync
sudo systemctl restart isc-dhcp-server # 或 dnsmasq,取决于你的选择
五 常用自定义场景与排错