Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 965e33040dd61030a94f0eb89877aee8 > files > 2821

howto-html-en-20080722-2mdv2010.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
 <TITLE>RedHat Linux KickStart HOWTO: The KickStart config file</TITLE>
 <LINK HREF="KickStart-HOWTO-7.html" REL=next>
 <LINK HREF="KickStart-HOWTO-5.html" REL=previous>
 <LINK HREF="KickStart-HOWTO.html#toc6" REL=contents>
</HEAD>
<BODY>
<A HREF="KickStart-HOWTO-7.html">Next</A>
<A HREF="KickStart-HOWTO-5.html">Previous</A>
<A HREF="KickStart-HOWTO.html#toc6">Contents</A>
<HR>
<H2><A NAME="s6">6. The KickStart config file</A></H2>

<P>
<P>There are three main sections to the config file:
<P>
<P>
<OL>
<LI> System info, e.g. disk partitioning and network config</LI>
<LI> RedHat packages to install</LI>
<LI> Post-installation shell commands to run</LI>
</OL>
<P>
<P>There are some other possibilities which we won't talk about here, but
<B>might</B> work.  For more information check out the sample
KickStart config in <EM>misc/src/install/ks.samp</EM> and
<EM>doc/README.ks</EM> under the top level <EM>i386</EM> RedHat
distribution directory on your CD-ROM or local RedHat mirror site.
<P>
<P>
<P>
<H2><A NAME="ss6.1">6.1 System info</A>
</H2>

<P>
<P>The available directives which I've been using are:
<P>
<P>
<DL>
<DT><B>lang</B><DD><P>Language configuration, e.g. for English
<BLOCKQUOTE><CODE>
<PRE>
lang en
</PRE>
</CODE></BLOCKQUOTE>
<DT><B>network</B><DD><P>Network configuration, e.g. to use BOOTP/DHCP
<BLOCKQUOTE><CODE>
<PRE>
network --bootp
</PRE>
</CODE></BLOCKQUOTE>
<DT><B>nfs</B><DD><P>NFS server and directory to install from, e.g.
<BLOCKQUOTE><CODE>
<PRE>
nfs --server chicken.swedish-chef.org /mnt/cdrom
</PRE>
</CODE></BLOCKQUOTE>

to use the NFS server <EM>chicken.swedish-chef.org</EM> and try to
mount the RedHat distribution from the directory <EM>/mnt/cdrom</EM>.
<DT><B>keyboard</B><DD><P>Select keyboard type, e.g. for UK keyboards
<BLOCKQUOTE><CODE>
<PRE>
keyboard uk
</PRE>
</CODE></BLOCKQUOTE>
<DT><B>zerombr</B><DD><P>Clear the Master Boot Record - removes any existing
operating system boot loader from your disk
<DT><B>clearpart</B><DD><P>Clear existing partitions - e.g. to remove all existing
disk partitions prior to installation
<BLOCKQUOTE><CODE>
<PRE>
clearpart --all
</PRE>
</CODE></BLOCKQUOTE>
<DT><B>part</B><DD><P>Partition the disk, e.g. to make a root filesystem of
500MB
<BLOCKQUOTE><CODE>
<PRE>
part / --size 500
</PRE>
</CODE></BLOCKQUOTE>
<DT><B>install</B><DD><P>Make a fresh installation of RedHat Linux.
<DT><B>mouse</B><DD><P>Set the mouse being used, e.g. for a PS/2 or compatible
"bus mouse"
<BLOCKQUOTE><CODE>
<PRE>
mouse ps/2
</PRE>
</CODE></BLOCKQUOTE>
<DT><B>timezone</B><DD><P>Set the timezone, e.g. for local time in the UK
<BLOCKQUOTE><CODE>
<PRE>
timezone --utc Europe/London
</PRE>
</CODE></BLOCKQUOTE>
<DT><B>rootpw</B><DD><P>Set the initial root password, based on a previously
derived encrypted password
<BLOCKQUOTE><CODE>
<PRE>
rootpw --iscrypted XaacoeGPmf/A.
</PRE>
</CODE></BLOCKQUOTE>
<DT><B>lilo</B><DD><P>Install the LILO boot loader, e.g. in the Master Boot Record
<BLOCKQUOTE><CODE>
<PRE>
lilo --location mbr
</PRE>
</CODE></BLOCKQUOTE>
<DT><B>%packages</B><DD><P>Packages to install - see below.
<DT><B>%post</B><DD><P>Post-installation shell commands - see below.
</DL>
<P>
<P>Note that the directory where KickStart is looking for the RedHat
distribution should have a subdirectory <EM>RedHat</EM>, which
contains the RedHat distribution tree for the platform in question.
In the above example, we should see something like the following files
and directories:
<P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
/mnt/cdrom/RedHat
/mnt/cdrom/RedHat/base
/mnt/cdrom/RedHat/contents
/mnt/cdrom/RedHat/i386
/mnt/cdrom/RedHat/instimage
/mnt/cdrom/RedHat/RPMS
/mnt/cdrom/RPM-PGP-KEY
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>If you're installing off a CD-ROM rather than off the network, the
contents should look something like this:
<P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
RedHat
RedHat/base
RedHat/contents
RedHat/i386
RedHat/instimage
RedHat/RPMS
RPM-PGP-KEY
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>If you have the RedHat distribution for multiple architectures (e.g.
on an NFS server - they're too big to fit more than one architecture's
version onto a single CD-ROM), you'll notice that each distribution
has the same files and directories under a subdirectory, e.g.
<P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
alpha/RPM-PGP-KEY
i386/RPM-PGP-KEY
sparc/RPM-PGP-KEY
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>There should be a file <CODE>architecture</CODE>/Redhat/<CODE>architecture</CODE>,
e.g. <EM>i386/Redhat/i386</EM>.
<P>
<P>If you want to create your own encrypted passwords, it's very easy
using Perl, e.g.
<P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
% perl -e 'print crypt("schmurrdegurr", "Xa") . "\n";'p
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>Other options (or mooted options), which I've not tried:
<P>
<P>
<DL>
<DT><B>cdrom</B><DD><P>Install off CD-ROM rather than network.
<DT><B>device</B><DD><P>Explicitly declare device details, e.g.
<BLOCKQUOTE><CODE>
<PRE>
device ethernet 3c509 --opts "io=0x330, irq=7"
</PRE>
</CODE></BLOCKQUOTE>

