In the above experiment, we did not do any installation configuration, all with the help of Cobbler.However, in practice, we have corresponding requirements for each host's hard disk partition and installed software, so we need to customize the KickStart file by ourselves so that we can customize the mass installation of the operating system.
We customize our own KickStart files using the KickStart files in the Experimental Environment (CentOS 7).
1. Configuration ks file
Location where Cobbler's ks files are stored
/var/lib/cobbler/kickstarts/
Methods of configuring ks
Method 1. For each Centos machine installed, the Centos Installer will create a kickstart profile to record your actual installation configuration.If you want to install something similar to a system, you can generate your own kickstart profile based on that system's kickstart profile.(The generated file name is anaconda-ks.cfg at/root/anaconda-ks.cfg)
Method 2. Centos provides a graphical kickstart configuration tool.Running this tool on any installed Linux system makes it easy to create your own kickstart profile.The kickstart configuration tool command is redhat-config-kickstart (RHEL3) or system-config-kickstart (RHEL5/6/7)
Method 3. Customize a.cfg file by format (if method 1 is not available)
ks file description
The kickstart file is a simple text file that contains a list of items, each identified by a keyword.
Firewall (optional)
This option corresponds to the Firewall Configuration screen in Setup: firewall –enabled|–disabled [–trust=] [–port=]
Graphical (optional)
Perform a kickstart installation in graphical mode.kickstart installation Default is to install.Text text installation in graphical mode.
Network (optional)
Configure network information for your system.If the kickstart installation does not require networking (in other words, not from NFS,HTTP, or FTP), you do not need to configure the network for your system.If the installation requires networking and no network information is provided in the kickstart file, the setup will assume that it is installed from eth0 through a dynamic IP address (BOOTP/DHCP).Configure the installed system to dynamically determine the IP address. The network option configures networking information for both the kickstart installation over the network and the installed system. - ip=, the IP address of the machine to be installed. - gateway=, default gateway in IP address format. - nameserver=, primary name server, IP address format. - nodns, do not configure any DNS servers. - netmask=, the subnet mask of the installed system. - hostname=, the host name of the installed system. - ethtool=, specifies other underlying settings for the network device passed to the ethtool program. - essid=, the network ID of the wireless network. - wepkey=, the encryption key for wireless networks. - onboot=, whether to enable the device at boot time. - class=,DHCP type. - mtu=, MTU of the device. - noipv4=, disable IPv4 for this device. - noipv6=, disable IPv6 for this device
Multipath (optional)
multipath-name=-device=-rule=part or partition (which is required for installation and negligible for upgrade). Create partitions on the system. If there are multiple Red Hat Enterprise Linux systems in different partitions, the installer will prompt the user to upgrade which system. Note: As part of the installation process, all created partitions will be formatted unless noformat and onpart. are used. If a partition's mount point is used, it must be one of the following: / For example, /, /usr,/home Swap, which is used as swap space. To automatically determine the size of the swap partition, use the -recommended option. swap –recommended The minimum value of automatically generated swap partitions is greater than the amount of system memory, but less than twice the amount of system memory. Raid. This partition is used for software RAID (reference raid). pv. This partition is for LVM (reference logvol). - size=, the minimum partition size in MB. Specify an integer value here, such as 500. Do not add MB after the number. - grow, tells the partition to use all available space (if any), or the maximum value set. - maxsize=, the maximum value of a partition in MB when the partition is set to be expandable. Specify an integer value here, and do not add MB after the number. - noformat, use the -onpart command to tell the installer not to format partitions. - onpart=or -usepart=, place the partition on an existing device. For example: partition/home-onpart=hda1, place/home on/dev/hda1 that must already exist. - ondisk=or -ondrive=, forcing the partition to be created on the specified disk. For example: -ondisk=sdb places the partition on the second SCSI disk of the system. - asprimary, force the partition to be assigned as the primary partition, otherwise the partition will fail. - type= (replaced by fstype), this option is no longer available. fstype should be used. - fstype=, set the file system type for the partition. Valid types are ext2,ext3,swap, and vfat. - start=, specifies the starting cylinder of the partition, which requires a drive to be specified with -ondisk=or ondrive=It also requires an end cylinder to be specified with -end=or a partition size to be specified with -size= - end=, specifies the end cylindrical surface of the partition. It requires the start cylindrical surface to be specified with -start=. - bytes-per-inode=, specifies the node size of the file system created on this partition. Not all file systems support this option, so it is ignored in other cases. - recommended, automatically determines the size of the partition. - onbiosdisk, forcing partitions to be created on specific disks found by BIOS. Note: If partition fails for some reason, diagnostic information will be displayed on Virtual Terminal 3
Define installed packages:
%packages (xxx) %end
Define commands or scripts to execute after installation:
%post (xxx) %end
Sample ks file
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
2. Associate KickStart file with yum source
After Cobbler automatically creates the yum source, a KS file automatically corresponds to the source.Now we need to associate the KS file we made with the original Yum source.
#--name The name of the Startup menu we need to add #--distro The yum library associated with our custom ks file #--kickstart Path to our custom ks file
[root@localhost kickstarts]#cobbler profile add --name=centos7-x86_64-new --distro=centos7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.cfg
See how many startup items are still in Cobbler
[root@localhost kickstarts]#cobbler profile list centos6.9-x86_64 centos7-x86_64 centos7-x86_64-new
3. Synchronization
Synchronize every cobbler change
#cobbler sync