一、掛載並導入ISO鏡像
1.1 加載鏡像
shell> mount -t auto -o loop CentOS-6.9-x86_64-bin-DVD1.iso /mnt/
1.2 導入ISO鏡像
# --path 鏡像路徑
# --name 為安裝源定義一個名字
# --arch 指定安裝源是32位或64位,目前支持的選項有:x86 | x86_64 | ia64
# 安裝源的唯一標識就是根據name參數來定義的,本例導入成功後,標識就是CentOS-6.9-x86_64,如果重複,系統會提示導入失敗。
shell> cobbler import --path=/mnt/ --name=CentOS-6.9 --arch=x86_64
二、配置ks.cfg
2.1 查看安裝鏡像文件信息
# 在第一次導入系統鏡像後,cobbler會給鏡像指定一個默認的kickstart自動安裝文件在 /var/lib/cobbler/kickstarts下的sample_end.ks
shell> cobbler profile report --name=CentOS-6.9-x86_64
Name : CentOS-6.9-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6.9-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks
2.2 創建ks.cfg文件(節選)
shell> cat CentOS-6.9-x86_64.ks
unsupported_hardware
install
text
url --url=$tree
lang en_US.UTF-8
keyboard us
skipx
network --device em1 --bootproto dhcp --noipv6 --onboot=no --hostname XcarOS
rootpw --iscrypted $default_password_crypted
firewall --disable
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc Asia/Shanghai
firstboot --disable
%include /tmp/fdisk
reboot
%post
/bin/mv -fv /etc/udev/rules.d/70-persistent-net.rules /etc/sysconfig/network-scripts/ifcfg-em* /etc/sysconfig/network-scripts/ifcfg-p* /tmp/
/bin/cp -fv /boot/grub/grub.conf /tmp/
i=0
for IfCard in `find /tmp/ -type f -name "ifcfg-*" | sort`
do
sed "s/DEVICE=.*/DEVICE=eth${i}/g" $IfCard > /etc/sysconfig/network-scripts/ifcfg-eth${i} # device=ethX
sed -ci 's/ONBOOT=no/ONBOOT=yes/g' /etc/sysconfig/network-scripts/ifcfg-eth* # onboot=yes
#sed -i 's/\\(BOOTPROTO=\\).*/\\1static/g' /etc/sysconfig/network-scripts/ifcfg-eth* # bootproto=static
sed -ci 's/\\(BOOTPROTO=\\).*/\\1dhcp/g' /etc/sysconfig/network-scripts/ifcfg-eth* # bootproto=dhcp
echo "ARPCHECK=no" >> /etc/sysconfig/network-scripts/ifcfg-eth${i}
i=`echo $(($i+1))`
done
# disable grub:rhgb
sed -ci 's/rhgb//' /etc/grub.conf
# disable ipv6
cat << EOF >> /etc/modprobe.d/dist.conf
options ipv6 disable=1
EOF
cat << EOF >> /etc/sysconfig/network
NETWORKING_IPV6=off
EOF
2.3 編輯profile,修改關聯的ks文件
shell> cobbler profile edit --name=CentOS-6.9-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.9-x86_64.ks
2.4 再次查看安裝鏡像文件信息,kickstart的配置cfg文件地址被改變了。
shell> cobbler profile report --name=CentOS-6.9-x86_64
Name : CentOS-6.9-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6.9-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/CentOS-6.9-x86_64.ks
2.5 同步cobbler數據,每次修改完都要鏡像同步
shell> cobbler sync
原文:https://www.cnblogs.com/91donkey/p/11635868.html
閱讀更多 91donkey 的文章