Showing posts with label KICKSTART. Show all posts
Showing posts with label KICKSTART. Show all posts

Kickstart Examples – Configuration 5

Kickstart Examples – Configuration 5

Networking:
  • Bootproto = static
  • Hostname = centvm1
  • IP = 192.168.122.200
  • Netmask = 255.255.255.0
  • Gateway = 192.168.122.1
  • Nameserver = 192.168.122.1
  • Disable IPv6
Partitioning:
  • /boot –ext4 –size 500M
  • LVM paritioning
  • Volume Group – size 7G
  • Logical volume – lv_root – size 5G
  • Logical volume – lv_swap – size 1.5G
General:
  • SELinux enabled
  • Firewall rule added for SSH
  • TimeZone – Europe/London
  • CentOS Minimal – Core
  • Add a user named testuser
  • Install httpd package and enable & start the service

Kickstart config

# =======================================
# SECTION 1: Command section
# =======================================
# Install options
install
url --url ftp://192.168.122.249/images/centos/x86_64/6.5
keyboard uk
lang en_US
selinux --enforcing
timezone --utc Europe/London

# Set up root password
rootpw --iscrypted $6$jgrdXC4a/XBlOZkv$A49cH1mwaK7K91.EM/GDdiFO7NBt4CXk3omKntDk35UEyzjWBeJl2x6oGPuH0HRYLjJNUhYDsHRjyEGjsMFp50

# Create an user with encrypted password
user --name=testuser --password=$6$jgrdXC4a/XBlOZkv$A49cH1mwaK7K91.EM/GDdiFO7NBt4CXk3omKntDk35UEyzjWBeJl2x6oGPuH0HRYLjJNUhYDsHRjyEGjsMFp50 --iscrypted

# Networking options
network --onboot yes --device eth0 --bootproto static --ip 192.168.122.200 --netmask 255.255.255.0 --gateway 192.168.122.1 --nameserver 192.168.122.1 --hostname centvm1 --noipv6

# Authentication options
authconfig --enableshadow --passalgo-sha512

# Bootloader options
# Harddisk in this case is /dev/vda
zerombr
bootloader --location=mbr --driveorder=vda --append="crashkernel=auto"

# Add an exception for ssh in firewall
firewall --service=ssh

# Partitioning
clearpart --all --initlabel
part /boot --fstype=ext4 --size=500
part pv.001 --size 7000
volgroup my_volgp pv.001
logvol / --fstype=ext4 --vgname=my_volgp --size=5000 --name=lv_root
logvol swap --fstype=swap --vgname=my_volgp --size 1500 --name=lv_swap

# Reboot after installation
reboot

# =======================================
# SECTION 2: Packages section
# =======================================
%packages --nobase
@Core
httpd

# =======================================
# SECTION 3: Pre section (optional)
# =======================================

# =======================================
# SECTION 4: Post section (optional)
# =======================================
%post
chkconfig httpd on
service httpd start

Kickstart Examples – Configuration 4

Kickstart Examples – Configuration 4

Networking:
  • Bootproto = static
  • Hostname = centvm1
  • IP = 192.168.122.200
  • Netmask = 255.255.255.0
  • Gateway = 192.168.122.1
  • Nameserver = 192.168.122.1
  • Disable IPv6
Partitioning:
  • /boot –ext4 –size 500M
  • LVM paritioning
  • Volume Group – size 7G
  • Logical volume – lv_root – size 5G
  • Logical volume – lv_swap – size 1.5G
General:
  • SELinux enabled
  • Firewall rule added for SSH
  • TimeZone – Europe/London
  • CentOS Minimal – Core
  • Add a user named testuser

Kickstart config

# =======================================
# SECTION 1: Command section
# =======================================
# Install options
install
url --url ftp://192.168.122.249/images/centos/x86_64/6.5
keyboard uk
lang en_US
selinux --enforcing
timezone --utc Europe/London

# Set up root password
rootpw --iscrypted $6$jgrdXC4a/XBlOZkv$A49cH1mwaK7K91.EM/GDdiFO7NBt4CXk3omKntDk35UEyzjWBeJl2x6oGPuH0HRYLjJNUhYDsHRjyEGjsMFp50

