在開始自定義前,需確保Cobbler服務端已正確安裝并配置。核心命令如下:
sudo apt-get update
sudo apt-get install cobbler cobbler-web dhcp3-server tftpd-hpa xinetd
安裝完成后,啟動Cobbler服務并設置開機自啟:
sudo systemctl start cobbler
sudo systemctl enable cobbler
通過cobbler check命令檢查配置問題(如未解決需按提示修復)。
Cobbler為Ubuntu提供了默認的Kickstart模板(通常位于/var/lib/cobbler/kickstarts/目錄下),以default.seed或ubuntu.seed命名??芍苯訌椭圃撃0暹M行修改:
sudo cp /var/lib/cobbler/kickstarts/default.seed /var/lib/cobbler/kickstarts/custom-ubuntu.ks
或從Ubuntu ISO中提取模板(掛載ISO后,路徑通常為/pool/main/ubuntu-installer/amd64/)。
使用文本編輯器(如vim)打開模板文件,根據需求修改以下關鍵參數:
zh_CN.UTF-8)和鍵盤布局(如us)。lang zh_CN.UTF-8
keyboard us
Asia/Shanghai)。timezone Asia/Shanghai
mkpasswd加密,如$1$abc123$xyz456)。rootpw --iscrypted $1$abc123$xyz456
autopart快速創建默認分區(適用于大多數場景)。autopart
/boot、swap、/)。part /boot --fstype=ext4 --size=500
part swap --size=2048
part / --fstype=ext4 --grow --size=1
@base組安裝核心組件,或單獨指定軟件包(如vim、openssh-server)。%packages
@base
vim
openssh-server
wget
%end
bootproto=static并提供IP、網關、DNS等信息。network --bootproto=static --ip=192.168.1.100 --netmask=255.255.255.0 --gateway=192.168.1.1 --nameserver=8.8.8.8 --hostname=my-ubuntu
bootproto=dhcp。network --bootproto=dhcp
bootloader --location=mbr
--location=esp并指定ESP分區(如--boot-drive=sda1)。bootloader --location=esp --boot-drive=sda1
更多參數可參考Cobbler官方文檔或Kickstart手冊。
使用cobbler profile edit命令將自定義Kickstart文件關聯到Cobbler配置文件(Profile):
sudo cobbler profile edit --name=my-ubuntu-profile --kickstart=/var/lib/cobbler/kickstarts/custom-ubuntu.ks
其中,my-ubuntu-profile是自定義的Profile名稱,/var/lib/cobbler/kickstarts/custom-ubuntu.ks是Kickstart文件的路徑。
修改完成后,必須同步Cobbler配置以使更改生效:
sudo cobbler sync
該命令會將Kickstart文件上傳至TFTP服務器,并更新PXE啟動菜單。
可通過以下方式驗證Kickstart文件的有效性:
cobbler validateks命令檢查文件語法。sudo cobbler validateks /var/lib/cobbler/kickstarts/custom-ubuntu.ks
my-ubuntu-profile),觀察是否按自定義配置自動安裝。mkpasswd加密(如mkpasswd -m sha-512),避免明文存儲。http://cobbler-server/cblr/svc/op/ks/profile/my-ubuntu-profile)。通過以上步驟,即可完成Ubuntu Cobbler Kickstart文件的自定義,實現自動化部署的個性化需求。