Nov 30, 2009

RHEL & CentOS automatic install Kickstart


I use Kickstart in order to install automatically RHEL (3, 4, 5, 32 or 64 bit) and CentOS from an image shared on the network (NFS).

You can completely automatize the method I describe by adding a DHCP/BOOTP server on which you install a boot image. I do not use that because of already having several networks, all with their own DHCP. I use a bootable image of RHEL and then start with this line on the GRUB :

linux ks=nfs:192.168.xx.xx:/path/to/your/kickstart
The advantages of this method are :

  • Nothing to do during the install, meaning time for other things ;p
  • You can customize the default RHEL or CentOS install with the post-install script
  • Greatest speed ever !!! Twice or three times faster than installing with DVD or CD, as long as your network is correct (100Mb).

So, first step is to create ISO images of your favorite distro. For that use dd or mkisofs :
dd if=/dev/dvd of=image.iso
mkisofs -R -J -o image.iso /mnt/cdrom


Then, share these images (i have on per architecture and distro) on a NFS server.

Now the most important, the Kickstart file :
# System authorization information
auth --useshadow --enablemd5 --enablenis --nisdomain=mydomain --nisserver=192.168.xxx.xxx
# License RHEL
key xxxxxxxxxxxxxx # put here youy license key
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Use graphical install
graphical
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard fr-latin1
# System language
lang fr_FR
# Installation logging level
logging --level=debug
#We make a network install from NFS Server
nfs --server=192.168.xxx.xxx --dir=/path/to/your/isos/
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on --mtu=4500
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $1$DNIhtN0D$8D.Ard1Aq48KP6NmtxZSx0
# SELinux configuration
selinux --disabled
# System timezone
timezone Europe/Paris
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig --defaultdesktop=GNOME --depth=24 --resolution=1280x1024
# Disk partitioning information, fixed sizes, /data is what remains on disk
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=200
part / --bytes-per-inode=4096 --fstype="ext3" --size=5000
part /var --bytes-per-inode=4096 --fstype="ext3" --size=5000
part /tmp --bytes-per-inode=4096 --fstype="ext3" --size=5000
part /usr --bytes-per-inode=4096 --fstype="ext3" --size=10000
part swap --bytes-per-inode=4096 --fstype="swap" --size=4000
part /data --bytes-per-inode=4096 --fstype="ext3" --grow --size=1

%packages
@base-x
@gnome-desktop
@base
@development-libs
@graphical-internet
@admin-tools
@development-tools
@kde-desktop
@printing
@sound-and-video
@legacy-software-development
@graphics
@office
@system-tools
@editors
@engineering-and-scientific

#--- Post-installation script
%post
#!/bin/bash
chroot /mnt/sysimage

echo "192.168.xxx.xxx netapp" >> /etc/hosts
echo "192.168.xxx.xxx nisserver" >> /etc/hosts

mkdir -p /netapp/vol3
mount 192.168.xxx.xxx:/vol/vol3 /netapp/vol3
cd /netapp/vol3/distros/rpms
#Installing NVIDIA kernel module, RPMs from internet.
rpm -ivh nvidia-graphics-helpers-0.0.26-27.el5.i386.rpm
rpm -ivh nvidia-graphics-devices-1.0-5.0.el5.noarch.rpm
rpm -ivh nvidia-graphics173.14.09-libs-173.14.09-99.el5.i386.rpm
rpm -ivh nvidia-graphics173.14.09-kmdl-2.6.18-53.el5PAE-173.14.09-99.el5.i686.rpm
rpm -ivh nvidia-graphics173.14.09-173.14.09-99.el5.i386.rpm

#Installing software (meaning doing links to autofs mount points)
ln -s /soft/abaqus/ /usr/local/abaqus
ln -s /soft/hyperworks8 /usr/local/hyworks
ln -s /soft/hyperworks7 /usr/local/hyworks7
ln -s /soft/msc /usr/local/msc
ln -s /soft/radioss /usr/local/radioss

#Copy nsswitch and other resolv.conf ....
cp -f /netapp/vol3/distros/post/nsswitch.conf /etc/nsswitch.conf

cd /root
umount /netapp/vol3



Have fun !

No comments: