User Tools

Site Tools


linux:centos_redhat_kickstart

Deployment on CentOS/Redhat from ISO customized (kickstart)

CentOS and Redhat 7 and 8

You can customize the base ISO image to have a personalized installation.

Mount the DVD iso at some location:

# mount -o loop ~/Downloads/rhel-server-8.4-x86_64-dvd.iso /mnt

Then create a directory and copy all the contents of the ISO into the same.

# shopt -s dotglob
# mkdir /tmp/rhel8
# cp -avRf /mnt/* /tmp/rhel8
# cp -avRf /mnt/.discinfo /mnt/.treeinfo /tmp/rhel8

Note: All files including .<file> must also be copied, else the stage2 won't be loaded.

Copy your kickstart file into the temporary folder (name must be ks.cfg)

# cd /tmp/rhel8
# cp ~/myfiles/ks.cfg /tmp/rhel8/

Into kickstart file, do not specify url or repo section.

If you don't know how to create a kickstart file refer to examples

https://github.com/jivoi/scripts/blob/master/kickstart/ks.cfg

Or use the configurator

https://access.redhat.com/labs/kickstartconfig/

Ex:

lang en_US.UTF-8
keyboard fr_CH
#platform IBM pSeries
reboot
text
cdrom
bootloader --location=partition --append="rhgb quiet crashkernel=auto"
zerombr
clearpart --all --initlabel
autopart
auth --passalgo=sha512 --useshadow

# Network information
network  --bootproto=dhcp --device=env2 --interfacename=env2 --activate --ipv6=auto 
network  --bootproto=dhcp --device=env3 --interfacename=env3 --onboot=off --noipv6
network  --hostname=lnx100
# Root password
rootpw --iscrypted $6$c12345siBmU$fko/4zLgIGBumF8p.Jp1nndgZ0
# System authorization information
auth --passalgo=sha512 --useshadow
# SELinux configuration
selinux --disabled
firstboot --disable
# Do not configure the X Window System
skipx
# System services
services --enabled="chronyd"
services --disabled="libvirtd"
# System timezone
timezone Europe/Luxembourg --isUtc

# Disk partitioning information
ignoredisk --only-use=mpatha
clearpart --all --initlabel --drives=mpatha

part pv.590 --fstype="lvmpv" --ondisk=mpatha --size=16392 --grow
part prepboot --fstype="prepboot" --ondisk=mpatha --size=10
part /boot --fstype="xfs" --ondisk=mpatha --size=1005
volgroup rootvg --pesize=4096 pv.590
logvol / --fstype="xfs" --size=3072 --name=root --vgname=rootvg
logvol /usr --fstype="xfs" --size=3072 --name=usr --vgname=rootvg
logvol /var --fstype="xfs" --size=3072 --name=var --vgname=rootvg
logvol /tmp --fstype="xfs" --size=1024 --name=tmp --vgname=rootvg
logvol /home --fstype="xfs" --size=1024 --name=home --vgname=rootvg
logvol swap --fstype="swap" --size=2048 --name=swap --vgname=rootvg

%packages
@^custom-environment
@standard
nfs-utils
@network-tools
@backup-client
rear
%end

%post
(
set -x
echo
echo "################################"
echo "# Running Post Configuration   #"
echo "################################"

#Update system
rm -rf /var/cache/yum/timedhosts.txt
yum update -y
) > /root/post_install.log 2>&1

%end

Check the LABEL of the DVD iso.

# blkid ~/Download/rhel-server-8.4-x86_64-dvd.iso 

Add the stanza in /tmp/rhel8/isolinux/isolinux.cfg file as follows.

Make sure that the stanza has inst.stage2 and the correct label.

#######################################
label kickstart
  menu label ^Kickstart Installation of RHEL8.4
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-8.4\x20Server.x86_64 inst.ks=cdrom:/ks.cfg
#######################################

Also modify the file /tmp/rhel8/EFI/BOOT/grub.cfg as follows.

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Install Red Hat Enterprise Linux 8.4' --class fedora --class gnu-linux --class gnu --class os {
    linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=RHEL-8.4\x20Server.x86_64 inst.ks=cdrom:/ks.cfg
    initrdefi /images/pxeboot/initrd.img
}

Create the ISO file. Be careful, the label must be correct, else CD won't boot. Don't forget the dot at the end of the command

# cd /tmp/rhel8/
# mkisofs -o /tmp/rhel8test.iso -b isolinux/isolinux.bin -J -R -l -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -graft-points -V "RHEL-8.4 Server.x86_64" .

Make your ISO bootable

# isohybrid --uefi /tmp/rhel8test.iso

Note: Difference between 7 and 8

  • kickstart file
  • volume label ID
linux/centos_redhat_kickstart.txt · Last modified: 2021/08/26 16:59 by manu