如何为CentOS / Fedora / RedHat(RHEL)创建Kickstart文件

如何为CentOS / Fedora / RedHat(RHEL)创建Kickstart文件

IT支持公司工作意味着我经常在服务器和台式机上安装CentOS,Fedora和Redhat。 本指南将介绍如何自动化安装过程并安装附加软件后安装脚本,以下CentOS Kickstart教程也可在我的博客上。

首先,如果您以前从未见过kickstart文件,并且在系统上安装了Redhat Linux的风格,请查看/ root目录,您应该看到一个名为“anaconda-ks.cfg”的文件,打开它,您将请参阅在kickstart文件中安装过程中输入的参数。 这是通过示例了解的好方法(提供您可以记住您在启动时选择的选项)。

下面我将给出一个kickstart文件的例子,我在安装了一些安装了VMWare播放器的Fedora笔记本电脑和通过wget拉入的几个虚拟机映像时,使用了一个kickstart文件。 我选择使用一个kickstart安装,使用诸如Symantec Ghost等映像软件的脚本进行Linux安装,因为这使我能够在各种类型的硬件上使用映像,并且通过脚本的调整,我可以在将来大大地自定义安装。 Microsoft WDS / RIS或Ghost不会让我有这样的灵活性。

以下是我在Fedora安装上使用的kickstart,用户友好的评论。

text
install
cdrom
lang en_US.UTF-8
keyboard uk
timezone --utc Europe/London
rootpw  --iscrypted $$nndedddewfooofcerd3r434
selinux --disabled
# Custom user added
user --name=kevinmitnick --groups=users --password=HackThePlanet
authconfig --enableshadow --passalgo=sha512 --enablefingerprint
firewall --service=ssh
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --drives=sda
ignoredisk --only-use=sda
part /boot --fstype=ext2 --asprimary --size=500
part /OtherOS --fstype=ext4 --asprimary --size=10240
part swap --asprimary --size=2048
part pv.fedora1000 --grow --asprimary --size=500
volgroup fedora --pesize=32768 pv.fedora1000
logvol /centosVM --fstype=ext4 --name=centosVM --vgname=fedora --size=30720
logvol /home --fstype=ext4 --name=home --vgname=fedora --size=81920
logvol / --fstype=ext4 --name=root --vgname=fedora --size=25600
logvol /windowsVM --fstype=ext4 --name=windowsVM --vgname=fedora --size=40960
bootloader --location=mbr --driveorder=sda --append="nomodeset rhgb quiet"
# setup the network with DHCP
network --device=eth0 --bootproto=dhcp
# packages that will be installed, anything starting with an @ sign is a yum package group.
%packages
@admin-tools
@authoring-and-publishing
@base
@core
@development-libs
@development-tools
@dial-up
@editors
@education
@electronic-lab
@engineering-and-scientific
@eclipse
@fedora-packager
@fonts
@gnome-desktop
@gnome-software-development
@graphical-internet
@graphics
@hardware-support
@input-methods
@java
@java-development
@kde-desktop
@kde-software-development
@legacy-fonts
@office
@online-docs
@printing
@sound-and-video
@system-tools
@text-internet
@x-software-development
@base-x
kpackagekit
system-config-network
scribus
xfsprogs
mtools
gpgme
gpm
rpmdevtools
koji
mercurial
lua
pylint
rpmlint
plague-client
cmake
mock
bzr
pptp
kdeedu-marble
minicom
opencv
yum-priorities
plotutils
openoffice.org-opensymbol-fonts
qtcurve-gtk2
gvfs-obexftp
glibmm24-devel
gnome-vfs2-devel
libsigc++20-devel
libart_lgpl-devel
kdepim
konversation
ImageMagick
digikam
kipi-plugins
kdegraphics
gypsy
gpsd
hdparm
m17n-db-tamil
m17n-db-gujarati
m17n-db-kannada
m17n-db-hindi
gok
m17n-db-oriya
m17n-db-bengali
m17n-contrib-sinhala
m17n-db-assamese
m17n-db-punjabi
iok
m17n-db-telugu
m17n-db-malayalam
xorg-x11-fonts-ISO8859-1-100dpi
urw-fonts
ghostscript-fonts
kdepim
vorbis-tools
amarok
jack-audio-connection-kit
kaffeine
kdemultimedia
vbetool
gssdp
geoclue
createrepo
radeontool
PackageKit-command-not-found
obexftp
enca
festival
ntpdate
xsel
gupnp
rdesktop
fuse
ncftp
mesa-libGLU-devel
xorg-x11-apps
xscreensaver-gl-extras
gdm
xscreensaver-extras
xscreensaver-base
xterm
xorg-x11-resutils
gitk
git-gui
dia
tftp
python-crypto
boost-devel
valgrind
subversion
cvs
thunderbird-lightning
python-sqlite2
asciidoc
glibc-static
tcllib
python-psycopg*
ssh*
perl-ExtUtils-MakeMaker
perl-Net-Telnet
perl-HTML-FromText
libICE.so.6
libSM.so.6
libXmu.so.6
libXp.so.6
libXpm.so.4
libXt.so.6
help2man
cscope
ctags
git
kernel-devel
tftp-server
texlive-latex
texi2html
cmake
transfig
alsa-lib
libXScrnSaver
qt
qt-x11
libasound.so.2

