Sunday, June 8, 2008

Unbreakable Linux Kickstart HowTo

Oracle Unbreakable linux is essential same as Redhat Linux. This post I will cover how to do a kickstart on Unbreakable linux AS 4 update 6. This would apply to other versions and RedHat installations as well.
Kickstart simplifies your installation of linux servers on the network. Essentially, these are the main components to it:
1. The server gets a small boot file from floppy, CD, USB or over the network.
2. The server gets a kickstart config file as above from media or over the network.
3. Depending on what you choose as your installation media in the kickstart config file, the operating system packages are installed.
4. You can mention pre and post installation steps in kickstart file to automate processes such as user creation etc.

From my point of view a network install all the way makes more sense and that is what I would be covering here today.
Redhat website has a nice detailed howto all the methods and can be found here:


I will break it into 3 steps:
Step 1: install required services/packages.
Step 2. Configure required files.
Step 3. Starting the pxe boot

Step 1:
We need 3 services that could be hosted by a single server or multiple servers and a few config utilities:
1. DHCP service ->gives IP address to PXE boot client and tells it the file name to boot from and tftp server address.
2. TFTP server ->where the initial boot file resides, that contains info regarding install.
3. NFS server -> where the kickstart config file and installation tree is available.
4. service-config-netboot -> that would generate the pxelinux.cfg tree and boot file for the client.

1st lets get into making the installation tree available locally on the box. I copied all the .iso files under /kickstart on the server. It could be any folder you choose as long as you are willing to NFS share it.

For my setup, I had all of 3 services above on a single server. Lets get to installing or starting these services.
These would reveal if you have tftp server and dhcp server installed or not:
rpm -qa grep *tftp*
rpm -qa grep *dhcp*
rpm -qa grep *netboot*

If these services are installed, skip this section and move onto step 2.

Install all these 3 packages using your favorite method. You can do yum install .
Or you can install them from the installation CDs. I didn't know which CD contained these packages, I mounted all of them. OUL(oracle unbreakable linux 4_6 64bit) has 5 installation CDs. So I created 5 mount points and mounted them on the server:
mkdir -p /mnt/tmp1
mkdir -p /mnt/tmp2
mkdir -p /mnt/tmp3
mkdir -p /mnt/tmp4
mkdir -p /mnt/tmp5
mount -o loop Enterprise-R4-U6-x86_64-disc1.iso /mnt/tmp1
mount -o loop Enterprise-R4-U6-x86_64-disc2.iso /mnt/tmp2
mount -o loop Enterprise-R4-U6-x86_64-disc3.iso /mnt/tmp3
mount -o loop Enterprise-R4-U6-x86_64-disc4.iso /mnt/tmp4
mount -o loop Enterprise-R4-U6-x86_64-disc5.iso /mnt/tmp5

Doing the following on the above mount points to see where the required RPMs are:
cd /mnt/tmp1/Enterprise/RPMS
and
ls | grep *dhcp*
ls | grep *tftp*
ls | grep *netboot*
After locating them, do the install. You would need to install tftp server before service-config-netboot:
rpm -i dhcp-3.0.1-59.EL4.x86_64.rpm
rpm -i tftp-server-0.39-2.x86_64.rpm
rpm -i system-config-netboot-0.1.40.1-1.x86_64.rpm

Step 2:
The following files would be created/edited:
a. kickstart config file
b. xinetd.d tftp file
c. pxelinux.cfg directory and install files.
d. dhcpd.conf file

a. kickstart config file

Since our install was oracle specific. I downloaded the recommended config file from oracle's wiki website at following address: http://wiki.oracle.com/page/Linux+installation+kickstart+for+Oracle+database
You can customize this according to:
http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/s1-kickstart2-options.html
or you can use GUI to create one for you using service-config-kickstart(You might have to install this package if its missing).

The following config file is basically a copy of one downloaded from oracle website with some modifications like:
1. NFS install instead of url
2. Hostname etc. changed
3. No post installations here.
You should make the necessary modifications as per your requirements to this file. The default root password in this config file is password.

Kickstart config file, saved as example.cfg under /kickstart:

##############################################################################
# Uncomment the next line to enable interactive installation
#interactive

# Comment the next line to use GUI installation
text

install

# From where to get the installation disks
#cdrom
#url --url http://myserver/redhat/
nfs --server=192.168.1.10 --dir=/kickstart

lang en_US.UTF-8
langsupport --default=en_US.UTF-8 en_US.UTF-8
keyboard us
xconfig --resolution 800x600 --depth 16 --defaultdesktop gnome

# Change the hostname and peek the best eth configuration for you
#network --device eth0 --bootproto dhcp --hostname srvoracle01
network --device eth0 --bootproto static --ip 192.168.1.100 --netmask 255.255.255.0 --gateway
192.168.1.1 --nameserver 192.168.1.1, 192.168.1.2 --hostname testmachine