# Create an user with encrypted password
user --name=testuser --password=$6$jgrdXC4a/XBlOZkv$A49cH1mwaK7K91.EM/GDdiFO7NBt4CXk3omKntDk35UEyzjWBeJl2x6oGPuH0HRYLjJNUhYDsHRjyEGjsMFp50 --iscrypted

# Networking options
network --onboot yes --device eth0 --bootproto static --ip 192.168.122.200 --netmask 255.255.255.0 --gateway 192.168.122.1 --nameserver 192.168.122.1 --hostname centvm1 --noipv6

# Authentication options
authconfig --enableshadow --passalgo-sha512

# Bootloader options
# Harddisk in this case is /dev/vda
zerombr
bootloader --location=mbr --driveorder=vda --append="crashkernel=auto"

# Add an exception for ssh in firewall
firewall --service=ssh

# Partitioning
clearpart --all --initlabel
part /boot --fstype=ext4 --size=500
part pv.001 --size 7000
volgroup my_volgp pv.001
logvol / --fstype=ext4 --vgname=my_volgp --size=5000 --name=lv_root
logvol swap --fstype=swap --vgname=my_volgp --size 1500 --name=lv_swap

# Reboot after installation
reboot

# =======================================
# SECTION 2: Packages section
# =======================================
%packages --nobase
@Core

# =======================================
# SECTION 3: Pre section (optional)
# =======================================

# =======================================
# SECTION 4: Post section (optional)
# =======================================

Kickstart Examples – Configuration 3

Kickstart Examples – Configuration 3

Networking:
  • Bootproto = dhcp
  • Hostname = centvm1
  • Disable IPv6
Partitioning:
  • /boot –ext4 –size 500M
  • LVM paritioning
  • Volume Group – size 7G
  • Logical volume – lv_root – size 5G
  • Logical volume – lv_swap – size 1.5G
General:
  • SELinux enabled
  • Firewall rule added for SSH
  • TimeZone – Europe/London
  • CentOS Minimal – Core
  • Add a user named testuser

Kickstart config

# =======================================
# SECTION 1: Command section
# =======================================
# Install options
install
url --url ftp://192.168.122.249/images/centos/x86_64/6.5
keyboard uk
lang en_US
selinux --enforcing
timezone --utc Europe/London

# Set up root password
rootpw --iscrypted $6$jgrdXC4a/XBlOZkv$A49cH1mwaK7K91.EM/GDdiFO7NBt4CXk3omKntDk35UEyzjWBeJl2x6oGPuH0HRYLjJNUhYDsHRjyEGjsMFp50

# Create an user with encrypted password
user --name=testuser --password=$6$jgrdXC4a/XBlOZkv$A49cH1mwaK7K91.EM/GDdiFO7NBt4CXk3omKntDk35UEyzjWBeJl2x6oGPuH0HRYLjJNUhYDsHRjyEGjsMFp50 --iscrypted

# Networking options
network --onboot yes --device eth0 --bootproto dhcp --hostname centvm1 --noipv6

# Authentication options
authconfig --enableshadow --passalgo-sha512

# Bootloader options
# Harddisk in this case is /dev/vda
zerombr
bootloader --location=mbr --driveorder=vda --append="crashkernel=auto"

# Add an exception for ssh in firewall
firewall --service=ssh

# Partitioning
clearpart --all --initlabel
part /boot --fstype=ext4 --size=500
part pv.001 --size 7000
volgroup my_volgp pv.001
logvol / --fstype=ext4 --vgname=my_volgp --size=5000 --name=lv_root
logvol swap --fstype=swap --vgname=my_volgp --size 1500 --name=lv_swap

# Reboot after installation
reboot

# =======================================
# SECTION 2: Packages section
# =======================================
%packages --nobase
@Core

# =======================================
# SECTION 3: Pre section (optional)
# =======================================

# =======================================
# SECTION 4: Post section (optional)
# =======================================

Kickstart Examples – Configuration 2

Kickstart Examples – Configuration 2

Networking:
  • Bootproto = dhcp
  • Hostname = centvm1
  • Disable IPv6
Partitioning:
Simple paritioning
  • /boot – ext4 – size 500M
  • / – ext4 – size 5G
  • Swap – size 2G