Alternative values of <CODE>device</CODE> include <CODE>scsi</CODE> for SCSI
controllers and <CODE>cdrom</CODE> for proprietary CD-ROM drives.
<DT><B>upgrade</B><DD><P>Upgrade an existing installation rather than make
a fresh installation.
<DT><B>xconfig</B><DD><P>Configure X Window server, graphics card and monitor.
e.g.
<BLOCKQUOTE><CODE>
<PRE>
xconfig --server "Mach64" --monitor "tatung cm14uhe"
</PRE>
</CODE></BLOCKQUOTE>
</DL>
<P>
<P>I've not delved too deeply into this last one, because I'm not ever
planning to run X on the console of any of my KickStarted machines.
I'm told that running <CODE>xconfig</CODE> within KickStart itself is a
bit flaky, but the same functionality is also available from the
command line via <CODE>Xconfigurator</CODE> - so you might be best off
leaving this to the post-installation script.
<P>
<P>Here's how this first part of a KickStart config file looks when we
put all the bits together:
<P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
lang en
network --static --ip 198.168.254.253 --netmask 255.255.255.0
  --gateway 198.168.254.1 --nameserver 198.168.254.2
nfs --server chicken.swedish-chef.org /mnt/cdrom
keyboard uk
zerombr yes
clearpart --all
part / --size 500
part swap --size 120
install
mouse ps/2
timezone --utc Europe/London
rootpw --iscrypted XaacoeGPmf/A.
lilo --location mbr
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>Note that some of the RedHat documentation refers to an invocation
of the <CODE>network</CODE> directive which doesn't actually work in
practice: <CODE>network --option</CODE>.  The correct invocation is to
put <CODE>network</CODE> followed by <CODE>--static</CODE>, <CODE>--bootp</CODE>
or <CODE>--dhcp</CODE>.  Be aware that the BOOTP and DHCP options are
different - to the extent that they even use different code.
<P>
<P>You can add the <CODE>--grow</CODE> parameter to a <CODE>part</CODE>
directive to indicate that it's OK to grow the partition beyond
the size you specify.  It probably only makes sense to have one
partition tagged with <CODE>--grow</CODE>.
<P>
<P>
<P>
<H2><A NAME="ss6.2">6.2 Packages to install</A>
</H2>

<P>
<P>The start of the packages section of the KickStart config file is
indicated by the presence of a <CODE>%packages</CODE> directive on a line
of its own.  This is followed by one or both of two types of package
specifier - individual packages may be installed by giving the name of
their RPM (excluding the version and platform information), and groups
of packages may be installed by giving their group name.
<P>
<P>Here's a sample <CODE>packages</CODE> section for a KickStart config file:
<P>
<BLOCKQUOTE><CODE>
<PRE>
%packages
@ Base
netkit-base
bind-utils
ncftp
rdate
tcp_wrappers
traceroute
cmu-snmp
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>So, what are these groups ?  Well, there are a number of groups
defined by default in a file called <EM>base/comps</EM> under the
RedHat distribution's top level directory.  Here are the ones which
were current at the time of writing:
<P>
<P>
<UL>
<LI> Base</LI>
<LI> Printer Support</LI>
<LI> X Window System</LI>
<LI> Mail/WWW/News Tools</LI>
<LI> DOS/Windows Connectivity</LI>
<LI> File Managers</LI>
<LI> Graphics Manipulation</LI>
<LI> X Games</LI>
<LI> Console Games</LI>
<LI> X multimedia support</LI>
<LI> Console Multimedia</LI>
<LI> Print Server</LI>
<LI> Networked Workstation</LI>
<LI> Dialup Workstation</LI>
<LI> News Server</LI>
<LI> NFS Server</LI>
<LI> SMB (Samba) Connectivity</LI>
<LI> IPX/Netware(tm) Connectivity</LI>
<LI> Anonymous FTP/Gopher Server</LI>
<LI> Web Server</LI>
<LI> DNS Name Server</LI>
<LI> Postgres (SQL) Server</LI>
<LI> Network Management Workstation</LI>
<LI> TeX Document Formatting</LI>
<LI> Emacs</LI>
<LI> Emacs with X windows</LI>
<LI> C Development</LI>
<LI> Development Libraries</LI>
<LI> C++ Development</LI>
<LI> X Development</LI>
<LI> Extra Documentation</LI>
</UL>
<P>
<P>You'll notice that they correspond to the various configurations which
you're prompted for during a manual installation.  Note that some of
the packages in a given package group are duplicated in other groups,
and that you can install multiple groups of packages without this
causing problems.  Each group's entry in the <EM>comps</EM> listing
looks similar to this:
<P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
0 Extra Documentation
sag
lpg
howto
faq
man-pages
end
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>It seems that groups with a <EM>1</EM> next to their name (the first
line above) are selected for installation by default.  You can customise
the Linux installation process even further by creating your own groups
or redefine existing ones by editing this file.
<P>
<P>
<P>
<H2><A NAME="ss6.3">6.3 Post-installation shell commands</A>
</H2>

