Development:Kickstart CD

Development:Kickstart CD

Contents

[hide]

Introduction to Using Kickstart

Introduction

This page is about how to create a single boot CD installation. It is based on CentOS 5 and we are using the kickstart technology included with CentOS and Fedora to script the Anaconda installer. In addition to creating an automated install, this page also describes how to create a custom distribution of CentOS that includes only the needed RPMs. The distribution fits on one CD and is self-contained resolving all its dependencies. No network connection is required to install it.

This was the process used to create the DiaStar™ ISO install disk Project DiaStar™ Server - ISO Install and is posted here in the event of your wanting to create a similar disk yourself.

Installing Necessary Tools

The scripts required to perform all the necessary operations are part of the CentOS / Fedora distribution.

# yum install anaconda-runtime createrepo yum-utils anaconda anaconda-help busybox-anaconda mkisofs

CentOS / Fedora also provides a graphical tool that allows creating and editing kickstart configuration files. This might be useful and is mentioned here for completeness. The description below is focused on manually editing the config files as this is almost easier than using a graphical tool. Start it by choosing Applications ? System Tools ? Kickstart. (Or: /usr/sbin/system-config-kickstrart).

# yum install system-config-kickstart

Create a Working Copy of the CentOS Installation Disk

We are using CentOS 5 to start with. Only CD 1 is required as we are interested in a customized minimal installation. Mount the CD and copy its content to a working directory:

$ mkdir centos-cd1 cd1
$ sudo mount /dev/cdrom centos-cd1
$ rsync -a centos-cd1/* cd1
$ cp centos-cd1/.discinfo cd1
$ sudo umount centos-cd1

Create a Kickstart Configuration File - ks.cfg

The most important file is the kickstart configuration file (ks.cfg). This file has to be copied to the root directory of the new CD. It provides all the parameters to Anaconda for an automated installation, determines what packages to install and allows some post installation scripts to be executed.

#######################################
# Kickstart file for DiaStar appliance
#
#######################################

#platform=x86, AMD64, or Intel EM64T
#version=BETA

# Firewall configuration
# Dialogic RTP 49152 (2 ports per channel, rtp and rtcp)
firewall --enabled --ssh --port=42420:tcp,49152-51152:udp

# Root password
rootpw --iscrypted $1$137n62W.$C4fWL0yd10McOTZOfwxVu1

# System authorization information
auth  --useshadow  --passalgo=md5

# Use graphical install
graphical
firstboot --disable

# Skip the X Window System configuration
skipx

# System keyboard
keyboard us

# System language
lang en_US

# SELinux configuration
selinux --disabled

# Install OS instead of upgrade
install

# Use CDROM installation media
cdrom

# System timezone
timezone  --utc America/New_York

# Network configuration
network --bootproto=query --device=eth0 --onboot=on --hostname=diastar

# System bootloader configuration
bootloader --location=mbr

# Clear the Master Boot Record
zerombr


# Partition clearing information
clearpart --all --initlabel

# Disk partitioning information
part /boot --fstype="ext3" --size=128
part swap --size=1024
part / --fstype="ext3" --size=4096
part /var --fstype="ext3" --grow --size=1

# Pre installation
#%pre

# Packages to be installed
%packages --resolvedeps
e2fsprogs
grub
kernel
ntp
vim-enhanced
gcc
gcc-c++
compat-libstdc++-33-3.2.3-61.i386
ncurses
ncurses-devel
libtermcap
libtermcap-devel
termcap
DiaStar

%post --nochroot
#!/bin/sh

# Copy the Dialogic install from the CDROM
mkdir /mnt/cdrom
mount -t iso9660 /tmp/cdrom /mnt/cdrom
cp /mnt/cdrom/extras/lnx3.1.1_1.tgz /mnt/sysimage/tmp/
cp /mnt/cdrom/extras/Hmp.Uconfig /mnt/sysimage/tmp/
tar -zxvf /mnt/sysimage/tmp/lnx3.1.1_1.tgz -C /mnt/sysimage/tmp/
umount /mnt/cdrom
rmdir /mnt/cdrom


# Post installation
%post
#!/bin/sh

# Disable root ssh access
#echo 'PermitRootLogin no' >> /etc/ssh/sshd_config

# Create admin account
useradd -c 'System administrator' -m -p 'admin' admin
echo 'export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin' >> /home/admin/.bash_profile
echo 'admin ALL = ALL' >> /etc/sudoers

# Create the DiaStar user
useradd -c 'DiaStar user account' diastar

# Install Dialogic
cd /tmp/redistributable-runtime/
./install.sh --silent ALL

# RTP latency mods
cp /tmp/Hmp.Uconfig /usr/dialogic/data

# Stop CentOS yum updates
rm -f /etc/yum.repos.d/*

# Performance mods
#
sysctl -w fs.file-max=100000
sysctl -w net.core.netdev_max_backlog=8192
sysctl -w net.core.somaxconn=8192



The file isolinux.cfg specifies that the splash screen to be displayed before starting the boot process is called boot.msg:

^L
^Xsplash.lss

Press <ENTER> to start the installation.


WARNING: All data will be erased and the disk is formatted.
-----------------------------------------------------------


Root password is "opendialogic".


^O02[F1-Main] [F2-Options] [F3-General] [F4-Kernel]^O07

Note: Adapt the other files options.mgs, general.msg, param.msg to your liking.

Changing the splash.lss File

The splash.lss file is the splash file that displays in the very first screen after the machine restarts and presents the user with the boot options. This file is in the directory /isolinux. An excellent description of how to do this is here.

  • First Step:

Create an image file of the format 640 x 220 pixels using The Gimp. Down sample the colour depth to 14 colours. This is done in GIMP by going to ->Image->Mode - select "indexed". Then save the file in the png format.

  • second Step:

Convert the .png file to .lss

$ pngtopnm splash.png | ppmtolss16 '#c0c0c0=7' > splash.lss
  • Third Step:

Copy the file splash.lss to the /isolinux directory.

Additional Notes on Down sampling Colour Depth in GIMP:Our target number of colours is 16. However, consider setting this to 15 or 14 to save one or two slots in the index table for one or two text colours. Alternatively, you can select suitable text colours from your resulting image and use them in your boot.msg (or whatever your welcome screen text is called).

In The Gimp indexing dialog, you can also select an appropriate palette optimization method. For images originating in photos with a large number of colour shades use one of the Floyd-Steinberg dithering methods. This produces mellow random noise in the resulting image, greatly reducing the effects of low color depth. If you have a flat-colour company logo, choose "no dithering" - your company colours will be slightly shifted but clean.

Please note that if you're already in indexed mode, e.g. as a result of loading an 8bpp GIF as a master image of your splash screen, you need to switch to RGB mode first and then back to indexed in order to get to the index generation screen, to get the palette down to 16 colours. The colour palette can be checked using [context menu]->dialogs->indexed palette.

Changing the Splash Image displayed by Grub (splash.xpm.gz)

  1. Start the GIMP.
  2. Click on File->New or type Ctrl+N
  3. In the new image dialog, change Width to 640 pixels and Height to 480 pixels. (The image should be of size 640x480 pixels.) Now click OK.
  4. Create the image which you would like to be the splash image. It's quite fun to experiment with the various tools of the GIMP!
  5. After you have finished creating the image, hit Alt+i or right click on the image and click on Image->Mode->Indexed...
  6. In the Indexed Color Conversion dialog that appears, click on the radio button "Generate optimal Palette" and in "# of colors" enter 14. Click OK.(The image should be of only 14 colors)
  7. Now right-click on the image and click on File->Save As...Save the file as splash.xpm in a directory of your choice.
  8. Now open a terminal window and navigate to the directory where you have saved splash.xpm
  9. Now key in gzip splash.xpm
  10. You will find that a file named splash.xpm.gz is created in the directory where splash.xpm used to exist.
  11. Copy this splash.xpm.gz to the /boot/grub directory. You may want to back up the pre-existing splash.xpm.gz file in the /boot/grub directory first.

Customizing Anaconda

Anaconda is the program that provides all the installation services and displays all the graphics during the installation process. It is included in the directory cd1/images in a file-system image file called stage2.img. An excellent explanation of how to edit this image manually can be found here.

Changing the Graphics displayed by Anaconda

The following describes a crude way of changing the artwork used by Anaconda during the installation process. The cleaner way would be to use buildinstall to create a new installer. In this case we start with an existing installer and modify it.

The file-system image of the Anaconda installer can be found in cd1/images. The image file is called stage2.img. We will now mount this image so that we can look inside.

$ mkdir ~/anaconda
$ mount -o loop cd1/images/stage2.img ~/anaconda

Now we need to copy the contents to a directory where we can alter the files. A simple cp command was claimed to not work because of some hard links included in the image. For this reason we use tar to package the contents of the directory and then untarred them where we could work on them.

$ cd ~/anaconda
$ tar -cvf ~/stage2.tar .
$ cd ~
$ mkdir stage2
$ cd stage2
$ tar -xvf ../stage2.tar 

Now we can alter the artwork used by the installer located in usr/share/anaconda/pixmaps and the artwork used in the installation slide show in usr/share/anaconda/pixmaps/rnotes. You can also edit the text in the left sidebar, which is in HTML format, in usr/share/anaconda/help/[locale].

After you've made the desired modifications, we need to compress this information back into an .img file.

$ cd ~
$ mksquashfs  stage2/ stage2.img.new 

Then, copy the altered stage2.img to the images directory.

$ cp stage2.img.new cd1/images/stage2.img

Creating a Customized CentOS Distribution

The next steps describe how to create a customized distribution of CentOS that includes only the packages we want and their dependencies. This is the most time consuming step as it is an iterative process where you select packages and then test for dependencies until all dependencies are resolved.

Choose the appropriate RPMs to be in CentOS/RPMS

This is the most difficult step. It involves selecting a set if RPMS that comprise all the necessary elements for Linux to install and boot. In addition it requires all the RPMS required for the system you are building. In addition, all the dependencies have to be resolved. And lastly, its size must not exceed what can fit onto a single CD.

We started with the first CD of the CentOS 5 distribution. The list of RPMs we deleted is long.

In addition, it is possible to update the RPMs to their latest patch level which makes it unnecessary to run yum update after the system is installed.

Test if all dependencies for all the RPMs in CentOS/RPMS are resolved

The following test is absolutely crucial. Inevitably once you start removing or adding RPMs to the repository, you will have to make sure that all dependencies are resolved properly. Once the test below passes, you have succeeded to create a self-contained repository that will install properly.

$ cd ~
$ mkdir testdb
$ rpm --initdb --dbpath $PWD/testdb
$ rpm --test --dbpath $PWD/testdb -Uvh cd1/CentOS/*.rpm

Create repodata using createrepo

$ cd ~
$ createrepo -g repodata/comps.xml ~/cd1/

Create the ISO Image

$ cd ~
$ mkisofs -R -J -T -no-emul-boot -boot-load-size 4 -boot-info-table -V "DiaStar 1.0" \
-A "Created on 27/7/2009" -P "DiaStar" -p "DiaStar" -b isolinux/isolinux.bin \
-c isolinux/boot.cat -x "lost+found" -o DiaStar.iso cd1

Optional (for check disk utility):

$ /usr/lib/anaconda-runtime/implantisomd5 DiaStar.iso

The ISO image can now be burnt to a CD for test.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值