General:
  • SELinux enabled
  • Firewall rule added for SSH
  • TimeZone – Europe/London
  • CentOS Minimal – Core
  • Add a user named testuser

Kickstart config

# =======================================
# SECTION 1: Command section
# =======================================
# Install options
install
url --url ftp://192.168.122.249/images/centos/x86_64/6.5
keyboard uk
lang en_US
selinux --enforcing
timezone --utc Europe/London

# Set up root password
rootpw --iscrypted $6$jgrdXC4a/XBlOZkv$A49cH1mwaK7K91.EM/GDdiFO7NBt4CXk3omKntDk35UEyzjWBeJl2x6oGPuH0HRYLjJNUhYDsHRjyEGjsMFp50

# Create an user with encrypted password
user --name=testuser --password=$6$jgrdXC4a/XBlOZkv$A49cH1mwaK7K91.EM/GDdiFO7NBt4CXk3omKntDk35UEyzjWBeJl2x6oGPuH0HRYLjJNUhYDsHRjyEGjsMFp50 --iscrypted

# Networking options
network --onboot yes --device eth0 --bootproto dhcp --hostname centvm1 --noipv6

# Authentication options
authconfig --enableshadow --passalgo-sha512

# Bootloader options
# Harddisk in this case is /dev/vda
zerombr
bootloader --location=mbr --driveorder=vda --append="crashkernel=auto"

# Add an exception for ssh in firewall
firewall --service=ssh

# Partitioning
clearpart --all --initlabel
part / --fstype=ext4 --size=5000
part /boot --fstype=ext4 --size=500
part swap --fstype=swap --size=2000

# Reboot after installation
reboot

# =======================================
# SECTION 2: Packages section
# =======================================
%packages --nobase
@Core

# =======================================
# SECTION 3: Pre section (optional)
# =======================================

# =======================================
# SECTION 4: Post section (optional)
# =======================================

Kickstart Examples – Configuration 1

Kickstart Examples – Configuration 1

Networking:
  • Bootproto = dhcp
  • Hostname = centvm1
  • Disable IPv6
Partitioning:
Simple paritioning
  • /boot – ext4 – size 500M
  • / – ext4 – size 5G
  • Swap – size 2G
General:
  • SELinux enabled
  • Firewall rule added for SSH
  • TimeZone – Europe/London
  • CentOS Minimal – Core

Kickstart config

# =======================================
# SECTION 1: Command section
# =======================================
# Install options
install
url --url ftp://192.168.122.249/images/centos/x86_64/6.5
keyboard uk
lang en_US
selinux --enforcing
timezone --utc Europe/London

# Set up root password
rootpw --iscrypted $6$jgrdXC4a/XBlOZkv$A49cH1mwaK7K91.EM/GDdiFO7NBt4CXk3omKntDk35UEyzjWBeJl2x6oGPuH0HRYLjJNUhYDsHRjyEGjsMFp50

# Networking options
network --onboot yes --device eth0 --bootproto dhcp --hostname centvm1 --noipv6

# Authentication options
authconfig --enableshadow --passalgo-sha512

# Bootloader options
# Harddisk in this case is /dev/vda
zerombr
bootloader --location=mbr --driveorder=vda --append="crashkernel=auto"

# Add an exception for ssh in firewall
firewall --service=ssh

# Partitioning
clearpart --all --initlabel
part / --fstype=ext4 --size=5000
part /boot --fstype=ext4 --size=500
part swap --fstype=swap --size=2000

# Reboot after installation
reboot

# =======================================
# SECTION 2: Packages section
# =======================================
%packages --nobase
@Core

# =======================================
# SECTION 3: Pre section (optional)
# =======================================

# =======================================
# SECTION 4: Post section (optional)
# =======================================

Kickstart Examples configurations

Kickstart Examples

Hi Readers, in this article I am going to share with you some basic kickstart configuration files. Feel free to try these config files in your set up.

My Set Up

I was using KVM on my Ubuntu machine to play with PXE and Kickstart. I have set up a PXE server on CentOS 6.5 which has IP address 192.168.122.249. OS installation files are served by vsftpd server in this machine. Change the IP address and other settings as per your needs in the kickstart files mentioned in this article.

