Development:Kickstart CD

来源:互联网 发布:医疗美容网络 编辑:程序博客网 时间:2024/06/05 16:47

Development:Kickstart CD

Contents

[hide]
  • 1Introduction to Using Kickstart
    • 1.1Introduction
    • 1.2Installing Necessary Tools
    • 1.3Create a Working Copy of the CentOS Installation Disk
    • 1.4Create a Kickstart Configuration File - ks.cfg
    • 1.5Changing the splash.lss File
    • 1.6Changing the Splash Image displayed by Grub (splash.xpm.gz)
    • 1.7Customizing Anaconda
      • 1.7.1Changing the Graphics displayed by Anaconda
    • 1.8Creating a Customized CentOS Distribution
      • 1.8.1Choose the appropriate RPMs to be in CentOS/RPMS
      • 1.8.2Test if all dependencies for all the RPMs in CentOS/RPMS are resolved
      • 1.8.3Create repodata using createrepo
      • 1.8.4Create the ISO Image
    • 1.9References
    • 1.10Additional Information

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 thekickstart 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 passwordrootpw --iscrypted $1$137n62W.$C4fWL0yd10McOTZOfwxVu1# System authorization informationauth  --useshadow  --passalgo=md5# Use graphical installgraphicalfirstboot --disable# Skip the X Window System configurationskipx# System keyboardkeyboard us# System languagelang en_US# SELinux configurationselinux --disabled# Install OS instead of upgradeinstall# Use CDROM installation mediacdrom# System timezonetimezone  --utc America/New_York# Network configurationnetwork --bootproto=query --device=eth0 --onboot=on --hostname=diastar# System bootloader configurationbootloader --location=mbr# Clear the Master Boot Recordzerombr# Partition clearing informationclearpart --all --initlabel# Disk partitioning informationpart /boot --fstype="ext3" --size=128part swap --size=1024part / --fstype="ext3" --size=4096part /var --fstype="ext3" --grow --size=1# Pre installation#%pre# Packages to be installed%packages --resolvedepse2fsprogsgrubkernelntpvim-enhancedgccgcc-c++compat-libstdc++-33-3.2.3-61.i386ncursesncurses-devellibtermcaplibtermcap-develtermcapDiaStar%post --nochroot#!/bin/sh# Copy the Dialogic install from the CDROMmkdir /mnt/cdrommount -t iso9660 /tmp/cdrom /mnt/cdromcp /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/cdromrmdir /mnt/cdrom# Post installation%post#!/bin/sh# Disable root ssh access#echo 'PermitRootLogin no' >> /etc/ssh/sshd_config# Create admin accountuseradd -c 'System administrator' -m -p 'admin' adminecho 'export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin' >> /home/admin/.bash_profileecho 'admin ALL = ALL' >> /etc/sudoers# Create the DiaStar useruseradd -c 'DiaStar user account' diastar# Install Dialogiccd /tmp/redistributable-runtime/./install.sh --silent ALL# RTP latency modscp /tmp/Hmp.Uconfig /usr/dialogic/data# Stop CentOS yum updatesrm -f /etc/yum.repos.d/*# Performance mods#sysctl -w fs.file-max=100000sysctl -w net.core.netdev_max_backlog=8192sysctl -w net.core.somaxconn=8192


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

^L^Xsplash.lssPress <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 directorycd1/images in a file-system image file called stage2.img. An excellent explanation of how to edit this image manually can be foundhere.

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 usebuildinstall 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 calledstage2.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 simplecp command was claimed to not work because of some hard links included in the image. For this reason we usetar 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 inusr/share/anaconda/pixmaps/rnotes. You can also edit the text in the left sidebar, which is in HTML format, inusr/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 runyum 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.

原创粉丝点击