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 02:55
下一篇 2018-05-28 08:55

相关推荐

  • linux文件处理命令和用户管理和权限管理

    文件处理命令
    用户管理
    权限管理

    Linux笔记 2018-05-28
  • Linux下history的用法

    Linux下history的用法 如果你经常使用Linux命令,那么使用history命令无疑会提升你的工作效率。history命令主要用于显示历史指令记录内容, 通过快捷键快速下达历史纪录中的指令, -c: 清空命令历史 清空内存中的历史记录 -d offset: 删除历史中指定的第offset个命令 例如 history -d 153 删除第153条记录…

    2018-04-01
  • 第三周博客作业

    1、列出当前系统上所有已登录的用户名,注意:同一用户登陆多次,则只显示一次即可。
    2、取出最后登录到当前系统的用户的相关信息。
    3、取出当前系统上被用户当作默认shell的最多的那个shell。
    4、将/etc/passwd中的第三个字段数值最大的后10个用户的信息全部改为大写后保存至/tmp/maxusers.txt文件中。
    5、取出当前主机的IP地址,提示:对ifconfig命令的结果进行切分。
    6、列出/etc目录下所有以.conf结尾的文件的文件名,并将其名字转换为大写后保存至/tmp/etc.conf文件中。
    7、显示/var目录下一级子目录或文件的总个数。
    8、取出/etc/group文件中第三个字段数值最小的10个组的名字。
    9、将/etc/fstab和/etc/issue文件的内容合并为同一个内容后保存至/tmp/etc.test文件中。
    10、请总结描述用户和组管理类命令的使用方法并完成以下练习:

    Linux笔记 2018-03-27
  • 第六周

    简述OSI七层模型和TCP/IP五层模型应用层:为计算机用户提供应用程序接口和各种网络服务,通常可见的网络服务协议有:http,https,ftp,smtp,pop。会话层:建立、管理和终止表示层之间的通信会话。网络层:进行逻辑地址寻址,实现不同网络之间的路径选择物理层: 建立维护和断开物理连接应用层:对应OSI七层模型中的应用层、表示层、会话层网络层:物理…

    Linux笔记 2018-07-15
  • RAID

    RAID技术 stripe:条带。将连续的数据切分成相同大小的数据块,把每段数据块分别写入到不同磁盘上的方法。 条带技术可以增加硬盘的读写性能,但是不支持数据容错。最少使用2块盘做条带。磁盘利用率为100% mirror:镜像。镜像技术是将n(2的倍数)块磁盘上的每个数据位同步成相同的数据位。在写数据时,写入2 份数据。镜像技术有容错功能,但是硬盘的写性能有…

    Linux笔记 2018-04-25
  • 随堂笔记2

    记马哥Linux运维课程第二周知识点(持续更新中)   bin目录 存放二进制数据 给普通用户执行的 在Centos7上 绿色的为… 并不是真正的文件夹 而是快捷方式 bin->usr/bin 内容放在一起 ;在6上,这两者并不是同一个目录,分开放 sbin 给管理员执行的二进制程序 media mnt(mount) 充当外围设备…

    Linux笔记 2018-07-29