以下是CentOS7的Kickstart内容。如果要改为适合CentOS6的内容,只需将keyboard项设置为"keyboard us",并修改下分区方式(如有必要的话)以及%post脚本段的内容即可。
[root@linuxidc ~]# vim /var/lib/cobbler/kickstarts/CentOS7.2.ks #version=DEVEL # System authorization information auth --enableshadow --passalgo=sha512 # Install OS instead of upgrade install # Use network installation url --url=$tree # Use text mode install text # Firewall configuration firewall --disabled firstboot --disable # ignoredisk --only-use=sda # 此项是CentOS7默认的项,但cobbler编译ks文件时不支持此语法,所以必须将此项注释掉 # Keyboard layouts # old format: keyboard us # new format: keyboard --vckeymap=us --xlayouts='us' # System language lang en_US.UTF-8 # Network information network --onboot=yes --bootproto=dhcp --device=eth0 --noipv6 network --hostname=node1.linuxidc.com # Reboot after installation reboot # Root password rootpw --iscrypted $6$KIPkwGVYqtjHln80$quxmkE5MKKA2LyzLOAc/s3FWH/jX76sObq6hqwOsEBoeMc/wIrzGG4xm72lkXwLeOfRLS/sl5vdajY9j34D4J. # SELinux configuration selinux --disabled # Do not configure the X Window System skipx # System timezone timezone Asia/Shanghai # System bootloader configuration bootloader --append="quiet crashkernel=auto" --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=250 part swap --fstype="swap" --size=2000 part / --asprimary --fstype="xfs" --grow --size=5000 # 如果是要LVM分区,则考虑以下分区 # part /boot --fstype ext4 --size=100 # part swap --fstype=swap --size=2048 # part pv26 --size=100 --grow # volgroup VG00 --pesize=32768 pv26 # logvol / --fstype ext4 --name=LVroot --vgname=VG00 --size=29984 # logvol /data --fstype ext4 --name=LVdata --vgname=VG00 --size=100 --grow %post rm -f /etc/yum.repos.d/* cat >>/etc/yum.repos.d/my.repo<<eof [base] name=sohu baseurl= gpgcheck=0 enable=1 [epel] name=epel baseurl= enable=1 gpgcheck=0 eof sed -i "s/rhgb //" /boot/grub2/grub.cfg sed -i "/UUID/d" /etc/sysconfig/network-scripts/ifcfg-eth0 echo "DNS1=114.114.114.114" >> /etc/sysconfig/network-scripts/ifcfg-eth0 echo "UseDNS no" >> /etc/ssh/sshd_config sed -i "s/GSSAPIAuthentication yes/GSSAPIAuthentication no/" /etc/ssh/ssh_config sed -i "s/^SELINUX=.*$/SELINUX=disabled/" /etc/sysconfig/selinux systemctl disable firewalld %end %packages @base @core @development @platform-devel kexec-tools lftp tree lrzsz %end %addon com_RedHat_kdump --enable --reserve-mb='auto' %end
上面的url也可以写成url --url="http://172.16.10.10/cobbler/ks_mirror/CentOS7.2/"。
1.4.3 提供profile在导入镜像生成distro的过程中,会自动生成一个profile。
[root@linuxidc cobbler]# cobbler profile list CentOS7.2-x86_64
该profile默认使用的kickstart是/var/lib/cobbler/kickstarts/sample_end.ks,所以需要修改此项。
[root@linuxidc cobbler]# cobbler profile report --name=CentOS7.2-x86_64 Name : CentOS7.2-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : CentOS7.2-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 Kickstart Metadata : {} Management Classes : [] Management Parameters : <<inherit>> Name Servers : [] Name Servers Search Path : [] Owners : ['admin'] Parent Profile : Internal proxy : Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Repos : [] Server Override : <<inherit>> Template Files : {} Virt Auto Boot : 1 Virt Bridge : xenbr0 Virt CPUs : 1 Virt Disk Driver Type : raw Virt File Size(GB) : 5 Virt Path : Virt RAM (MB) : 512 Virt Type : kvm