一、挂载并导入ISO镜像
shell> mount -t auto -o loop CentOS-6.9-x86_64-bin-DVD1.iso /mnt/
# --path 镜像路径
# --name 为安装源定义一个名字
# --arch 指定安装源是32位或64位,目前支持的选项有:x86 | x86_64 | ia64
# 安装源的唯一标识就是根据name参数来定义的,本例导入成功后,标识就是CentOS-6.9-x86_64,如果重复,系统会提示导入失败。
shell> cobbler import --path=/mnt/ --name=CentOS-6.9-x86_64 --arch=x86_64
二、配置ks.cfg
# 在第一次导入系统镜像后,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
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 91donkeyOS
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
shell> cobbler profile edit --name=CentOS-6.9-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.9-x86_64.ks
- 再次查看安装镜像文件信息,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
shell> cobbler sync