PXE自动化安装centos6与centos7

PXE自动化安装centos7系统
1、确保防火墙和selinux全部关闭
2、yum -y install dhcp tftp-server httpd syslinux
3、启动相关服务
systemctl start httpd
systemctl enable httpd
systemctl start tftp.service
systemctl enable tftp.service
4、编辑dhcp配置文件/etc/dhcp/dhcpd.conf
subnet 192.168.67.0 netmask 255.255.255.0 {
range 192.168.67.150 192.168.67.200;
option routers 192.168.67.253;
next-server 192.168.67.130;
filename “pxelinux.0″;
}
5、启动dhcp服务
Systemctl start dhcpd
Systemctl enable dhcpd
6、自动挂载光盘,供客户端安装系统
mkdir -p /var/www/html/centos/7
vim /etc/fstab
/dev/sr0 /var/www/html/centos/7 iso9660 defaults 0 0
mount -a
7、在/var/www/html/目录下创建ksdir/7目录,编辑应答文件ks7_desktop.cfg放入其中
mkdir -p /var/www/html/ksdir/7
vim ks7_desktop.cfg
cp /root/anaconda-ks.cfg ks7_desktop.cfg
chmod +r ks7_desktop.cfg
vim ks7_desktop.cfg
#version=DEVEL
# System authorization information
auth –enableshadow –passalgo=sha512
# Use CDROM installation media
url –url=http://192.168.67.130/centos/7
# Use graphical install
text
reboot
# Run the Setup Agent on first boot
firstboot –enable
ignoredisk –only-use=sda
# Keyboard layouts
keyboard –vckeymap=us –xlayouts=’us’
# System language
lang en_US.UTF-8

# Network information
network –bootproto=dhcp –device=ens33 –onboot=on –ipv6=auto –activate
network –hostname=centos7

# Root password
rootpw –iscrypted $6$BKZMtfbq7nheJUSc$maT1N3JM4MKPu5u4cwWmmO6PRtlJfapZ11rTt/Vp4jE2IJN1eqL3YXugStz4Ywwn9JeDftsFFVkvxN8/uu9el.
# System services
services –disabled=”chronyd”
# System timezone
timezone Asia/Shanghai –isUtc –nontp
user –name=wang –password=$6$ajL2KgUguatiI0Ix$he/GsnwS19klg6U5J1QhghVlojJuRt8q6pKGEdT/rynfFYH64h7nlBxHiXa8s/qSyup/HI.HekOnc7011t36d/ –iscrypted –gecos=”wang”
# X Window System configuration information
xconfig –startxonboot
# System bootloader configuration
bootloader –append=” crashkernel=auto” –location=mbr –boot-drive=sda
# Partition clearing information
zerombr
clearpart –none –initlabel
# Disk partitioning information
part swap –fstype=”swap” –ondisk=sda –size=2000
part / –fstype=”xfs” –ondisk=sda –size=50000
part /boot –fstype=”xfs” –ondisk=sda –size=1000
part /data –fstype=”xfs” –ondisk=sda –size=30000

%packages
@^gnome-desktop-environment
@base
@core
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@print-client
@x11
autofs
%end

%addon com_redhat_kdump –enable –reserve-mb=’auto’

%end

%anaconda
pwpolicy root –minlen=6 –minquality=1 –notstrict –nochanges –notempty
pwpolicy user –minlen=6 –minquality=1 –notstrict –nochanges –emptyok
pwpolicy luks –minlen=6 –minquality=1 –notstrict –nochanges –notempty
%end

%post
systemctl enable autofs
systemctl disable initial-setup.service
systemctl set-default multi-user.target
mkdir /root/.ssh
cat > /root/.ssh/authorized_keys < /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=file:///misc/cd
gpgcheck=0
EOF
%end

8、在tftp工作目录/var/lib/tftpboot/下创建pxelinux.cfg目录
mkdir -p /var/lib/tftpboot/pxelinux.cfg/
9、拷贝pxelinux.0文件到/var/lib/tftpboot/
rpm -ql syslinux | grep pxelinux.0
/usr/share/syslinux/pxelinux.0
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
10、复制背景菜单文件
[root@centos7 tftpboot]#rpm -ql syslinux | grep menu.c32
/usr/share/syslinux/menu.c32
/usr/share/syslinux/vesamenu.c32
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
11、到光盘下isolinux目录下复制initrd.img,vmlinuz到/var/lib/tftpboot/目录
cp /misc/cd/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/
12、复制菜单配置文件到/var/lib/tftpboot/pxelinux.cfg/,并且改名default,之后编辑default
cp /misc/cd/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
vim default