libXss.so.1
libQtDBus.so.4
libQtGui.so.4
pulseaudio
alsa-plugins-pulseaudio
pulseaudio-esound-compat
pulseaudio-libs
pulseaudio-libs-glib2
pulseaudio-module-zeroconf
pulseaudio-libs-zeroconf
xmms-pulse
pulseaudio-module-gconf
wine-pulseaudio
xine-lib-pulseaudio
pulseaudio-utils
pulseaudio-module-bluetooth
padevchooser
paman
paprefs
pavucontrol
pavumeter
ncurses-devel.i686
%end
%post --log=/root/my-post-log
exec < /dev/tty3 > /dev/tty3
chvt 3
echo
echo "################################"
echo "# Running Post Configuration   #"
echo "################################"
# prevent future yum updates pulling down & install new kernels (and breaking VMware & video drivers).
echo "exclude=kernel*" >> /etc/yum.conf
# update the system
yum update -y 
# install rpm fusion repo
rpm -Uvh \
http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm \
http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
# disable rpmfusion repo, to prevent a yum update contaminating the system with rpmfusion rpms.
sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/rpmfusion-*
# install video drivers - enabling rpmfusion repos on the command line.
yum -y --enablerepo=rpmfusion-nonfree --enablerepo=rpmfusion-free  --enablerepo=rpmfusion-free-updates --enablerepo=rpmfusion-nonfree-updates install kmod-nvidia xorg-x11-drv-nvidia-libs.i686 xorg-x11-drv-nvidia-libs.x86_64 akmod-nvidia
# start akmods on boot
chkconfig akmods on
# add pcadmin to sudoers
echo "kevinmitnick ALL=(ALL)       ALL" >> /etc/sudoers
# set perms on vmware partitions so users in the users group can create vm's
chown :users /windowsVM && chmod 775 /windowsVM
chown :users /centosVM && chmod 775 /centosVM
# Make sure the system boots X by setting the system to run level 5
sed -i 's/id:3:initdefault:/id:5:initdefault:/g' /etc/inittab
# install openvpn & configure
wget ftp://$host/pub/VPN/OpenVPN/Linux/openvpnclient-custom-settings-1.6-3.i386.rpm
rpm -ivh openvpnclient-custom-settings-1.6-3.i386.rpm
cd /etc/openvpn/
rm client.conf-*
wget ftp://$host/pub/VPN/OpenVPN/Linux/64bit/client.conf-1
mv client.conf-1 client.conf-0
rm -f /openvpnclient-custom-settings-1.6-3.i386.rpm
# add Kevin Mitnick to group users
usermod -a -G users kevinmitnick
# pull down vmware images
cd /windowsVM/
wget --user=magicinstaller --password=hacktheplanet ftp://magicinstaller:fubar@ftp.$host.com/images/windowsVM.tar.gz
tar -xvzf windowsVM.tar.gz
cd /centosVM/
wget --user=magicinstaller --password=hacktheplanet ftp://magicinstaller:fubar@ftp.$host.com/images/centosVM.tar.gz
tar -xvzf centosVM.tar.gz
# create symlink as instructed
cd /usr/lib; ln -s libtinfo.so libtermcap.so.2
# confirm perms are set correctly
chown -R :users /windowsVM && chmod -R 775 /windowsVM
chown -R :users /centosVM && chmod -R 775 /centosVM
# swap to console 1
chvt 1

显然,这个kickstart文件中有一些选项需要被删除并添加到你的要求中,但是你应该能够感受到一个kickstart文件可以实现什么。 如果您想知道如何安装VMWare Player,我必须手动执行此操作,因为VMWare许可的内容(单击接受等)。

分享和评论可在下面...任何问题让我发表评论,我会尽快回复你。

赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