PXE DHCP TFTP NFS自动化部署Linux系统

1、安装准备工作

内核、根文件系统存放目录 系统文件存放目录 ks文件存放目录
/tftpboot/系统名/ /pxe/iso/系统名/ /pxe/ks/系统名/

mkdir  -p /tftpboot/{redhat6.6,centos6.5,pxelinux.cfg}

mkdir -p /pxe/iso/centos6.5 /pxe/iso/redhat6.6

mkdir -p /pxe/ks/centos6.5 /pxe/ks/redhat6.6


mount -o loop /iso/CentOS6.5_X86.iso /pxe/iso/centos6.5/

mount -o loop /iso/Redhat6.6_X86.iso /pxe/iso/redhat6.6/


2、安装DHCP、TFTP、NFS

yum -y install dhcp* nfs* tftp*


3、配置DHCP

vim /etc/dhcp/dhcpd.conf


allow booting;

allow bootp;

ignore client-updates;

option routers 172.16.1.254;

option subnet-mask 255.255.255.0;

subnet 172.16.1.0 netmask 255.255.255.0{

        range 172.16.1.150 172.16.1.200;

        next-server 172.16.1.254;

        filename "pxelinux.0";

}


vim /etc/rc.d/init.d/dhcpd

将user=dhcpd、group=dhcpd改为user=root、group=root


chkconfig dhcpd on

service dhcpd start


4、配置NFS

vi  /etc/exports


/pxe/iso/centos6.5 *(rw,sync)

/pxe/ks/centos6.5 *(rw,sync)

/pxe/iso/redhat6.6 *(rw,sync)

/pxe/ks/redhat6.6 *(rw,sync)


chkconfig nfs on

service nfs start


5、配置TFTP

vim /etc/xinetd.d/tftp


service tftp

{

socket_type= dgram

protocol= udp

wait= yes

user= root

server= /usr/sbin/in.tftpd

server_args= -s /tftpboot

disable= no

per_source= 11

cps= 100 2

flags= IPv4

}

chkconfig xinetd on

service xinetd start


通用配置引导文件、配置文件  

cd  /tftpboot  

cp /usr/share/syslinux/pxelinux.0 ./

cp /pxe/iso/centos6.5/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default


差异配置内核文件、根文件系统文件

cp /pxe/iso/centos6.5/images/pxeboot/vmlinuz /pxe/iso/centos6.5/images/pxeboot/initrd.img /tftpboot/centos6.5/

cp  /pxe/iso/redhat6.6/images/pxeboot/{vmlinuz,initrd.img}   /tftpboot/redhat6.6/


6、在/tftpboot目录下新建boot.msg文件

vim /tftpboot/boot.msg

################################################################

Please select system:

redhat6.6

centos6.5

################################################################


7、修改配置文件

vim /tftpboot/pxelinux.cfg/default


timeout 60


display boot.msg


label redhat6.6

 kernel redhat6.6/vmlinuz

 append ks=nfs:172.16.1.254:/pxe/ks/redhat6.6/ks.cfg ksdevice=eth0 initrd=redhat6.6/initrd.img

label centos6.5

 kernel centos6.5/vmlinuz

 append ks=nfs:172.16.1.254:/pxe/ks/centos6.5/ks.cfg ksdevice=eth0 initrd=centos6.5/initrd.img


label vesa

  menu label Install system with ^basic video driver

  kernel vmlinuz

  append initrd=initrd.img xdriver=vesa nomodeset

label rescue

  menu label ^Rescue installed system

  kernel vmlinuz

  append initrd=initrd.img rescue

label local

  menu label Boot from ^local drive

  localboot 0xffff

label memtest86

  menu label ^Memory test

  kernel memtest

  append 



8、生成ks.cfg文件

#platform=x86, AMD64, or Intel EM64T

#version=DEVEL

# Firewall configuration

firewall --disabled

# Install OS instead of upgrade

install

# Use NFS installation media

nfs --server=172.16.1.254 --dir=/pxe/iso/centos6.5

# Root password

rootpw --iscrypted $1$OpOihMEn$H4fb.ML21Qxq1BeVJB/Fr0

# System authorization information

auth  --useshadow  --passalgo=sha512

# Use graphical install

graphical

firstboot --disable

# System keyboard

keyboard us

# System language

lang en_US

# SELinux configuration

selinux --disabled

# Installation logging level

logging --level=info

# Reboot after installation

reboot

# System timezone

timezone  Africa/Abidjan

# System bootloader configuration

bootloader --location=mbr

# Clear the Master Boot Record

zerombr

# Partition clearing information

clearpart --all --initlabel 

# Disk partitioning information

part /boot --asprimary --fstype="ext4" --size=1024

part swap --asprimary --fstype="swap" --size=1024

part / --asprimary --fstype="ext4" --grow --size=1


%packages

@base


%end


9、客户端测试

wKioL1YKU0Kh4VwVAAK3ooeOfxc147.jpg


你可能感兴趣的:(TFTP,DHCP,centos6.5,pxe,NFS自动化部署Linux系统)