Installing Linux using Kickstart and Kobbler
Using Kickstart server 01.Setup a Kickstart server 02.Setup Kickstart using Kobbler 2a.Installing kobbler 2b.Import a distribution using kobbler import 2e.Reinstall a system with koan
Red Hat Linux operating system installations can be done via a network connection using a Kickstart server. It is frequently much faster than using CDs and the process can be automated.
Example Kickstart Get the kickstart cfg from http server and start the install boot: linux ks=http://server.com/path/to/kickstart/file Get the kickstart cfg from nfs server and start the install boot: linux ks=nfs:server:/path/to/kickstart/file Serving the Kickstart file from nfs server through dhcp /etc/dhcpd.conf next-server 10.10.10.100; filename "/pxelinux.0";
Setup a Kickstart Server
01. Install and configure the DHCPD server
02. Install tftp server and enable TFTP service
a. yum install tftp-server
b. Enable TFTP server.
vi /etc/xinetd.d/tftp and change disable to 'no'
c. service xinetd restart
03. Install syslinux if not already installed
a. yum install syslinux
04. Copy needed files from syslinux to the tftpboot directory
cp /usr/lib/syslinux/pxelinux.0 /tftpboot
cp /usr/lib/syslinux/menu.c32 /tftpboot
cp /usr/lib/syslinux/memdisk /tftpboot
cp /usr/lib/syslinux/mboot.c32 /tftpboot
cp /usr/lib/syslinux/chain.c32 /tftpboot
04. Create the directory for your PXE menus
mkdir /tftpboot/pxelinux.cfg
05. For each "Release" and "ARCH" Copy vmlinuz and initrd.img from /images/pxeboot/ directory on "disc 1" of that $Release/$ARCH to /tftpboot/images/RHEL/$ARCH/$RELEASE
mkdir -p /tftpboot/images/RHEL/i386/4.3
mkdir -p /tftpboot/images/RHEL/i386/5.5
mkdir -p /tftpboot/images/RHEL/x86_64/4.3
mkdir -p /tftpboot/images/RHEL/x86_64/5.5
For RHEL 5.5 x86_64, do the following
mount /dev/cdrom /cdrom
cd /cdrom/images/pxeboot
cp vmlinuz initrd.img /tftpboot/images/RHEL/x86_64/5.5
Do the above for all releases and ARCH you want to kickstart from this server.
06. Add this to your existing or new /etc/dhcpd.conf.
Note: xxx.xxx.xxx.xxx is the IP address of your PXE server
allow booting;
allow bootp;
option option-128 code 128 = string;
option option-129 code 129 = text;
next-server xxx.xxx.xxx.xxx;
filename "/pxelinux.0";
07. Restart DHCP service
# service dhcpd restart
08. Create Simple or Multilevel PIXIE menu. Create a file called "default" in /tftpboot/pxelinux.cfg directory. A Sample file named "isolinux.cfg" is found on the boot installation media in "isolinux" directory. Copy this file as default and edit this file as per requirement. A sample default file is given bellow.
default menu.c32
prompt 0
timeout 300
ONTIMEOUT local
MENU TITLE PXE Menu
LABEL Pmajic
MENU LABEL Pmajic
kernel images/pmagic/bzImage
append noapic initrd=images/pmagic/initrd.gz root=/dev/ram0 init=/linuxrc ramdisk_size=100000
label Dos Bootdisk
MENU LABEL ^Dos bootdisk
kernel memdisk
append initrd=images/622c.img
LABEL RHEL 5 x86 eth0
MENU LABEL RHEL 5 x86 eth0
KERNEL images/RHEL/x86/5.5/vmlinuz
APPEND initrd=images/RHEL/x86_64/5.5/initrd.img ramdisk_size=10000
ks=nfs:xx.xx.xx.xxx:/<path _to_jumpstart_config_file> ksdevice=eth1
LABEL RHEL 5 x86_64 eth0
MENU LABEL RHEL 5 x86_64 eth0
KERNEL images/RHEL/x86_64/5.5/vmlinuz
APPEND initrd=images/RHEL/x86_64/5.5/initrd.img ramdisk_size=10000
ks=nfs:xx.xx.xx.xxx:/<path _to_jumpstart_config_file> ksdevice=eth1
09. Install the kickstart Configurator tool. This tool will be helpful to create the kickstart configuration file.
yum install system-config-kickstart
10. Create the kickstart config file. This file can be created using kickstart Configuration Tool. A Sample file anaconda-ks.cfg based on current installation of a system is placed in /root directory. We can also use this /root/anaconda-ks-cfg as the configuration file. Copy this file to the location specified in the default file. Make sure the directory is NFS exported if you are using NFS for installing the OS.
11. Modify the kickstart configuration file as per requirement. If you are using NFS for installation, Make sure to copy the ISO images of Linux disks to any NFS server and NFS export the directory. This server/directory details need to be specified in the jumpstart configuration file.
12. After creating the KS configuration files and copying the ISO images, the installation can be started.
Sample Kickstart configuration file can be found here
http://www.datadisk.co.uk/html_docs/redhat/rh_pxe.html
http://esther.ilionet.com/programs/kickstart.php
http://pxe.dev.aboveaverageurl.com/index.php/PXE_Booting
http://wiki.centos.org/HowTos/PXE/PXE_Setup
Kickstart using Cobbler
Installing kobbler
The latest stable releases of Cobbler and Koan are included in Extras Packages.
yum install cobbler # on the boot server yum install cobbler-web # on the boot server (optional) yum install koan # on target systems (optional)
On the cobbler server:
# Review the procedure below. The command arguments "--foo=bar" will need to vary locally. # Install cobbler. The command below assumes a Redhat-like OS. yum install cobbler # Show what aspects might need attention cobbler check # Act on the 'check' above, then re-check until satisfactory. # Import a client OS from a DVD. This automatically sets up a "distro" and names it. cobbler import --path=/mnt --name=rhel5 --arch=x86_64 # Create a profile (e.g. "rhel5_workstation") and associate it with that distro cobbler profile add --name=rhel5_workstation --distro=rhel5 # Set up a kickstart file. # Associate a kickstart file with this profile cobbler profile edit --name=rhel5_workstation --kickstart=/path/to/kick.ks # Register a client machine (e.g. "workstation1") and its network details # and associate it with a profile cobbler system add --name=workstation1 \ --mac=AA:BB:CC:DD:EE:FF --ip=III.JJJ.KKK.LLL \ --profile=rhel5_workstation \ --netboot-enabled=true # Get a detailed report of everything in cobbler cobbler report # Get cobbler to act on all the above (set up DHCP, etc.) cobbler sync
Kobbler Import
The purpose of "cobbler import" is to set up a network install server for one or more distributions. This mirrors content of a DVD image, an ISO file, a tree on a mounted filesystem, an external rsync mirror or SSH location to the local storage.
- Cobbler import uses rsync to mirror the content to the disk. By default, the rsync operations will exclude content of certain architectures, debug RPMs, and ISO images -- to change what is excluded during an import, see /etc/cobbler/rsync.exclude.
- Mirrored content is saved automatically in /var/www/cobbler/ks_mirror.
Import from inserted DVD
cobbler import --path=/media/dvd --name=centos6
..OR... import from the mounted ISO example
cobbler import --path=/somedir --name=centos6
To mirror from a public rsync server
cobbler import --path=rsync://servergoeshere/path/to/distro --name=centos6
Setup from existing filesystem
cobbler import --path=/path/where/filer/is/mounted --name=centos6 --available-as=nfs://nfsserver:/is/mounted/here
Once imported, run a "cobbler list" or "cobbler report" to see what you've added.
# cobbler list
distros:
Centos62-x86_64
profiles:
Centos62-x86_64
systems:
centos03
repos:
images:
Snippet
Kickstart Snippets
Kickstart Snippets are a way of reusing common blocks of code between kickstarts. For instance, the default Cobbler installation has a snippet called "$SNIPPET('func_register_if_enabled')" that can help set up the application called Func. This means that every time that this SNIPPET text appears in a kickstart file it is replaced by the contents of /var/lib/cobbler/snippets/func_register_if_enabled. This allows this block of text to be reused in every kickstart template. You may think of snippets, if you like, as templates for templates!
Snippets are implemented using a Cheetah function. The preferred syntax is:
$SNIPPET('snippet_name_here')
Manage yum repos
Yum Repos
If you manage a large number of machines and they are (A) not allowed to get to the outside world, (B) bandwidth constrained, or (C) wanting to get access to 3rd party packages including custom yum repositories, we can setup a local repo using cobbler.
To add a repo
First, follow the setup for DVD / ISO import
Once the import is complete, we will add the mirrors
cobbler repo add --mirror=http://download.fedora.redhat.com/pub/fedora/linux/updates/12/ --name=f12-i386-updates cobbler repo add --mirror=http://download.fedora.redhat.com/pub/fedora/linux/releases/12/Everything/i386/ --name=f12-i386-everything cobbler repo add --mirror=http://download.fedoraproject.org/pub/epel/6/x86_64 --name=epel6x86_64
Now that we've added the mirrors, let's pull down the content. This will take a little while, but subsequent updates won't take nearly as long.
cobbler reposync
Now, that the repositories are mirrored locally, let's create a cobbler profile that will be able to automatically install from the above repositories and also configure clients to use the new mirror.
cobbler profile add --name=f12-i386-test --repos="f12-i386-updates f12-i386-everything" --distro=F12-i386 --kickstart=/etc/cobbler/sample_end.ks
Now, any machines installed from this mirror won't have to hit the outside world for any content they may need during install or with yum. They'll ask for content from the cobbler server instead. Cool.
Koan
Perhaps it stands for "kickstart over a network". Koan is a client-side helper program for use with Cobbler. koan allows for both network provisioning of new virtualized guests (Xen, QEMU/KVM, VMware) and re-installation of an existing system.
When invoked, koan requests install information from a remote cobbler boot server, it then kicks off installations based on what is retrieved from cobbler and fed in on the koan command line. The examples below show the various use cases.
INSTALL KOAN ON A CLIENT
On the client,
yum install koan
LISTING REMOTE COBBLER OBJECTS
To browse remote objects on a cobbler server and see what you can install using koan, run one of the following commands:
koan --server=cobbler.example.org --list=profiles koan --server=cobbler.example.org --list=systems koan --server=cobbler.example.org --list=images
LEARNING MORE ABOUT REMOTE COBBLER OBJECTS
To learn more about what you are about to install, run one of the following commands:
koan --server=cobbler.example.org --display --profile=name koan --server=cobbler.example.org --display --system=name koan --server=cobbler.example.org --display --image=name
REINSTALLING EXISTING SYSTEMS
If you want to install Fedora 12 on (instead of whatever it is running now), right now, you can do this:
Using --replace-self will reinstall the existing system the next time you reboot.
koan --server=bootserver.example.com --list=profiles koan --server=cobbler.example.org --replace-self --profile=F12-i386 koan --server=cobbler.example.org --replace-self --system=name /sbin/reboot
The system will install the new operating system after rebooting, hands off, no interaction required.
Notice in the above example "F12-i386" is just one of the boring default profiles cobbler created for you. You can also create your own, for instance "F12-webservers" or "F12-appserver" -- whatever you would like to automate.
Additionally, adding the flag --add-reinstall-entry will make it add the entry to grub for reinstallation but will not make it automatically pick that option on the next boot.
Also the flag --kexec can be appended, which will launch the installer without needing to reboot. Not all kernels support this option.
https://github.com/cobbler/cobbler/wiki/Koan
Official Cobbler Docs
Cobbler on CentOS
Cobbler Web Interface
Setup network boot server in 10 minutes
Setup YUM Repo for provisioning
Cobbler on CentOS 6