网络安装RedHat Enterprises Linux5.4

 

网络安装RedHat Enterprises Linux5.4
 
一、PXE介绍
PXE(preboot execute environment)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服务器下载映像,并由此支持来自网络的操作系统的启动过程,其启动过程中,终端要求服务器分配IP地址,再用TFTP(trivial file transfer protocol)或MTFTP(multicast trivial file transfer protocol)协议下载一个启动软件包到本机内存中并执行,由这个启动软件包完成终端基本软件设置,从而引导预先安装在服务器中的终端操作系统。
 
二、KickStart+DHCP+NFS+TFTP+PXE的工作原理
无光软驱服务器通过PXE网卡启动,从DHCP服务器获取IP,通过TFTP下载pxelinux.0文件找到pxelinux.cfg里的配置文件,按配置文件找着vmlinuz引导Linux进入安装界面,之后选择NFS方式安装系统
 
服务器端配置
第一步:关闭iptables和SElinux
[root@localhost ~]# chkconfig iptables off
[root@localhost ~]# service iptables stop
[root@localhost ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#        enforcing - SELinux security policy is enforced.
#        permissive - SELinux prints warnings instead of enforcing.
#        disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#        targeted - Only targeted network daemons are protected.
#        strict - Full SELinux protection.
SELINUXTYPE=targeted
 
第二步:挂载镜像,安装TFTP与DHCP服务,并进行配置。
[root@localhost ~]# mount /dev/hdc /mnt
mount: block device /dev/hdc is write-protected, mounting read-only
[root@localhost ~]# cd /mnt/Server/
[root@localhost Server]# rpm -ivh tftp-server-0.42-3.1.i386.rpm
warning: tftp-server-0.42-3.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                 ########################################### [100%]
        package tftp-server-0.42-3.1.i386 is already installed
[root@localhost Server]# rpm -ivh dhcp-3.0.5-18.el5.i386.rpm
warning: dhcp-3.0.5-18.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                 ########################################### [100%]
   1:dhcp                   ########################################### [100%]
配置TFTP服务器
[root@localhost Server]# vi /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
#        protocol. The tftp protocol is often used to boot diskless \
#        workstations, download configuration files to network-aware printers, \
#        and to start the installation process for some operating systems.
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -u nobody -s /tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
 
配置DHCP服务器
[root@localhost Server]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
cp: overwrite `/etc/dhcpd.conf'? y
[root@localhost Server]# vi /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
authourtative;
log-facility local7;
subnet 192.168.1.0 netmask 255.255.255.0 {
        range 192.168.1.55 192.168.1.66;
        option routers 192.168.1.1;
        option subnet-mask 255.255.255.0;
        option domain-name-servers 192.168.1.146;              //服务器IP地址
      option domain-name "koalinfo.com";
        option netbios-name-servers 192.168.1.146;        //服务器IP地址
        option time-offset -18000;
        option broadcast-address 192.168.1.255;
        default-lease-time 6000;
        max-lease-time 11400;
         next-server 192.168.1.146;                                //服务器IP地址
        filename "pxelinux.0";                                      //指示启动文件的位置的一个标签,这里是指/tftpboot/pxelinux.0。
}
第三步:创建目录,存放系统安装文件。
[root@localhost Server]# mkdir /disk
[root@localhost Server]# cp -rf /mnt/* /disk/
 
第四步:安装并配置NFS服务器
#查看是否已安装NFS服务器,如果没有安装,进入/mnt/Server/进行安装
[root@localhost ~]# rpm -qa | grep "nfs\|portmap"
portmap-4.0-65.2.2.1
nfs-utils-1.0.9-40.el5
nfs-utils-lib-1.0.8-7.2.z2
[root@localhost ~]# vi /etc/exports
/disk    *(ro.sync)
[root@localhost ~]# service nfs restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [FAILED]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
[root@localhost ~]# exportfs                             //输出NFS配置文件,检查是否生效
/disk            <world>
 
第五步:启动DHCP、NFS、TFTP服务
[root@localhost disk]# service dhcpd start
Starting dhcpd: [ OK ]
[root@localhost disk]# service portmap start
Starting portmap: [ OK ]
[root@localhost disk]# service nfs start
[root@localhost disk]# service xinetd start
Starting xinetd:           
 
第六步:将安装配置脚本文件(/root/anaconda-ks.cfg),重命名为ks.cfg,复制到/disk目录下,然后并共享出/disk目录。
[root@localhost disk]# cd /root
[root@localhost ~]# ls
anaconda-ks.cfg Desktop install.log install.log.syslog
[root@localhost ~]# cp anaconda-ks.cfg /disk/ks.cfg
[root@localhost ~]# exportfs -a; service nfs restart
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 ]
[root@localhost ~]# vi /disk/ks.cfg
将cdrom修改为:nfs --server=192.168.1.146 --dir=/disk
将network --device eth0 --bootproto dhcp修改为:network --device eth0 --bootproto dhcp
将#clearpart --all --drives=sda修改为:clearpart --all –initlabel
 
第七步:配置支持PXE,复制启动时所需要文件。
#确保/tftproot目录存在,不存在,手工创建。
[root@localhost ~]# ls -d /tftpboot/ || make /tftpboot/
/tftpboot/
[root@localhost ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
注意:如果找不到syslinux目录与pxelinux.0文件,那么你就必须安装软件包:syslinux-3.11-4.i386.rpm
[root@localhost ~]# mkdir /tftpboot/pxelinux.cfg
[root@localhost ~]# cd /media/
[root@localhost media]# ls
RHEL_5.3 i386 DVD
[root@localhost media]# cp /media/RHEL_5.3\ i386\ DVD/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
[root@localhost media]# cp /media/RHEL_5.3\ i386\ DVD/isolinux/* /tftpboot/
[root@localhost media]# chmod u+w /tftpboot/pxelinux.cfg/default
[root@localhost media]# vi /tftpboot/pxelinux.cfg/default
timeout 60                                                       //将超时时间修改为60秒
append initrd=initrd.img text 修改为:append ks=nfs:192.168.1.146:/disk/ks.cfg initrd=initrd.img
 
第八步:重启DHCP、NFS、TFTP服务。
[root@localhost ~]# service nfs restart
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 ]
[root@localhost ~]# service dhcpd restart
Shutting down dhcpd: [ OK ]
Starting dhcpd: [ OK ]
[root@localhost ~]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
Starting xinetd: [ OK ]

接下来,创建新的linux虚拟机,点击开机按钮, 即可到系统的安装界面。

你可能感兴趣的:(linux安装,pxe,网络安装)