使用kickstarts来安装Linux

kickstar是redhat的一种安装方式。使用起来非常简单。只需要修改redhat所有版本的第一个Iso文件里的isolinux/isolinux.cfg文件,修改完成后重新打包好iso就可以了。 修改这个文件主要是确认这个新装的LINUX在安装时候来定义一个IP。

我自己定义的isolinux.cfg文件定义如下。


 default linux ip=172.16.1.253 netmask=255.255.255.0 gateway=172.16.1.1 ks=http://192.168.1.254:8080/ks.cfg prompt 1 timeout 8 display boot.msg label linux kernel vmlinuz append initrd=initrd.img 

这里default linux ip=172.16.1.253 netmask=255.255.255.0 gateway=172.16.1.1 定义的是这个linux机器安装时候所使用的IP和子网掩码以及网关。当然如果你内网有DHCP服务器的话那也可以通过DHCP来获取IP,但是一般机房内我们不会单独设置一个DHCP服务器,所以这里使用的固定IP,这种方法更可靠。

ks=http://192.168.1.254:8080/ks.cfg 这个是定义ks.cfg文件的下载地址。

ks.cfg文件里包含了所有你需要的安装选项,如果没有这个文件,那系统安装也无法继续进行了。任何redhat机器安装完成都会在用户主目录下包含有ks.cfg这个文件。一般我们使用的使用的ks.cfg文件还会根据自己的要求来修改。主要修改的是%post后面的内容。

但是需要注意这里最好使用完整的路径


 install text url --url http://192.168.1.254:8080/rhel key 2515dd4e215225dd lang en_US.UTF-8 keyboard us #xconfig --startxonboot skipx network --device eth0 --bootproto static --ip 172.16.1.10 --netmask 255.255.0.0 --gateway 172.16.0.254 --nameserver 202.96.209.6 --hostname kickstart.test.com #123456 rootpw --iscrypted $1$jTyfIbbE$aSiDPkLNeVs7hQaFljqgS1 firewall --enabled --port=22:tcp authconfig --enableshadow --enablemd5 selinux --enforcing timezone Asia/Shanghai bootloader --location=mbr --driveorder=sda --append="rhgb quiet" # 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 --linux #part /boot --size 2048 --fstype=ext3 part / --size 50480 --fstype=ext3 --asprimary part swap --size 256 %packages @admin-tools @base @base-x @core @development-libs @development-tools @dialup @editors @gnome-desktop @gnome-software-development @graphical-internet @java @text-internet kernel-devel %post /sbin/chkconfig --level 345 sshd on /sbin/chkconfig --level 0123456 kudzu off /sbin/chkconfig --level 0123456 cups off /sbin/chkconfig --level 0123456 autofs off /sbin/chkconfig --level 0123456 sendmail off /sbin/chkconfig --level 0123456 atd off /sbin/chkconfig --level 0123456 iptables off /sbin/chkconfig --level 0123456 xinetd off /sbin/chkconfig --level 0123456 portmap off /sbin/chkconfig --level 0123456 pcmcia off /sbin/chkconfig --level 0123456 gpm off /sbin/chkconfig --level 0123456 rhnsd off /sbin/chkconfig --level 0123456 isdn off /sbin/chkconfig --level 0123456 nfslock off /sbin/chkconfig --level 0123456 rawdevices off /sbin/chkconfig --level 0123456 keytable off /sbin/chkconfig --level 0123456 apmd off /sbin/chkconfig --level 0123456 anacron off /sbin/chkconfig --level 0123456 xfs off /sbin/chkconfig --level 0123456 netfs off /sbin/chkconfig --level 0123456 ip6tables off /sbin/chkconfig --level 0123456 arptables_jf off /sbin/chkconfig --level 0123456 microcode_ctl off /sbin/chkconfig --level 0123456 irqbalance off /sbin/chkconfig --level 0123456 mdmonitor off /sbin/chkconfig --level 0123456 hpoj off /sbin/chkconfig --level 0123456 sgi_fam off /sbin/chkconfig --level 0123456 audit off /sbin/chkconfig --level 0123456 firstboot off /sbin/chkconfig --level 0123456 vsftpd off cd /usr/local/ /usr/bin/wget http://192.168.1.254:8080/source.tar.gz /bin/tar zxvf source.tar.gz /usr/local/source/scripts/sys-init.sh >>/tmp/sys-alert 2>&

url –url http://192.168.21.254:8080/rhel 这里定义的安装时候需要相关一些包的地址,所以由于centos这样的系统有很多包,rhel目录下是包含了disk1下所有的内容,同时要把其它盘里Server目录下的内容复制到rhel/Server/目录下。

这里定义的IP就是系统完成后的IP了。这个ks.cfg由于是在服务器端设置的,所以根据不同的需求来进行改变。而%post之后完全可以根据自己的要求来定义。而这里的路径请使用绝对路径。