Kickstart Examples

Kickstart File Auto Install Details
View Kickstart file Networking:
* Bootproto = dhcp
* Hostname = centvm1
* Disable IPv6Partitioning:
Simple paritioning
* /boot – ext4 – size 500M
* / – ext4 – size 5G
* Swap – size 2G General:
SELinux enabled
Firewall rule added for SSH
TimeZone – Europe/London
CentOS Minimal – Core
View Kickstart file Networking:
* Bootproto = dhcp
* Hostname = centvm1
* Disable IPv6Partitioning:
Simple paritioning
* /boot – ext4 – size 500M
* / – ext4 – size 5G
* Swap – size 2G General:
SELinux enabled
Firewall rule added for SSH
TimeZone – Europe/London
CentOS Minimal – Core
Add a new user named testuser
View Kickstart file Networking:
* Bootproto = dhcp
* Hostname = centvm1
* Disable IPv6Partitioning:
* /boot –ext4 –size 500M
LVM paritioning
* Volume Group – size 7G
* Logical volume – lv_root – size 5G
* Logical volume – lv_swap – size 1.5G General:
SELinux enabled
Firewall rule added for SSH
TimeZone – Europe/London
CentOS Minimal – Core
Add a new user named testuser
View Kickstart file Networking:
* Bootproto = static
* Hostname = centvm1
* IP = 192.168.122.200
* Netmask = 255.255.255.0
* Gateway = 192.168.122.1
* Nameserver = 192.168.122.1
* Disable IPv6Partitioning:
* /boot –ext4 –size 500M
LVM paritioning
* Volume Group – size 7G
* Logical volume – lv_root – size 5G
* Logical volume – lv_swap – size 1.5G General:
SELinux enabled
Firewall rule added for SSH
TimeZone – Europe/London
CentOS Minimal – Core
Add a new user named testuser
View Kickstart file Networking:
* Bootproto = static
* Hostname = centvm1
* IP = 192.168.122.200
* Netmask = 255.255.255.0
* Gateway = 192.168.122.1
* Nameserver = 192.168.122.1
* Disable IPv6Partitioning:
* /boot –ext4 –size 500M
LVM paritioning
* Volume Group – size 7G
* Logical volume – lv_root – size 5G
* Logical volume – lv_swap – size 1.5G General:
SELinux enabled
Firewall rule added for SSH
TimeZone – Europe/London
CentOS Minimal – Core
Add a new user named testuser
Install httpd server
Enable httpd on boot
Start httpd service

Kickstart Installation on RHEL/CentOS

Kickstart Installation

Hello readers, In this article I am going to walk you through kickstart installation, an automated installation method on RHEL based systems. I tested this on a CentOS 6.5 virtual machine. The process should be the same on other RHEL distro variations.

Kickstart

It is an automated way of installing the operating system. You set all the options in a config file which is then read by all the machine during installation. So you don’t have to manually answer all the questions that are generally asked during installation.
Here is a good explanation of kickstart from RedHat documentation.
Many system administrators would prefer to use an automated installation method to install Red Hat Enterprise Linux on their machines. To answer this need, Red Hat created the kickstart installation method. Using kickstart, a system administrator can create a single file containing the answers to all the questions that would normally be asked during a typical installation.
Kickstart files can be kept on a single server system and read by individual computers during the installation. This installation method can support the use of a single kickstart file to install Red Hat Enterprise Linux on multiple machines, making it ideal for network and system administrators.
Kickstart provides a way for users to automate a Red Hat Enterprise Linux installation.

Steps for kickstart installation

Here is a brief outline of the steps involved in automating installation using Kickstart
  • Create kickstart file that has all the installation options set
  • Create a boot disk with kickstart file
  • Or create a boot disk and have the kickstart file in the network
  • Make the OS installation tree available somewhere in the network (ftp, http, nfs)
  • Start the kickstart installation on new machines.

Kickstart configurator