rootpw --iscrypted $1$uKWECPhN$Im66UG8MpWd2/kpcHoyuy/
firewall --disabled
selinux --disabled
authconfig --enableshadow --enablemd5

# Set a different timezone if not located in EST
timezone America/New_York

bootloader --location=mbr --append="rhgb quiet"


# Create a Volgroup device sda
clearpart --all --drives=sda
part /boot --fstype ext3 --size=100 --ondisk=sda
part pv.3 --size=0 --grow --ondisk=sda
volgroup vg00 --pesize=32768 pv.3

# Create the filesystems and logical volumes
logvol / --fstype ext3 --name=lvol00 --vgname=vg00 --size=2048
logvol /tmp --fstype ext3 --name=lvol01 --vgname=vg00 --size=2048
logvol /usr --fstype ext3 --name=lvol02 --vgname=vg00 --size=3500
logvol /usr/local --fstype ext3 --name=lvol03 --vgname=vg00 --size=1024
logvol /var --fstype ext3 --name=lvol04 --vgname=vg00 --size=1024
logvol /var/log --fstype ext3 --name=lvol05 --vgname=vg00 --size=1024
logvol /opt --fstype ext3 --name=lvol06 --vgname=vg00 --size=1024
logvol /home --fstype ext3 --name=lvol07 --vgname=vg00 --size=512

# Edit the swap space to be twice the size of the machine RAM, if you
logvol swap --fstype swap --name=lvol08 --vgname=vg00 --size=8192


# All packages needed by Oracle installation include Gnome desktop
%packages
@ system-tools
@ gnome-desktop
@ dialup
@ compat-arch-support
-openldap-clients
-ckermit
-wireshark
-bluez-pin
-OpenIPMI-tools
-samba-client
e2fsprogs
-screen
-xdelta
-zsh
-nmap
lvm2
sysstat
-open
kernel-smp
grub
binutils
compat-db
control-center
gcc
gcc-c++
glibc
glibc-common
gnome-libs
libstdc++
libstdc++-devel
make
pdksh
sysstat
xscreensaver


%post
##############################################################################


Need to make the folders available for NFS share:
This is the /kickstart folder that contains kickstart config file and installation .iso files.
nfs-export --dir /kickstart --perm ro --ip 192.168.1.100
nfs-export --dir /kickstart --perm ro --ip 192.168.1.10

If you skipped step 1, mount 1st iso CD under /mnt/tmp1
(e.g. mount -o loop Enterprise-R4-U6-x86_64-disc1.iso /mnt/tmp1)
And make is available for NFS share:
nfs-export --dir /mnt/tmp1 --perm ro --ip 192.168.1.10
nfs-export --dir /mnt/tmp1 --perm ro --ip 192.168.1.100

Now we need to start the tftp daemon:
b. xinetd.d tftp file

Edit the following to run tftp as daemon, you can choose to run this in standalone mode using /usr/sbin/in.tftpd and not editing this file:
/etc/xinetd.d/tftp:
###################################################################
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
###################################################################

restard xinted.d:
/etc/init.d/xinetd restart

Next step is to get /tftpboot/linux-install folder ready for boot files.
c. pxelinux.cfg directory and install files.

Using the following command to generate these files under /tftpboot:
/usr/sbin/pxeos -a -i "OUL" -p NFS -D 0 -s 192.168.1.10 -K nfs:192.168.1.10:/kickstart/example.cfg -L /mnt/tmp1 OUL4
This also generates a defualt file under /tftpboot/linux-install/pxelinux.cfg, which is read by the installer at boot time. You can create one specific for your host using pxeboot command.

d. dhcpd.conf file

DHCP config file.
You can get the MAC address for the client in lot of different ways. If you PXE boot the client, it throws the client MAC address right at the console. You would need this to set the values in following file.
If you are crossing vlans/routers make sure ip helper address or equilavent is set on the routing/network device.

/etc/dhcpd.conf :
###################################################################
deny unknown-clients;
not authoritative;
ddns-update-style ad-hoc;
option domain-name "lcc.copr.pvt";
option domain-name-servers 192.168.1.1;
option subnet-mask 255.255.255.0;

allow bootp;
allow booting;

option ip-forwarding false; # No IP forwarding
option mask-supplier false; # Don't respond to ICMP Mask req

subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.1.1;
}
group {
next-server 192.168.1.10; # name of your TFTP server
filename "linux-install/pxelinux.0"; # name of the bootloader program

host node1 {
hardware ethernet 00:14:4F:45:14:0E;
fixed-address 192.168.1.100;
}
}
###################################################################

Start DHCP server:
/etc/init.d/dhcpd start

Step 3. Starting the pxe boot

Change the boot order to boot from the network on the client machine and if all the configs were done correctly, you should be able to go through the install smoothly. You can watch as it goes and look for error messages if any to fix any typos etc.