<P>
<P>This is probably the best feature of all, and something which there is
no direct equivalent to in the manual installation process.  What we
can do here is specify a sequence of shell level commands which should
be executed after the main installation (disk partitioning, package
installation, and so on) is complete.
<P>
<P>The beginning of this section is signified by the <CODE>%post</CODE>
directive in the KickStart config file.  In what follows you can take
advantage of all of the utilities which have been installed on your
newly built Linux system, e.g.
<P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
%post
ln -s /etc/rc.d/init.d /etc/init.d
ln -s /etc/rc.d/rc.local /etc/rc.local
ln -s /usr/bin/md5sum /usr/bin/md5
ln -s /usr/bin/perl /usr/local/bin/perl
chmod ug-s /bin/linuxconf
mkdir /var/tmp/tmp
perl -spi -e 's!image=/boot/vmlinuz-.*!image=/boot/vmlinuz!' /etc/lilo.conf
rm /etc/rc.d/rc*.d/*sendmail
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>You can also use I/O redirection and here documents:
<P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
cat &lt;&lt;EOF >>/etc/passwd
squid:*:102:3500:Squid Proxy:/usr/squid:/bin/bash
EOF

cat &lt;&lt;EOF >>/etc/group
cache:x:3500:
EOF
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>Modify the run-time startup scripts:
<P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
cat &lt;&lt;EOF >>/etc/rc.local
echo 8192 > /proc/sys/kernel/file-max
echo 32768 > /proc/sys/kernel/inode-max 

[ -x /usr/sbin/sshd ] &amp;&amp; /usr/sbin/sshd
[ -x /usr/sbin/cfd ] &amp;&amp; /usr/sbin/cfd

EOF
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>Set up <EM>crontab</EM> entries:
<P> 
<P>
<BLOCKQUOTE><CODE>
<PRE>
cat &lt;&lt;EOF >/tmp/crontab.root
# Keep the time up to date
0,15,30,45 * * * * /usr/sbin/ntpdate -s eggtimer 2>&amp;1 >/dev/null
# Recycle Exim log files
1 0 * * * /usr/exim/bin/exicyclog
# Flush the Exim queue
0,15,30,45 * * * * /usr/exim/bin/exim -q
EOF

crontab /tmp/crontab.root
rm /tmp/crontab.root
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>And even install other RPMs which you made yourself:
<P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
rpm -i ftp://chicken.swedish-chef.org/rpms/squid.rpm
rpm -i ftp://chicken.swedish-chef.org/rpms/ssh.rpm
rpm -i ftp://chicken.swedish-chef.org/rpms/exim.rpm
rpm -i ftp://chicken.swedish-chef.org/rpms/cfengine.rpm
rpm -i ftp://chicken.swedish-chef.org/rpms/linux.rpm

ssh-keygen -b 1024 -f /etc/ssh_host_key -N ""
depmod -a
</PRE>
</CODE></BLOCKQUOTE>
<P>
<P>Note that you can achieve the same effect by making your own RPMs
containing the commands you want executed - see below for more
information.  Give them a carefully chosen name and you can force them
to be installed first (e.g. name starts with 'aaa') or last (e.g.
name starts with 'zzz').
<P>
<P>Be aware that a less painful way of doing root crontab entries is to
create them as files in one or more of the directories
<EM>/etc/cron.hourly</EM>, <EM>/etc/cron.daily</EM>,
<EM>/etc/cron.weekly</EM> and <EM>/etc/cron.monthly</EM>.
<P>
<P>More information about making your own RPMs is available in Appendix B.
<P>
<P>
<P>
<HR>
<A HREF="KickStart-HOWTO-7.html">Next</A>
<A HREF="KickStart-HOWTO-5.html">Previous</A>
<A HREF="KickStart-HOWTO.html#toc6">Contents</A>
</BODY>
</HTML>