Kickstart files are plain text files which can either be created by hand if you are an advanced user or using a GUI tool. I would reccommend going the GUI way if you are just starting. RedHat provides a kickstart configurator tool which can be installed as follows
# yum install system-config-kickstart
If you want to see how a kickstart file looks, take a look at anaconda-ks.cfg in /root directory of any RHEL/CentOS systems. This file gets generated and placed in /root directory on a newly installed machine.
Start the GUI tool using the system menu or from the terminal as follows
# system-config-kickstart
You will be welcomed with this screen
Kickstart Installation Scren 1
Most of the options are self-explanatory and fill in all the details as you would while installing the OS. You will also be able to select the packages that you want.
In the below installation option screen, select the one that suits your need. In this article I will show you how to do it via ftp and http.
Kickstart Installation Screen 2
When you select ftp or http method, the tool will ask you for ftp/http server url, password and path. Continue reading this article and you will find what to fill in this section. Once all the details are filled, save the file as ks.cfg or whatever you want it to be called, but remember it.

Creating bootdisk

You can either use your OS install disk or create a boot disk if you want by following the below process. You will be using this boot disk to boot the machine and then point it to the kickstart file later.
mkisofs is a tool provided by genisoimage package. Using this tool we can build iso files. Install it as follows.
# yum install genisoimage
Mount your RHEL/CentOS install DVD and copy isolinux directory
# mkdir /tmp/installdvd
# cp -R /path/to/mounted/dvd/isolinux /tmp/installdvd
# cd /tmp/installdvd
# chmod u+w isolinux/*
Create the iso image now
# cd /tmp/installdvd
# mkisofs -o file.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T isolinux/
This will create an iso image named file.iso. Burn it to a dvd and now you have got a boot disk!

Kickstart via FTP

I am going to assume here that you have got a working ftp server (vsftpd) and anonymous access is allowed.

Copying install tree to ftp:

Now we are going to copy the install disk to our ftp root. Lets assume you have got an iso file of the CentOS install disk downloaded from the internet. Mount it and copy to ftp as follows.
# mkdir /mnt/centosdvd
# mount -o loop /path/to/centos-6.5-x86_64-dvd.iso /mnt/centosdvd
# mkdir /var/ftp/pub/centos65
# cp -aR /mnt/centosdvd/* /var/ftp/pub/centos65/

Copying kickstart file to ftp:

Copy the kickstart file that you created earlier using system-config-kickstart to the ftp root.
# cp /path/to/ks.cfg /var/ftp/pub/

Adjusting SELinux:

If you have SELinux enabled, you need to set proper context to the newly copied directories. We shall use semanage tool to make our changes persistent. If you haven’t already got policycoreutils-python package installed, install it now.
# yum install policycoreutils-python
# semanage fcontext -a -t public_content_t "/var/ftp/pub/centos65(/.*)?"
# restorecon -R /var/ftp/pub/centos65
That’ it. Lets assume our server’s ip address is 10.0.3.100. This is going to be our kickstart server serving ks.cfg and OS install files.
On your kickstart configurator tool, select ftp and enter ftp://10.0.3.100/pub/centos65 as the ftp url.

Kickstart via HTTP

I am going to assume here that you have a web server set up already.

Copying install tree to web server:

Lets copy the OS install disk to web root so that all new machines can download packages from this server. Assuming you still have the disk mounted from earlier tasks,
# mkdir /var/www/html/centos65
# cp -aR /mnt/centosdvd/* /var/www/html/centos65/

Copy kickstart file to web server:

# cp /path/to/ks.cfg /var/www/html/

Adjusting SELinux:

# semanage fcontext -a -t httpd_sys_content_t "/var/www/html/centos65(/.*)?"
# restorecon -R /var/www/html/centos65

Performing Kickstart installation

Alright, we have come to the final bit. Lets perform an automated installation on one of our new machine. Boot the machine with either the boot disk that you created earlier or using the OS install DVD. When you see the boot menu press TAB key to edit the boot option. Append the ks.cfg location as below,

For ftp setup

> vmlinuz initrd=initrd.img console=ttyS0 ks=ftp://10.0.3.100/pub/ks.cfg

For http setup

> vmlinuz initrd=initrd.img console=ttyS0 ks=http://10.0.3.100/ks.cfg
That’s it. Unattended kickstart installation will proceed. Enjoy a cup of coffee!
Hope you learnt something new today. Thanks for reading this article.