快捷搜索:   nginx

PXE无人值守方式安装Centos5

前面做好了PXE主机,但是只是解决了光盘的问题,也就是安装 100台甚至1000台主机的时候只需要一个网络镜像就可以了,但是还是需要花时间对这每台linux主机做具体的设置,也蛮浪费时间的,在 widows中有个无人值守安装,那么在linux能不能做到同样的效果呢?答案是肯定的,这样将大大方便批量方式安装linux系统!

在使用前面的PXE方式安装完一台linux后,在root用户的主目录下将能看 到一个anaconda-ks.cfg文件,下面我们将要使用这个脚本文件来配置PXE方式无人值守安装

[root@localhost ~]# ls
anaconda-ks.cfg install.log install.log.syslog

[root@localhost ~]# cat anaconda-ks.cfg
# Kickstart file automatically generated by anaconda.

install
nfs --server=192.168.0.200 --dir=/mnt
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto dhcp
rootpw --iscrypted $1$g2mP6W0y$vXvC1TRwJkUOfMLC1c0lg0
firewall --enabled --port=22:tcp
authconfig --enableshadow --enablemd5
selinux --enforcing
timezone --utc America/New_York
bootloader --location=mbr --driveorder=hda
# 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 --drives=hda
#part /boot --fstype ext3 --size=100 --ondisk=hda
#part pv.2 --size=0 --grow --ondisk=hda
#volgroup VolGroup00 --pesize=32768 pv.2
#logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=256 --grow --maxsize=512
#logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow

%packages
@core
@base
device-mapper-multipath

[root@centos5 ~]# mkdir /disk
[root@centos5 ~]# vi /disk/ks.cfg   (将anaconda-ks.cfg脚本文件中的内容复制到ks.cfg文件中,这个文件定义了之前安装第一台linux的配置信息)
# Kickstart file automatically generated by anaconda.

install
nfs --server=192.168.0.200 --dir=/mnt (设定nfs服务器的IP和目录)
lang en_US.UTF-8       (设定语言)
keyboard us            (设定键盘)
network --device eth0 --bootproto dhcp (设定IP获取方式为DHCP)
rootpw --iscrypted $1$g2mP6W0y$vXvC1TRwJkUOfMLC1c0lg0 (设定root用户的密码,这里经过了MD5加密)
firewall --enabled --port=22:tcp (防火墙为开启,允许SSH方式访问)
authconfig --enableshadow --enablemd5
selinux --enforcing
timezone --utc America/New_York (时区参数)
bootloader --location=mbr --driveorder=hda (引导的安装参数,其他的我也看不懂了,哈哈!)
# 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 --drives=hda
#part /boot --fstype ext3 --size=100 --ondisk=hda
#part pv.2 --size=0 --grow --ondisk=hda
#volgroup VolGroup00 --pesize=32768 pv.2
#logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=256 --grow --maxsize=512
#logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow

%packages
@core
@base
device-mapper-multipath

[root@centos5 ~]# vi /etc/exports (将/disk目录添加到NFS共享)
/mnt 192.168.0.0/24(ro,sync)
/disk 192.168.0.0/24(ro,sync)

[root@centos5 /]# vi /tftpboot/pxelinux.cfg/default (修改default文件如下)
default linux
prompt 1
timeout 10
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append ks=nfs:192.168.0.200:/disk/ks.cfg initrd=initrd.img (修改此项参数)
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append expert initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -

[root@centos5 ~]# service nfs restart (重启NFS服务)
Shutting down NFS mountd:                                  [ OK ]
Shutting down NFS daemon:                                  [ OK ]
Shutting down NFS quotas:                                  [ OK ]
Shutting down NFS services:                                [ OK ]
Starting NFS services:                                     [ OK ]
Starting NFS quotas:                                       [ OK ]
Starting NFS daemon:                                       [ OK ]
Starting NFS mountd:                                       [ OK ]


这样设置完了后,其他计算机从网卡启动就能获得安装信息,进行自动安装!故不方便截图, 深感抱歉!
顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论