在上面的实验中,咱们没有进行任何的安装配置,所有都是Cobbler帮助咱们完成的。但是在实际生产中,咱们对每台主机的硬盘分区,安装的软件都有相应的要求,因此咱们须要本身来定制KickStart文件,这样咱们就可以定制地批量安装操做系统了。
咱们就利用实验环境(CentOS 7)中的KickStart文件来定制咱们本身的KickStart文件。node
Cobbler的ks文件存放位置linux
/var/lib/cobbler/kickstarts/ ios
配置ks的方法redis
方法一、 每安装好一台Centos机器,Centos安装程序都会建立一个kickstart配置文件,记录你的真实安装配置。若是你但愿实现和某系统相似的安装,能够基于该系统的kickstart配置文件来生成你本身的kickstart配置文件。(生成的文件名字叫anaconda-ks.cfg位于/root/anaconda-ks.cfg)
方法二、Centos提供了一个图形化的kickstart配置工具。在任何一个安装好的Linux系统上运行该工具,就能够很容易地建立你本身的kickstart配置文件。kickstart配置工具命令为redhat-config-kickstart(RHEL3)或system-config-kickstart(RHEL5/6/7)
方法三、按照格式自定义一个.cfg文件(方法1不可用的状况下)centos
ks文件说明服务器
kickstart文件是一个简单的文本文件,它包含了一个项目列表,每一个项目由一个关键字来识别。网络
firewall(可选)app
这个选项对应安装程序里的「防火墙配置」屏幕: firewall –enabled|–disabled [–trust=] [–port=]
graphical(可选)ide
在图形模式下执行kickstart安装.kickstart安装默认在图形模式下安装.text文本安装。
network(可选)工具
为系统配置网络信息.若是 kickstart安装不要求联网(换句话说,不从NFS,HTTP或FTP安装),就不须要为系统配置网络.若是安装要求联网而kickstart文件 里没有提供网络信息,安装程序会假定从eth0经过动态IP地址(BOOTP/DHCP)来安装,并配置安装完的系统动态决定IP地址.network选 项为经过网络的kickstart安装以及所安装的系统配置联网信息. –ip=,要安装的机器的IP地址. –gateway=,IP地址格式的默认网关. –nameserver=,主名称服务器,IP地址格式. –nodns,不要配置任何 DNS 服务器. –netmask=,安装的系统的子网掩码. –hostname=,安装的系统的主机名. –ethtool=,指定传给ethtool程序的网络设备的其余底层设置. –essid=,无线网络的网络ID. –wepkey=,无线网络的加密密钥. –onboot=,是否在引导时启用该设备. –class=,DHCP类型. –mtu=,该设备的MTU. –noipv4=,禁用此设备的IPv4. –noipv6=,禁用此设备的IPv6
multipath(可选)
multipath –name= –device= –rule=part或partition(对于安装是必需的,升级可忽略). 在系统上建立分区. 若是不一样分区里有多个红帽企业Linux系统,安装程序会提示用户升级哪一个系统. 注意:做为安装过程的一部分,全部被建立的分区都会被格式化,除非使用了–noformat和–onpart.,若是是分区的挂载点,它必须是下列形式中的一种: / ,例如,/,/usr,/home swap,该分区被用做交换空间,要自动决定交换分区的大小,使用–recommended选项. swap –recommended 自动生成的交换分区的最小值大于系统内存的数量,但小于系统内存的两倍. raid. ,该分区用于 software RAID(参考 raid). pv. ,该分区用于 LVM(参考 logvol). –size=,以MB为单位的分区最小值.在此处指定一个整数值,如500.不要在数字后面加MB. –grow,告诉分区使用全部可用空间(如有),或使用设置的最大值. –maxsize=,当分区被设置为可扩充时,以MB为单位的分区最大值.在这里指定一个整数值,不要在数字后加MB. –noformat,用–onpart命令来告诉安装程序不要格式化分区. –onpart=或–usepart=,把分区放在已存在的设备上. 例如:partition /home –onpart=hda1,把/home置于必须已经存在的/dev/hda1上. –ondisk=或–ondrive=,强迫分区在指定磁盘上建立. 例如:–ondisk=sdb把分区置于系统的第二个SCSI磁盘上. –asprimary,强迫把分区分配为主分区,不然提示分区失败. –type=(用fstype代替),这个选项再也不可用了.应该使用fstype. –fstype=,为分区设置文件系统类型.有效的类型为ext2,ext3,swap和vfat. –start=,指定分区的起始柱面,它要求用–ondisk=或ondrive=指定驱动器.它也要求用–end=指定结束柱面或用 –size=指定分区大小. –end=,指定分区的结束柱面.它要求用–start=指定起始柱面. –bytes-per-inode=,指定此分区上建立的文件系统的节点大小.不是全部的文件系统都支持这个选项,因此在其余状况下它都被忽略. –recommended,自动决定分区的大小. –onbiosdisk,强迫在 BIOS 找到的特定磁盘上建立分区. 注:若是由于某种缘由分区失败了,虚拟终端3上会显示诊断信息
定义安装的包:
%packages (xxx) %end
定义安装后执行的命令或脚本:
%post (xxx) %end
ks文件示例
centos7
cat /var/lib/cobbler/kickstarts/centos7.cfg
#platform=x86, AMD64, or Intel EM64T #version=DEVEL # Install OS instead of upgrade install # Keyboard layouts # old format: keyboard us # new format: keyboard --vckeymap=us --xlayouts='us' # Root password rootpw --iscrypted $1$1qaz!QAZ$L4d6kVwN3toE.0oAS.dQ31 # Use network installation url --url="http://192.168.42.128/cobbler/ks_mirror/CentOS-7-x86_64_new-x86_64/" # System language lang en_US.UTF-8 # Firewall configuration firewall --disabled # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install #graphical reboot text # Run the Setup Agent on first boot firstboot --enable # SELinux configuration selinux --disabled # Do not configure the X Window System skipx # System services services --disabled="chronyd" ignoredisk --only-use=sda # Network information network --bootproto=dhcp --device=eth0 --onboot=on # Reboot after installation reboot # System timezone timezone Asia/Shanghai # System bootloader configuration bootloader --location=mbr --boot-drive=sda # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --asprimary --fstype="xfs" --size=1024 part swap --fstype="swap" --size=2048 part / --fstype="xfs" --grow --size=1 %packages @^minimal @core %end %post cat >/etc/profile<<EOF HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S `whoami` " ulimit -n 65536 EOF cat >/etc/security/limits.conf<<EOF * soft nofile = 65536 * hard nofile = 65536 root soft nofile 65536 root hard nofile 65536 EOF hwclock -w %end
centos6.8
#platform=x86, AMD64, or Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use network installation url --url="http://192.168.137.38/cobbler/ks_mirror/CentOS-6.8-x86_64/" #repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100 # Root password rootpw --iscrypted $1$ljohn$yBMDpKkntQ9jfV1ZAWKpU1 # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install graphical # System keyboard keyboard us # System language lang en_US.UTF-8 # SELinux configuration selinux --disabled # Do not configure the X Window System skipx # Installation logging level #logging --level=info # Reboot after installation reboot # System timezone timezone Asia/Shanghai # Network information network --bootproto=dhcp --device=eth0 --onboot=on #network --bootproto=dhcp --device=eth1 --onboot=on # System bootloader configuration bootloader --append="crashkernel=auto rhgb quiet" --location=mbr --driveorder="sda" # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --asprimary --fstype="ext4" --size=500 part swap --fstype="swap" --size=2048 part / --fstype="ext4" --grow --size=1 %packages --nobase @core %end
在Cobbler 自动建立了yum源以后,会自动有一个ks文件与该源相对应。如今咱们须要将本身制做的KS文件与原有的yum源进行关联。
# --name 咱们须要添加的启动菜单的名字 # --distro 咱们自定制的ks文件关联的yum库 # --kickstart 咱们自定制的ks文件的路径
[root@localhost kickstarts]#cobbler profile add --name=centos7-x86_64-new --distro=centos7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.cfg
查看Cobbler中如今还有多少个启动项
[root@localhost kickstarts]#cobbler profile list centos6.9-x86_64 centos7-x86_64 centos7-x86_64-new
每次对cobbler更改都要执行同步
#cobbler sync