default menu.c32
timeout 600

menu title install centos

label desktop
menu label ^Install desktop CentOS 7
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.67.130/ksdir/7/ks7_desktop.cfg

label check
menu label Test this ^media & install CentOS 7
menu default
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet

menu end

Pxe自动化安装centos6
1、首先确认防火墙和selinux全部关闭
2、yum -y install dhcp tftp-servier httpd syslinux
3、开启相关服务
chkconfig tftp on
service xinetd restart
Service httpd start
Chkconfig httpd on
4、编辑dhcp配置文件
subnet 192.168.67.0 netmask 255.255.255.0 {
range 192.168.67.50 192.168.67.100;
option routers 192.168.67.254;
option domain-name-servers 8.8.8.8;
next-server 192.168.67.131;
filename “pxelinux.0”;
}
5、启动dhcp服务并设置开机启动
Service dhcpd start
Chkconfig dhcpd on
6、在/var/www/html目录下创建centos/6目录
mkdir -p centos/6
7、自动挂载光盘
/dev/sr0 /var/www/html/centos/6 iso9660 defaults 0 0
8、创建目录/var/www/html/ksdir/6,并且生成应答文件ks6_mini.cfg放置其中
mkdir -p /var/www/html/ksdir/6
cp ks6_mini.cfg /var/www/html/ksdir/6
chmod +r ks6_mini.cfg
9、进入到tftp工作目录/var/lib/tftpboot/,创建目录pxelinux.cfg
10、找到并复制pxelinux.0到/var/lib/tftpboot/
updatedb
locate
cp /usr/share/syslinux/pxelinux.0 ./
11、到光盘isolinux/目录下复制initrd.img vmlinuz到/var/lib/tftpboot/目录下
cp /misc/cd/isolinux/{initrd.img,vmlinuz} ./
12、复制菜单相关文件
cp /misc/cd/isolinux/{splash.jpg,vesamenu.c32} ./
13、复制菜单配置文件到/var/lib/tftpboot/pxelinux.cfg目录下
cp /misc/cd/isolinux/isolinux.cfg ./pxelinux.cfg/default

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/99638

(2)
王琪锋王琪锋
上一篇 2018-05-28
下一篇 2018-05-28

相关推荐

  • 文件实时查找工具-find

    find:命令 实时查找工具,通过遍历指定路径完成文件查找 工作特点:查找速度慢,精确查找,实时查找,可能只搜索用户具备读取和执行的目录 用法:  find【OPTION]…[查找路径】【查找条件】【处理动作】 查找路径:指定具体目标路径;默认为当前目录查找条件:指定的查找标准,可以文件名、大小、类型、权限等标准进行;默认为找出指定路径下的所有文…

    2018-04-13
  • linux操作系统启动流程和创建

    1、简述linux操作系统启动流程
    2、简述grub启动引导程序配置及命令行接口详解
    3、实现kickstart文件制作与光盘镜像制作

    2018-06-20
  • 计算机构成简介与Linux基础知识

        ◆ 命令—Linux学习的基础,而基础就是核心。◆ 没有基础就只如空中楼阁,每次处理问题的时候,都需要向外界的力量求教,而缺乏自己解决问题的能力。◆ 学习比较被动,知识的储备速度不能紧跟使用需求。◆ SO,夯实基础反而成为重中之重。想要万丈高楼平地起,就先打好地基,在人们还看不见的时候,挥洒着汗水;而时间会给你成长的回报! 一、计算机构成与功能简介 …

    Linux笔记 2018-04-03
  • Linux学习笔记——权限管理

    Linux学习笔记——权限管理 前言: Linux下的权限管理与日常使用的windows有众多与众不同之处。这些特性使得Linux在实际生产作业中更加安全与高效,发挥着各种灵活的作用。本文简要写下笔者对Linux权限管理的理解,供参考与复习,欢迎指正。 回顾: 确认文件的权限与所有者: 使用ll(即ls -l) 命令可查看这个文件的详细信息。 $ ll da…

    2018-04-07
  • 相信过程-马哥教育

    IT工程师工作和学习都是比较枯燥的,过于目标化忽略了过程本身并不适合我,如果我来这里能使我全心全意投入到一段学习当中,我觉得来这里目标就达到了。其他的事情自然会水到渠成。 大家共勉!

    2018-07-21