自定义 Cobbler 安装模板的完整流程
一 核心概念与模板类型
二 操作步骤
三 常用模板示例
Kickstart 模板片段(自定义分区、包组与 %post)
# System authorization
auth --useshadow --passalgo=sha512
# Root password(请替换为你的加密串)
rootpw --iscrypted $1$random$sFftrCTxKKsDZ.Sdr8mDG0
# Firewall and SELinux
firewall --disabled
selinux --permissive
# Network (示例 DHCP)
network --bootproto=dhcp --device=eth0 --onboot=yes
# Repo(可选,使用 Cobbler 管理的源)
repo --name=base --baseurl=$tree
# Keyboard and timezone
keyboard us
timezone Asia/Shanghai --isUtc
# Bootloader
bootloader --location=mbr --boot-drive=sda
zerombr
clearpart --all --initlabel
# Partitioning
part /boot --fstype=xfs --size=1024
part swap --fstype=swap --size=2048
part / --fstype=xfs --grow --size=1
%packages
@^minimal
@core
vim
wget
%end
%post
# 示例:设置历史命令时间格式
cat >>/etc/profile <<'EOF'
HISTTIMEFORMAT="%F %T \u@\h:\w\$ "
EOF
# 示例:调整文件句柄
cat >>/etc/security/limits.conf <<'EOF'
* soft nofile 65536
* hard nofile 65536
root soft nofile 65536
root hard nofile 65536
EOF
%end
要点:分区前先 clearpart,包组以 @ 开头,%post 用于初始化系统与合规配置。
PXE 菜单模板片段(自定义标题与默认项)
DEFAULT menu
PROMPT 0
MENU TITLE Cobbler Custom Installer
TIMEOUT 200
TOTALTIMEOUT 6000
ONTIMEOUT $pxe_timeout_profile
LABEL local
MENU LABEL (local)
LOCALBOOT -1
$pxe_menu_items
MENU END
修改后执行 cobbler sync 使菜单生效。
四 变量与高级定制