Differences

This shows you the differences between two versions of the page.


centos_kickstart [2021/08/09 07:40] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== CentOS Kickstart ======
  
 +  * [[CentOS]]
 +  * [[CentOS Xen]]
 +
 +  * [[https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Installation_Guide/ch-kickstart2.html|Kickstart Installations]]
 +
 +=== Introduction ===
 +
 +This guide is very similar in style to the [[Ubuntu autoinstall]] guide, in the sense that it makes a file to pre-define certain things. It is not as extensive as the other one, though, in modifying the ISOLINUX config files and so on.
 +
 +When creating a Kickstart file, here are some simple things to know.
 +
 +When the OS boots with the kickstarter, the install will fail on any mis-configured or unknown options. That makes testing a bit of a pain if you're creating one from scratch. It's not impossible to do that, but if you want to, you can create one more easily using the kickstarter GUI application that ships with CentOS. You'd have to install it first before using it:
 +
 +<code>
 +yum install system-config-kickstart
 +system-config-kickstart
 +</code>
 +
 +=== Download ISO ===
 +
 +The first thing to do is download the CentOS ISO you'd like to install. In this example, I'm using CentOS 6.6 (which is rather old). The kickstart file should work with newer installs as well.
 +
 +<code>
 +wget http://archive.kernel.org/centos-vault/6.6/isos/x86_64/CentOS-6.6-x86_64-minimal.iso
 +</code>
 +
 +=== Sample Kicsktarter File ===
 +
 +Here's a file I make to go through a quick text install. When finished, the file is saved as ''ks.cfg'' and needs to go into the ''ISOLINUX'' directory on the ISO.
 +
 +Do a text installation, and use the contents from the ISO:
 +
 +<code>
 +install
 +cdrom
 +text
 +skipx
 +</code>
 +
 +Use locale settings:
 +
 +<code>
 +keyboard us
 +lang en_US
 +</code>
 +
 +As well as timezone:
 +
 +<code>
 +timezone --isUtc America/Denver
 +</code>
 +
 +I prefer to disable the firewall:
 +
 +<code>
 +firewall --disabled
 +</code>
 +
 +As well as SELinux:
 +
 +<code>
 +selinux --disabled
 +</code>
 +
 +Use shadow authentication for the passwords (which is the default on a system anyway):
 +
 +<code>
 +auth --useshadow
 +</code>
 +
 +Create a generic user with password ''insecure'':
 +
 +<code>
 +user --name=centos --groups=wheel --password=insecure --shell=/bin/bash
 +</code>
 +
 +Set the root password to ''insecure'' as well:
 +
 +<code>
 +rootpw insecure
 +</code>
 +
 +Shut down the system when all is finished:
 +
 +<code>
 +poweroff
 +</code>
 +
 +=== Partitioning ===
 +
 +Setting up the partitions is a tricky step, so refer to the documentation (or even better, the GUI) to set exactly what you want.
 +
 +In this configuration, here's step by step what is happening.
 +
 +The original bootloader is eradicated:
 +
 +<code>
 +zerombr
 +</code>
 +
 +The new bootloader is installed in the MBR:
 +
 +<code>
 +bootloader --location=mbr
 +</code>
 +
 +All existing partitions are removed:
 +
 +<code>
 +clearpart --all --initlabel
 +</code>
 +
 +Create a ''/boot'' partition, ''ext2'' filesytem, 256 MB:
 +
 +<code>
 +part /boot --fstype=ext3 --size=256
 +</code>
 +
 +Create a swap partition, letting CentOS set the size:
 +
 +<code>
 +part swap --fstype=swap --recommended
 +</code>
 +
 +Create an ext4 filesystem for ''/'', using the remaining space on the partition:
 +
 +<code>
 +part / --fstype=ext4 --grow --size=1
 +</code>
 +
 +=== Packages ===
 +
 +At the end of the kickstarter file, you can add some specific packages you'd like installed along with the base system. By default there's quite a lot, but you may want to add more, based on the ISO you're using to install it.
 +
 +You can display the packages that are available by mounting the ISO and looking int the ''Packages'' directory.
 +
 +Add the list to the kickstarter file. Ignore missing ones just in case, so the install will continue if there's not one installing. This is just using ''dhclient'' as //an example//.
 +
 +<code>
 +%packages --ignoremissing
 +dhclient
 +</code>
 +
 +Some additional packages:
 +
 +<code>
 +@ base
 +@ core
 +coreutils
 +yum
 +rpm
 +e2fsprogs
 +openssh-server
 +openssh-clients
 +dhclient
 +</code>
 +
 +=== Creating the ISO ===
 +
 +Mount the original ISO, and copy its contents somewhere else:
 +
 +<code>
 +mkdir /tmp/source-iso
 +mkdir /tmp/target-iso
 +mount -o loop,ro centos.iso /tmp/source-iso
 +cp -r /tmp/source-iso/* /tmp/target-iso/
 +</code>
 +
 +The original ISO won't be needed any more, so it can be unmounted if you feel like it:
 +
 +<code>
 +umount /tmp/source-iso
 +</code>
 +
 +Once you've created the kickstarter config file, save it as ''ks.cfg'' and copy it into the ISOLINUX directory:
 +
 +<code>
 +cp ks.cfg /tmp/source-iso/isolinux
 +</code>
 +
 +Update the ISOLINUX config file to tell it where the kickstarter config file is. Edit the file ''/tmp/source-iso/isolinux/isolinx.cfg''
 +
 +Update the first ''append initrd'' entry to point to the ''ks.cfg'' file:
 +
 +<code>
 +append initrd=initrd.img ks=cdrom:/ks.cfg
 +</code>
 +
 +Finally, build the new bootable ISO with the config file:
 +
 +<code>
 +cd /tmp/target-iso
 +mkisofs -o /tmp/centos-kickstart.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T isolinux/. .
 +</code>
 +
 +And boot the ISO as normal. You've got an automated install!

Navigation
QR Code
QR Code centos_kickstart (generated for current page)