There are three main sections to the config file:
There are some other possibilities which we won't talk about here, but might work. For more information check out the sample KickStart config in misc/src/install/ks.samp and doc/README.ks under the top level i386 RedHat distribution directory on your CD-ROM or local RedHat mirror site.
The available directives which I've been using are:
Language configuration, e.g. for English
lang en
Network configuration, e.g. to use BOOTP/DHCP
network --bootp
NFS server and directory to install from, e.g.
nfs --server chicken.swedish-chef.org /mnt/cdrom
to use the NFS server chicken.swedish-chef.org and try to
mount the RedHat distribution from the directory /mnt/cdrom.
Select keyboard type, e.g. for UK keyboards
keyboard uk
Clear the Master Boot Record - removes any existing operating system boot loader from your disk
Clear existing partitions - e.g. to remove all existing disk partitions prior to installation
clearpart --all
Partition the disk, e.g. to make a root filesystem of 500MB
part / --size 500
Make a fresh installation of RedHat Linux.
Set the mouse being used, e.g. for a PS/2 or compatible "bus mouse"
mouse ps/2
Set the timezone, e.g. for local time in the UK
timezone --utc Europe/London
Set the initial root password, based on a previously derived encrypted password
rootpw --iscrypted XaacoeGPmf/A.
Install the LILO boot loader, e.g. in the Master Boot Record
lilo --location mbr
Packages to install - see below.
Post-installation shell commands - see below.
Note that the directory where KickStart is looking for the RedHat distribution should have a subdirectory RedHat, 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:
/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
If you're installing off a CD-ROM rather than off the network, the contents should look something like this:
RedHat
RedHat/base
RedHat/contents
RedHat/i386
RedHat/instimage
RedHat/RPMS
RPM-PGP-KEY
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.
alpha/RPM-PGP-KEY
i386/RPM-PGP-KEY
sparc/RPM-PGP-KEY
There should be a file architecture
/Redhat/architecture
,
e.g. i386/Redhat/i386.
If you want to create your own encrypted passwords, it's very easy using Perl, e.g.
% perl -e 'print crypt("schmurrdegurr", "Xa") . "\n";'p
Other options (or mooted options), which I've not tried:
Install off CD-ROM rather than network.
Explicitly declare device details, e.g.
device ethernet 3c509 --opts "io=0x330, irq=7"
Alternative values of device
include scsi
for SCSI
controllers and cdrom
for proprietary CD-ROM drives.
Upgrade an existing installation rather than make a fresh installation.
Configure X Window server, graphics card and monitor. e.g.
xconfig --server "Mach64" --monitor "tatung cm14uhe"
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 xconfig
within KickStart itself is a
bit flaky, but the same functionality is also available from the
command line via Xconfigurator
- so you might be best off
leaving this to the post-installation script.
Here's how this first part of a KickStart config file looks when we put all the bits together:
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
Note that some of the RedHat documentation refers to an invocation
of the network
directive which doesn't actually work in
practice: network --option
. The correct invocation is to
put network
followed by --static
, --bootp
or --dhcp
. Be aware that the BOOTP and DHCP options are
different - to the extent that they even use different code.
You can add the --grow
parameter to a part
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 --grow
.
The start of the packages section of the KickStart config file is
indicated by the presence of a %packages
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.
Here's a sample packages
section for a KickStart config file:
%packages
@ Base
netkit-base
bind-utils
ncftp
rdate
tcp_wrappers
traceroute
cmu-snmp
So, what are these groups ? Well, there are a number of groups defined by default in a file called base/comps under the RedHat distribution's top level directory. Here are the ones which were current at the time of writing:
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 comps listing looks similar to this:
0 Extra Documentation
sag
lpg
howto
faq
man-pages
end
It seems that groups with a 1 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.
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.
The beginning of this section is signified by the %post
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.
%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
You can also use I/O redirection and here documents:
cat <<EOF >>/etc/passwd
squid:*:102:3500:Squid Proxy:/usr/squid:/bin/bash
EOF
cat <<EOF >>/etc/group
cache:x:3500:
EOF
Modify the run-time startup scripts:
cat <<EOF >>/etc/rc.local
echo 8192 > /proc/sys/kernel/file-max
echo 32768 > /proc/sys/kernel/inode-max
[ -x /usr/sbin/sshd ] && /usr/sbin/sshd
[ -x /usr/sbin/cfd ] && /usr/sbin/cfd
EOF
Set up crontab entries:
cat <<EOF >/tmp/crontab.root
# Keep the time up to date
0,15,30,45 * * * * /usr/sbin/ntpdate -s eggtimer 2>&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
And even install other RPMs which you made yourself:
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
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').
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 /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly and /etc/cron.monthly.
More information about making your own RPMs is available in Appendix B.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |