设为首页 收藏本站
查看: 939|回复: 0

[经验分享] PXE DHCP TFTP NFS自动化部署Linux系统

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-9-30 09:00:16 | 显示全部楼层 |阅读模式
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、客户端测试
QQ截图20150930090003.png


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-120708-1-1.html 上篇帖子: ssh连接报错The authenticity of host '192.168.203.137 (192.168.203.137)' can't be est 下篇帖子: rsync配置文件同步 Linux
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表